-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Step Recording feature #4544
Merged
Merged
Step Recording feature #4544
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
594dcf0
Step Recording inital commit
Mister-Lemon e72994f
Do not add current recorded step-notes to pattern until released (all…
Mister-Lemon a6c4de4
cleanup - removal of debug prints
Mister-Lemon 8db9d3a
1. prevent playing note when added using mouse while step-recording 2…
Mister-Lemon 056d9d7
Auto-scroll to step-recording cursor position
Mister-Lemon 6840bd5
cleanup and formatting fixes according to code review
Mister-Lemon 628835c
fix bug: SLOT function should have been changed from patternRenamed t…
Mister-Lemon 6c31067
Two bug fixes (recorded notes position and length were wrong on speci…
Mister-Lemon d035e43
Remove trailing whitespace
zonkmachine aebf056
PlayPos 0 when toggling step record on while playing
zonkmachine c6426f7
Use std::numeric_limits<int>::max()
zonkmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* 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 STEP_RECORDER_H | ||
#define STEP_RECORDER_H | ||
|
||
#include <QTime> | ||
#include <QTimer> | ||
#include <QObject> | ||
#include <QKeyEvent> | ||
|
||
#include "Note.h" | ||
#include "lmms_basics.h" | ||
#include "Pattern.h" | ||
|
||
class PianoRoll; | ||
class StepRecorderWidget; | ||
|
||
class StepRecorder : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
StepRecorder(PianoRoll& pianoRoll, StepRecorderWidget& stepRecorderWidget); | ||
|
||
void initialize(); | ||
void start(const MidiTime& currentPosition,const MidiTime& stepLength); | ||
void stop(); | ||
void notePressed(const Note & n); | ||
void noteReleased(const Note & n); | ||
bool keyPressEvent(QKeyEvent* ke); | ||
bool mousePressEvent(QMouseEvent* ke); | ||
void setCurrentPattern(Pattern* newPattern); | ||
void setStepsLength(const MidiTime& newLength); | ||
|
||
QVector<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(); | ||
|
||
MidiTime getCurStepEndPos(); | ||
|
||
void updateCurStepNotes(); | ||
void updateWidget(); | ||
|
||
bool allCurStepNotesReleased(); | ||
|
||
PianoRoll& m_pianoRoll; | ||
StepRecorderWidget& m_stepRecorderWidget; | ||
|
||
bool m_isRecording = false; | ||
MidiTime m_curStepStartPos = 0; | ||
MidiTime m_curStepEndPos = 0; | ||
|
||
MidiTime m_stepsLength; | ||
MidiTime 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; | ||
|
||
Pattern* m_pattern; | ||
|
||
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; | ||
QTime releasedTimer; | ||
} ; | ||
|
||
QVector<StepNote*> m_curStepNotes; // contains the current recorded step notes (i.e. while user still press the notes; before they are applied to the pattern) | ||
|
||
StepNote* findCurStepNote(const int key); | ||
|
||
bool m_isStepInProgress = false; | ||
}; | ||
|
||
#endif //STEP_RECORDER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* StepRecorderWidget.h - widget that provide gui markers for step recording | ||
* | ||
* 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 STEP_RECOREDER_WIDGET_H | ||
#define STEP_RECOREDER_WIDGET_H | ||
|
||
#include "lmms_basics.h" | ||
#include "Note.h" | ||
|
||
#include <QWidget> | ||
#include <QColor> | ||
#include <QPainter> | ||
|
||
class StepRecorderWidget : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
StepRecorderWidget( | ||
QWidget * parent, | ||
const int ppt, | ||
const int marginTop, | ||
const int marginBottom, | ||
const int marginLeft, | ||
const int marginRight); | ||
|
||
//API used by PianoRoll | ||
void setPixelsPerTact(int ppt); | ||
void setCurrentPosition(MidiTime currentPosition); | ||
void setBottomMargin(const int marginBottom); | ||
|
||
//API used by StepRecorder | ||
void setStepsLength(MidiTime stepsLength); | ||
void setStartPosition(MidiTime pos); | ||
void setEndPosition(MidiTime pos); | ||
|
||
void showHint(); | ||
|
||
private: | ||
virtual void paintEvent(QPaintEvent * pe); | ||
|
||
int xCoordOfTick(int tick); | ||
|
||
void drawVerLine(QPainter* painter, int x, const QColor& color, int top, int bottom); | ||
void drawVerLine(QPainter* painter, const MidiTime& pos, const QColor& color, int top, int bottom); | ||
|
||
void updateBoundaries(); | ||
|
||
MidiTime m_stepsLength; | ||
MidiTime m_curStepStartPos; | ||
MidiTime m_curStepEndPos; | ||
|
||
int m_ppt; // pixels per tact | ||
MidiTime m_currentPosition; // current position showed by on PianoRoll | ||
|
||
QColor m_colorLineStart; | ||
QColor m_colorLineEnd; | ||
|
||
// boundaries within piano roll window | ||
int m_top; | ||
int m_bottom; | ||
int m_left; | ||
int m_right; | ||
|
||
const int m_marginTop; | ||
int m_marginBottom; // not const since can change on resize of edit-note area | ||
const int m_marginLeft; | ||
const int m_marginRight; | ||
|
||
signals: | ||
void positionChanged(const MidiTime & t); | ||
} ; | ||
|
||
#endif //STEP_RECOREDER_WIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move this to stylesheets later.