comparison widgets/UnitConverter.cpp @ 887:139aad8bb445

Wire up note/octave stuff
author Chris Cannam
date Tue, 02 Dec 2014 17:53:17 +0000
parents 01cceacee3da
children cb3a3e20634d
comparison
equal deleted inserted replaced
886:01cceacee3da 887:139aad8bb445
124 124
125 void 125 void
126 UnitConverter::noteChanged(int note) 126 UnitConverter::noteChanged(int note)
127 { 127 {
128 cerr << "noteChanged: " << note << endl; 128 cerr << "noteChanged: " << note << endl;
129 int pitch = Pitch::getPitchForNoteAndOctave(m_note->currentIndex(),
130 m_octave->value());
131 m_hz->setValue(Pitch::getFrequencyForPitch(pitch, m_cents->value()));
129 } 132 }
130 133
131 void 134 void
132 UnitConverter::octaveChanged(int oct) 135 UnitConverter::octaveChanged(int oct)
133 { 136 {
151 void 154 void
152 UnitConverter::updateAllFromHz() 155 UnitConverter::updateAllFromHz()
153 { 156 {
154 float cents = 0; 157 float cents = 0;
155 int pitch = Pitch::getPitchForFrequency(m_hz->value(), &cents); 158 int pitch = Pitch::getPitchForFrequency(m_hz->value(), &cents);
159 int note, octave;
160 Pitch::getNoteAndOctaveForPitch(pitch, note, octave);
156 161
157 m_midi->blockSignals(true); 162 m_midi->blockSignals(true);
158 m_cents->blockSignals(true); 163 m_cents->blockSignals(true);
164 m_note->blockSignals(true);
165 m_octave->blockSignals(true);
159 166
160 m_midi->setValue(pitch); 167 m_midi->setValue(pitch);
161 m_cents->setValue(cents); 168 m_cents->setValue(cents);
162 169 m_note->setCurrentIndex(note);
170 m_octave->setValue(octave);
171
163 m_midi->blockSignals(false); 172 m_midi->blockSignals(false);
164 m_cents->blockSignals(false); 173 m_cents->blockSignals(false);
174 m_note->blockSignals(false);
175 m_octave->blockSignals(false);
165 } 176 }
166 177
167 178
168 179
169 180