changeset 238:fce61899aeea

Add Merge Notes
author Chris Cannam
date Thu, 27 Mar 2014 16:30:26 +0000
parents 63092d9871f9
children d40c6cdb30a4
files .hgsubstate src/MainWindow.cpp src/MainWindow.h
diffstat 3 files changed, 44 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Thu Mar 27 15:59:46 2014 +0000
+++ b/.hgsubstate	Thu Mar 27 16:30:26 2014 +0000
@@ -4,4 +4,4 @@
 27d4e7152c954bf3c4387319db088fb3cd02436b sv-dependency-builds
 3144af512ea3447e6cf1775f02b5b54b5a5ddeb5 svapp
 0c8218b2d84a172049d966c82c2064f5aa59c503 svcore
-8d5df70b5ed703ade1b382744dad24e3841157e9 svgui
+bc049f1f080e2042c7967841c2fb717bc4e46e24 svgui
--- a/src/MainWindow.cpp	Thu Mar 27 15:59:46 2014 +0000
+++ b/src/MainWindow.cpp	Thu Mar 27 16:30:26 2014 +0000
@@ -591,15 +591,6 @@
     menu->addSeparator();
     m_rightButtonMenu->addSeparator();
     
-    action = new QAction(tr("Snap Notes to Pitch Track"), this);
-    action->setShortcut(tr("Ctrl+="));
-    action->setStatusTip(tr("Set all notes within the selected region to have the median frequency of their underlying pitches"));
-    m_keyReference->registerShortcut(action);
-    connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches()));
-    connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
-    menu->addAction(action);
-    m_rightButtonMenu->addAction(action);
-    
     action = new QAction(tr("Split Notes at Selection Boundaries"), this);
     action->setShortcut(tr("Ctrl+/"));
     action->setStatusTip(tr("If any notes overlap the start or end of the selected region, split them at those points"));
@@ -608,6 +599,25 @@
     connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
     menu->addAction(action);
     m_rightButtonMenu->addAction(action);
+
+    action = new QAction(tr("Merge Notes"), this);
+    action->setShortcut(tr("Ctrl+."));
+    action->setStatusTip(tr("Merge all notes within the selected region into a single note"));
+    m_keyReference->registerShortcut(action);
+    connect(action, SIGNAL(triggered()), this, SLOT(mergeNotes()));
+    connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
+    menu->addAction(action);
+    m_rightButtonMenu->addAction(action);
+    
+    action = new QAction(tr("Snap Notes to Pitch Track"), this);
+    action->setShortcut(tr("Ctrl+="));
+    action->setStatusTip(tr("Set notes within the selected region to the median frequency of their underlying pitches, or remove them if there are no underlying pitches"));
+    m_keyReference->registerShortcut(action);
+    connect(action, SIGNAL(triggered()), this, SLOT(snapNotesToPitches()));
+    connect(this, SIGNAL(canSnapNotes(bool)), action, SLOT(setEnabled(bool)));
+    menu->addAction(action);
+    m_rightButtonMenu->addAction(action);
+    
 }
 
 void
@@ -2094,6 +2104,29 @@
 }
 
 void
+MainWindow::mergeNotes()
+{
+    FlexiNoteLayer *layer =
+        qobject_cast<FlexiNoteLayer *>(m_analyser->getLayer(Analyser::Notes));
+    if (!layer) return;
+
+    MultiSelection::SelectionList selections = m_viewManager->getSelections();
+
+    if (!selections.empty()) {
+
+        CommandHistory::getInstance()->startCompoundOperation
+            (tr("Merge Notes"), true);
+                
+        for (MultiSelection::SelectionList::iterator k = selections.begin();
+             k != selections.end(); ++k) {
+            layer->mergeNotes(m_analyser->getPane(), *k);
+        }
+        
+        CommandHistory::getInstance()->endCompoundOperation();
+    }
+}
+
+void
 MainWindow::playSpeedChanged(int position)
 {
     PlaySpeedRangeMapper mapper(0, 200);
--- a/src/MainWindow.h	Thu Mar 27 15:59:46 2014 +0000
+++ b/src/MainWindow.h	Thu Mar 27 16:30:26 2014 +0000
@@ -61,6 +61,7 @@
 
     virtual void snapNotesToPitches();
     virtual void splitNotesAtSelection();
+    virtual void mergeNotes();
 
     virtual void showAudioToggled();
     virtual void showSpectToggled();