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

Method BPMDetect

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

Source from the content-addressed store, hash-verified

108
109
110BPMDetect::BPMDetect(int numChannels, int aSampleRate)
111{
112 this->sampleRate = aSampleRate;
113 this->channels = numChannels;
114
115 decimateSum = 0;
116 decimateCount = 0;
117
118 envelopeAccu = 0;
119
120 // Initialize RMS volume accumulator to RMS level of 1500 (out of 32768) that's
121 // safe initial RMS signal level value for song data. This value is then adapted
122 // to the actual level during processing.
123#ifdef SOUNDTOUCH_INTEGER_SAMPLES
124 // integer samples
125 RMSVolumeAccu = (1500 * 1500) / avgnorm;
126#else
127 // float samples, scaled to range [-1..+1[
128 RMSVolumeAccu = (0.045f * 0.045f) / avgnorm;
129#endif
130
131 // choose decimation factor so that result is approx. 1000 Hz
132 decimateBy = sampleRate / 1000;
133 assert(decimateBy > 0);
134 assert(INPUT_BLOCK_SAMPLES < decimateBy * DECIMATED_BLOCK_SAMPLES);
135
136 // Calculate window length & starting item according to desired min & max bpms
137 windowLen = (60 * sampleRate) / (decimateBy * MIN_BPM);
138 windowStart = (60 * sampleRate) / (decimateBy * MAX_BPM);
139
140 assert(windowLen > windowStart);
141
142 // allocate new working objects
143 xcorr = new float[windowLen];
144 memset(xcorr, 0, windowLen * sizeof(float));
145
146 // allocate processing buffer
147 buffer = new FIFOSampleBuffer();
148 // we do processing in mono mode
149 buffer->setChannels(1);
150 buffer->clear();
151}
152
153
154

Callers

nothing calls this directly

Calls 2

setChannelsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected