changeset 887:139aad8bb445

Wire up note/octave stuff
author Chris Cannam
date Tue, 02 Dec 2014 17:53:17 +0000
parents 01cceacee3da
children cb3a3e20634d
files widgets/UnitConverter.cpp
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/UnitConverter.cpp	Tue Dec 02 13:50:49 2014 +0000
+++ b/widgets/UnitConverter.cpp	Tue Dec 02 17:53:17 2014 +0000
@@ -126,6 +126,9 @@
 UnitConverter::noteChanged(int note)
 {
     cerr << "noteChanged: " << note << endl;
+    int pitch = Pitch::getPitchForNoteAndOctave(m_note->currentIndex(),
+						m_octave->value());
+    m_hz->setValue(Pitch::getFrequencyForPitch(pitch, m_cents->value()));
 }
 
 void
@@ -153,15 +156,23 @@
 {
     float cents = 0;
     int pitch = Pitch::getPitchForFrequency(m_hz->value(), &cents);
+    int note, octave;
+    Pitch::getNoteAndOctaveForPitch(pitch, note, octave);
 
     m_midi->blockSignals(true);
     m_cents->blockSignals(true);
+    m_note->blockSignals(true);
+    m_octave->blockSignals(true);
     
     m_midi->setValue(pitch);
     m_cents->setValue(cents);
-
+    m_note->setCurrentIndex(note);
+    m_octave->setValue(octave);
+    
     m_midi->blockSignals(false);
     m_cents->blockSignals(false);
+    m_note->blockSignals(false);
+    m_octave->blockSignals(false);
 }