# HG changeset patch # User Chris Cannam # Date 1400079502 -3600 # Node ID 26217edee3599559f122c33b8a5f1bbec2791de6 # Parent a45b51ea00a2eaf09966aa8efe10c7d8c17be43c Adjust frequency extents so as to place semitones in the middle of their spaces (if >1 bin per semitone) diff -r a45b51ea00a2 -r 26217edee359 vamp/CQChromaVamp.cpp --- a/vamp/CQChromaVamp.cpp Wed May 14 14:59:45 2014 +0100 +++ b/vamp/CQChromaVamp.cpp Wed May 14 15:58:22 2014 +0100 @@ -43,8 +43,8 @@ using std::cerr; using std::endl; -static const int defaultLowestOctave = 1; -static const int defaultOctaveCount = 8; +static const int defaultLowestOctave = 0; +static const int defaultOctaveCount = 7; static const int defaultBPO = 36; static const float defaultTuningFrequency = 440.f; @@ -208,15 +208,23 @@ m_blockSize = blockSize; int highestOctave = m_lowestOctave + m_octaveCount - 1; - int highestMIDIPitch = (1 + highestOctave) * 12 + 11; - m_maxFrequency = Pitch::getFrequencyForPitch - (highestMIDIPitch, 0, m_tuningFrequency); - m_minFrequency = m_maxFrequency / pow(2, m_octaveCount + 1) * - pow(2, 1.0 / m_bpo); + int midiPitchLimit = (1 + highestOctave) * 12 + 12; // C just beyond top + double midiPitchLimitFreq = + Pitch::getFrequencyForPitch(midiPitchLimit, 0, m_tuningFrequency); + + // Max frequency is frequency of the MIDI pitch just beyond the + // top octave range (midiPitchLimit) minus one bin, then minus + // floor(bins per semitone / 2) + int bps = m_bpo / 12; + m_maxFrequency = midiPitchLimitFreq / pow(2, (1.0 + floor(bps/2)) / m_bpo); + + // Min frequency is frequency of midiPitchLimit lowered by the + // appropriate number of octaves. + m_minFrequency = midiPitchLimitFreq / pow(2, m_octaveCount + 1); cerr << "lowest octave: " << m_lowestOctave << ", highest octave: " - << highestOctave << ", highest midi pitch: " << highestMIDIPitch + << highestOctave << ", limit midi pitch: " << midiPitchLimit << ", min freq " << m_minFrequency << ", max freq " << m_maxFrequency << endl;