Skip to content

Commit

Permalink
Add Quantize button to Piano Roll
Browse files Browse the repository at this point in the history
Add Quantize button to Piano Roll
  • Loading branch information
grejppi committed May 5, 2016
1 parent 355f6c2 commit c94d6e8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ protected slots:

void zoomingChanged();
void quantizeChanged();
void quantizeNotes();

void updateSemiToneMarkerMenu();

Expand Down
35 changes: 35 additions & 0 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,36 @@ int PianoRoll::quantization() const
}


void PianoRoll::quantizeNotes()
{
NoteVector notes = getSelectedNotes();

if (notes.empty())
{
for (Note* n : m_pattern->notes())
{
notes.push_back(n);
}
}

for (Note* n : notes)
{
if (n->length() == MidiTime(0))
{
continue;
}

Note copy(*n);
m_pattern->removeNote(n);
copy.quantizePos(quantization());
m_pattern->addNote(copy);
}

update();
gui->songEditor()->update();
}




void PianoRoll::updateSemiToneMarkerMenu()
Expand Down Expand Up @@ -4047,10 +4077,15 @@ PianoRollWindow::PianoRollWindow() :

connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int)));

QAction* quantizeAction = new QAction(embed::getIconPixmap("quantize"), tr("Quantize"), this);
connect(quantizeAction, SIGNAL(triggered()), m_editor, SLOT(quantizeNotes()));

notesActionsToolBar->addAction( drawAction );
notesActionsToolBar->addAction( eraseAction );
notesActionsToolBar->addAction( selectAction );
notesActionsToolBar->addAction( detuneAction );
notesActionsToolBar->addSeparator();
notesActionsToolBar->addAction( quantizeAction );

// Copy + paste actions
DropToolBar *copyPasteActionsToolBar = addDropToolBarToTop(tr("Copy paste controls"));
Expand Down

0 comments on commit c94d6e8

Please sign in to comment.