comparison BeatRootProcessor.h @ 22:6afcb5edd7ab

Fix compiler warnings, etc
author Chris Cannam
date Wed, 28 Aug 2013 16:50:40 +0100
parents 887c629502a9
children 633ec097fa56
comparison
equal deleted inserted replaced
21:d98bc465a116 22:6afcb5edd7ab
115 EventList beatTrack(); 115 EventList beatTrack();
116 116
117 protected: 117 protected:
118 /** Allocates memory for arrays, based on parameter settings */ 118 /** Allocates memory for arrays, based on parameter settings */
119 void init() { 119 void init() {
120 #ifdef DEBUG_BEATROOT
121 std::cerr << "BeatRootProcessor::init()" << std::endl;
122 #endif
120 makeFreqMap(fftSize, sampleRate); 123 makeFreqMap(fftSize, sampleRate);
121 prevFrame.clear(); 124 prevFrame.clear();
122 for (int i = 0; i <= fftSize/2; i++) prevFrame.push_back(0); 125 for (int i = 0; i <= fftSize/2; i++) prevFrame.push_back(0);
123 spectralFlux.clear(); 126 spectralFlux.clear();
127 onsets.clear();
128 onsetList.clear();
124 } // init() 129 } // init()
125 130
126 /** Creates a map of FFT frequency bins to comparison bins. 131 /** Creates a map of FFT frequency bins to comparison bins.
127 * Where the spacing of FFT bins is less than 0.5 semitones, the mapping is 132 * Where the spacing of FFT bins is less than 0.5 semitones, the mapping is
128 * one to one. Where the spacing is greater than 0.5 semitones, the FFT 133 * one to one. Where the spacing is greater than 0.5 semitones, the FFT
135 double binWidth = sampleRate / fftSize; 140 double binWidth = sampleRate / fftSize;
136 int crossoverBin = (int)(2 / (pow(2, 1/12.0) - 1)); 141 int crossoverBin = (int)(2 / (pow(2, 1/12.0) - 1));
137 int crossoverMidi = (int)lrint(log(crossoverBin*binWidth/440)/ 142 int crossoverMidi = (int)lrint(log(crossoverBin*binWidth/440)/
138 log(2) * 12 + 69); 143 log(2) * 12 + 69);
139 int i = 0; 144 int i = 0;
140 while (i <= crossoverBin && i <= fftSize/2) 145 while (i <= crossoverBin && i <= fftSize/2) {
141 freqMap[i++] = i; 146 freqMap[i] = i;
147 ++i;
148 }
142 while (i <= fftSize/2) { 149 while (i <= fftSize/2) {
143 double midi = log(i*binWidth/440) / log(2) * 12 + 69; 150 double midi = log(i*binWidth/440) / log(2) * 12 + 69;
144 if (midi > 127) 151 if (midi > 127)
145 midi = 127; 152 midi = 127;
146 freqMap[i++] = crossoverBin + (int)lrint(midi) - crossoverMidi; 153 freqMap[i] = crossoverBin + (int)lrint(midi) - crossoverMidi;
154 ++i;
147 } 155 }
148 freqMapSize = freqMap[i-1] + 1; 156 freqMapSize = freqMap[i-1] + 1;
149 } // makeFreqMap() 157 } // makeFreqMap()
150 158
151 }; // class AudioProcessor 159 }; // class AudioProcessor