diff src/MainWindow.cpp @ 227:ae0bf8dc5833

Crude ability to adjust displayed frequency range
author Chris Cannam
date Tue, 11 Mar 2014 09:26:04 +0000
parents 9bdff8d10a86
children 135e0f1fd1ee
line wrap: on
line diff
--- a/src/MainWindow.cpp	Mon Mar 10 14:59:50 2014 +0000
+++ b/src/MainWindow.cpp	Tue Mar 11 09:26:04 2014 +0000
@@ -55,6 +55,8 @@
 #include "data/fileio/MIDIFileWriter.h"
 #include "rdf/RDFExporter.h"
 
+#include "widgets/RangeInputDialog.h"
+
 // For version information
 #include "vamp/vamp.h"
 #include "vamp-sdk/PluginBase.h"
@@ -668,6 +670,13 @@
     connect(this, SIGNAL(canZoom(bool)), action, SLOT(setEnabled(bool)));
     m_keyReference->registerShortcut(action);
     menu->addAction(action);
+
+    menu->addSeparator();
+    
+    action = new QAction(tr("Set Displayed Fre&quency Range..."), this);
+    action->setStatusTip(tr("Set the minimum and maximum frequencies in the visible display"));
+    connect(action, SIGNAL(triggered()), this, SLOT(editDisplayExtents()));
+    menu->addAction(action);
 }
 
 void
@@ -1183,6 +1192,35 @@
 }
 
 void
+MainWindow::editDisplayExtents()
+{
+    float min, max;
+    float vmin = 0;
+    float vmax = getMainModel()->getSampleRate() /2;
+    
+    if (!m_analyser->getDisplayFrequencyExtents(min, max)) {
+        //!!!
+        return;
+    }
+
+    RangeInputDialog dialog(tr("Set frequency range"),
+                            tr("Enter new frequency range, from %1 to %2 Hz.\nThese values will be rounded to the nearest spectrogram bin.")
+                            .arg(vmin).arg(vmax),
+                            "Hz", vmin, vmax, this);
+    dialog.setRange(min, max);
+
+    if (dialog.exec() == QDialog::Accepted) {
+        dialog.getRange(min, max);
+        if (min > max) {
+            float tmp = max;
+            max = min;
+            min = tmp;
+        }
+        m_analyser->setDisplayFrequencyExtents(min, max);
+    }
+}
+
+void
 MainWindow::updateDescriptionLabel()
 {
     // Nothing, we don't have one