comparison modules-and-plug-ins/vamp-plugin/BTrackVamp.cpp @ 28:7af87d3f2ce2 develop

Added a function to allow updates to the hop and frame size of the beat tracker
author Adam <adamstark.uk@gmail.com>
date Tue, 28 Jan 2014 00:31:17 +0000
parents deb49a2590f3
children
comparison
equal deleted inserted replaced
27:98f7a54faa0c 28:7af87d3f2ce2
196 196
197 197
198 m_stepSize = stepSize; 198 m_stepSize = stepSize;
199 m_blockSize = blockSize; 199 m_blockSize = blockSize;
200 200
201 // Real initialisation work goes here! 201 b.updateHopAndFrameSize(m_stepSize,m_blockSize);
202
202 203
203 return true; 204 return true;
204 } 205 }
205 206
206 void 207 void
210 } 211 }
211 212
212 BTrackVamp::FeatureSet 213 BTrackVamp::FeatureSet
213 BTrackVamp::process(const float *const *inputBuffers, Vamp::RealTime timestamp) 214 BTrackVamp::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
214 { 215 {
216 // create an array to hold our audio frame
215 double frame[m_blockSize]; 217 double frame[m_blockSize];
216 218
219 // copy samples into our frame
217 for (int i = 0;i < m_blockSize;i++) 220 for (int i = 0;i < m_blockSize;i++)
218 { 221 {
219 frame[i] = (double) inputBuffers[0][i]; 222 frame[i] = (double) inputBuffers[0][i];
220 } 223 }
221 224
225 // process the frame in the beat tracker
222 b.processAudioFrame(frame); 226 b.processAudioFrame(frame);
223 227
228 // create a FeatureSet
224 FeatureSet featureSet; 229 FeatureSet featureSet;
225 230
231 // if there is a beat in this frame
226 if (b.beatDueInCurrentFrame()) 232 if (b.beatDueInCurrentFrame())
227 { 233 {
234 // add a beat to the FeatureSet
228 Feature beat; 235 Feature beat;
229 beat.hasTimestamp = true; 236 beat.hasTimestamp = true;
230 beat.timestamp = timestamp - Vamp::RealTime::frame2RealTime(m_stepSize, int(m_inputSampleRate + 0.5)); 237 beat.timestamp = timestamp - Vamp::RealTime::frame2RealTime(m_stepSize, int(m_inputSampleRate + 0.5));
231 featureSet[0].push_back(beat); 238 featureSet[0].push_back(beat);
232 } 239 }
233 240
234 // Do actual work! 241 // return the feature set
235 return featureSet; 242 return featureSet;
236 } 243 }
237 244
238 BTrackVamp::FeatureSet 245 BTrackVamp::FeatureSet
239 BTrackVamp::getRemainingFeatures() 246 BTrackVamp::getRemainingFeatures()