MCPcopy Create free account
hub / github.com/audacity/audacity / inputSamples

Method inputSamples

lib-src/soundtouch/source/SoundTouch/BPMDetect.cpp:289–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287
288
289void BPMDetect::inputSamples(const SAMPLETYPE *samples, int numSamples)
290{
291 SAMPLETYPE decimated[DECIMATED_BLOCK_SAMPLES];
292
293 // iterate so that max INPUT_BLOCK_SAMPLES processed per iteration
294 while (numSamples > 0)
295 {
296 int block;
297 int decSamples;
298
299 block = (numSamples > INPUT_BLOCK_SAMPLES) ? INPUT_BLOCK_SAMPLES : numSamples;
300
301 // decimate. note that converts to mono at the same time
302 decSamples = decimate(decimated, samples, block);
303 samples += block * channels;
304 numSamples -= block;
305
306 // envelope new samples and add them to buffer
307 calcEnvelope(decimated, decSamples);
308 buffer->putSamples(decimated, decSamples);
309 }
310
311 // when the buffer has enought samples for processing...
312 if ((int)buffer->numSamples() > windowLen)
313 {
314 int processLength;
315
316 // how many samples are processed
317 processLength = (int)buffer->numSamples() - windowLen;
318
319 // ... calculate autocorrelations for oldest samples...
320 updateXCorr(processLength);
321 // ... and remove them from the buffer
322 buffer->receiveSamples(processLength);
323 }
324}
325
326
327

Callers 1

detectBPMFunction · 0.80

Calls 3

putSamplesMethod · 0.45
numSamplesMethod · 0.45
receiveSamplesMethod · 0.45

Tested by

no test coverage detected