mirror of
https://github.com/LMMS/lmms.git
synced 2025-12-30 10:08:00 -05:00
* Replace QVector with std::vector in AudioEngine * Replace QVector with std::vector in AudioEngineWorkerThread * Replace QVector with std::vector in AudioJack * Replace QVector with std::vector in AutomatableModel * Replace QVector with std::vector in AutomationClip * Replace QVector with std::vector in AutomationEditor * Replace QVector with std::vector in ConfigManager * Replace QVector with std::vector in Controller * Replace QVector with std::vector in ControllerConnection * Replace QVector with std::vector in EffectChain * Replace QVector with std::vector in EnvelopeAndLfoParameters * Replace QVector with std::vector in InstrumentFunctions * Replace QVector with std::vector in MidiClient * Replace QVector with std::vector in Mixer * Replace QVector with std::vector in Note * Replace QVector with std::vector in PeakController * Replace QVector with std::vector in PianoRoll * Replace QVector with std::vector in PluginFactory * Replace QVector with std::vector in RenderManager * Replace QVector with std::vector in StepRecorder * Replace QVector with std::vector in Track * Replace QVector with std::vector in TrackContainer * Replace QVector with std::vector in Song * Adapt QVector to std::vector changes in ControllerConnectionDialog * Phase 2: Use std::abs in panning.h Without this, the QVector changes will make the code not compile. * Phase 2: Replace QVector with std::vector in PeakControllerEffect * Phase 2: Replace QVector with std::vector in AutomatableModel * Phase 2: Replace QVector with std::vector in AutomationClip * Phase 2: Replace QVector with std::vector in ControllerConnection * Phase 2: Replace QVector with std::vector in EffectChain * Phase 2: Replace QVector with std::vector in Mixer * Phase 2: Replace QVector with std::vector in PeakController * Phase 2: Replace QVector with std::vector in RenderManager * Phase 2: Replace QVector with std::vector in Song * Phase 2: Replace QVector with std::vector in StepRecorder * Phase 2: Replace QVector with std::vector in Track * Phase 2: Replace QVector with std::vector in TrackContainer * Phase 2: Adapt QVector changes in EffectRackView * Phase 2: Adapt QVector changes in AutomationClipView * Phase 2: Adapt QVector changes in ClipView * Phase 2: Adapt QVector changes in AutomationEditor * Phase 2: Adapt QVector changes in PianoRoll * Phase 2: Adapt QVector changes in TrackContainerView * Phase 2: Adapt QVector changes in TrackContentWidget * Phase 2: Adapt QVector changes in InstrumentTrack * Phase 2: Adapt QVector changes in MidiClip * Phase 2: Adapt QVector changes in SampleTrack * Fix segmentation fault in ConfigManager::value * Fix unintended faulty std::vector insert in AutomationClip::resolveAllIDs * Resolve trailing whitespace in src/core/StepRecorder.cpp Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> * Use std::next and std::prev in EffectChain::moveUp/moveDown * Introduce static "combineAllTracks" function in AutomationClip * Adjust variable name in Song::automatedValuesAt * Adjust removal of long step notes in StepRecorder::removeNotesReleasedForTooLong * Iterate over m_chords by const reference in src/core/InstrumentFunctions.cpp Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> * Fix StepRecorder::removeNotesReleasedForTooLong again * Combine the ConfigManager::value overloads using std::optional * Revise StepRecorder::removeNotesReleasedForTooLong * Remove redundant std::optional in ConfigManager::value * Remove trailing whitespace in ConfigManager::value * Fix: Prevent incorrect use of std::distance when element not found * Chore: Remove trailing whitespace in edited files * Only set the id attribute if the controller was found Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> * Remove extra indents from 84b8fe8a559855ed263b74cc582eab3655250c5f * Fix compilation issues * Add LMMS_ prefix for header guard in Track.h * Undo changes made to MixerView::deleteUnusedChannels * Simplify code to handle failure of finding tracks Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> * Split ternary operator into separate if statement Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> * Undo changes to indentation in MixerRoute * Do general clean-up Some of the changes made: + Use auto where benefical + Fix bug in AutomatableModel::globalAutomationValueAt (for loop should be looping over clips variable, not clipsInRange) + Undo out of focus whitespace changes * Always assign to m_steps regardless if clip is found or not Even when the clip is not found (i.e., currentClip is -1), m_steps still gets assigned to. * Insert at the end of tracks vector in src/core/Mixer.cpp Co-authored-by: Dominic Clark <mrdomclark@gmail.com> * Insert at the end of tracks vector in src/core/Mixer.cpp (2) Co-authored-by: Dominic Clark <mrdomclark@gmail.com> * Remove redundant template parameter * Use std::array for zoomLevels --------- Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
156 lines
3.2 KiB
C++
156 lines
3.2 KiB
C++
/*
|
|
* This file is part of LMMS - https://lmms.io
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public
|
|
* License along with this program (see COPYING); if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef LMMS_STEP_RECORDER_H
|
|
#define LMMS_STEP_RECORDER_H
|
|
|
|
#include <QColor>
|
|
#include <QElapsedTimer>
|
|
#include <QTimer>
|
|
#include <QObject>
|
|
|
|
#include "Note.h"
|
|
|
|
class QKeyEvent;
|
|
class QMouseEvent;
|
|
|
|
namespace lmms
|
|
{
|
|
|
|
class MidiClip;
|
|
|
|
namespace gui
|
|
{
|
|
class PianoRoll;
|
|
class StepRecorderWidget;
|
|
} // namespace gui
|
|
|
|
class StepRecorder : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
StepRecorder(gui::PianoRoll& pianoRoll, gui::StepRecorderWidget& stepRecorderWidget);
|
|
|
|
void initialize();
|
|
void start(const TimePos& currentPosition,const TimePos& stepLength);
|
|
void stop();
|
|
void notePressed(const Note & n);
|
|
void noteReleased(const Note & n);
|
|
bool keyPressEvent(QKeyEvent* ke);
|
|
bool mousePressEvent(QMouseEvent* ke);
|
|
void setCurrentMidiClip(MidiClip* newMidiClip);
|
|
void setStepsLength(const TimePos& newLength);
|
|
|
|
std::vector<Note*> getCurStepNotes();
|
|
|
|
bool isRecording() const
|
|
{
|
|
return m_isRecording;
|
|
}
|
|
|
|
QColor curStepNoteColor() const
|
|
{
|
|
return QColor(245,3,139); // radiant pink
|
|
}
|
|
|
|
private slots:
|
|
void removeNotesReleasedForTooLong();
|
|
|
|
private:
|
|
void stepForwards();
|
|
void stepBackwards();
|
|
|
|
void applyStep();
|
|
void dismissStep();
|
|
void prepareNewStep();
|
|
|
|
TimePos getCurStepEndPos();
|
|
|
|
void updateCurStepNotes();
|
|
void updateWidget();
|
|
|
|
bool allCurStepNotesReleased();
|
|
|
|
gui::PianoRoll& m_pianoRoll;
|
|
gui::StepRecorderWidget& m_stepRecorderWidget;
|
|
|
|
bool m_isRecording = false;
|
|
TimePos m_curStepStartPos = 0;
|
|
TimePos m_curStepEndPos = 0;
|
|
|
|
TimePos m_stepsLength;
|
|
TimePos m_curStepLength; // current step length refers to the step currently recorded. it may defer from m_stepsLength
|
|
// since the user can make current step larger
|
|
|
|
QTimer m_updateReleasedTimer;
|
|
|
|
MidiClip* m_midiClip;
|
|
|
|
class StepNote
|
|
{
|
|
public:
|
|
StepNote(const Note & note) : m_note(note), m_pressed(true) {};
|
|
|
|
void setPressed()
|
|
{
|
|
m_pressed = true;
|
|
}
|
|
|
|
void setReleased()
|
|
{
|
|
m_pressed = false;
|
|
releasedTimer.start();
|
|
}
|
|
|
|
int timeSinceReleased()
|
|
{
|
|
return releasedTimer.elapsed();
|
|
}
|
|
|
|
bool isPressed() const
|
|
{
|
|
return m_pressed;
|
|
}
|
|
|
|
bool isReleased() const
|
|
{
|
|
return !m_pressed;
|
|
}
|
|
|
|
Note m_note;
|
|
|
|
private:
|
|
bool m_pressed;
|
|
QElapsedTimer releasedTimer;
|
|
} ;
|
|
|
|
std::vector<StepNote*> m_curStepNotes; // contains the current recorded step notes (i.e. while user still press the notes; before they are applied to the clip)
|
|
|
|
StepNote* findCurStepNote(const int key);
|
|
|
|
bool m_isStepInProgress = false;
|
|
};
|
|
|
|
|
|
} // namespace lmms
|
|
|
|
#endif // LMMS_STEP_RECORDER_H
|