MCPcopy Create free account
hub / github.com/adamstark/BTrack / calculateOnsetDetectionFunctionSample

Method calculateOnsetDetectionFunctionSample

src/OnsetDetectionFunction.cpp:175–259  ·  view source on GitHub ↗

=======================================================================

Source from the content-addressed store, hash-verified

173
174//=======================================================================
175double OnsetDetectionFunction::calculateOnsetDetectionFunctionSample (double* buffer)
176{
177 double odfSample;
178
179 // shift audio samples back in frame by hop size
180 std::rotate (frame.begin(), frame.begin() + hopSize, frame.end());
181
182 // add new samples to frame from input buffer
183 int j = 0;
184 for (int i = (frameSize - hopSize); i < frameSize; i++)
185 {
186 frame[i] = buffer[j];
187 j++;
188 }
189
190 switch (onsetDetectionFunctionType)
191 {
192 case EnergyEnvelope:
193 {
194 // calculate energy envelope detection function sample
195 odfSample = energyEnvelope();
196 break;
197 }
198 case EnergyDifference:
199 {
200 // calculate half-wave rectified energy difference detection function sample
201 odfSample = energyDifference();
202 break;
203 }
204 case SpectralDifference:
205 {
206 // calculate spectral difference detection function sample
207 odfSample = spectralDifference();
208 break;
209 }
210 case SpectralDifferenceHWR:
211 {
212 // calculate spectral difference detection function sample (half wave rectified)
213 odfSample = spectralDifferenceHWR();
214 break;
215 }
216 case PhaseDeviation:
217 {
218 // calculate phase deviation detection function sample (half wave rectified)
219 odfSample = phaseDeviation();
220 break;
221 }
222 case ComplexSpectralDifference:
223 {
224 // calcualte complex spectral difference detection function sample
225 odfSample = complexSpectralDifference();
226 break;
227 }
228 case ComplexSpectralDifferenceHWR:
229 {
230 // calcualte complex spectral difference detection function sample (half-wave rectified)
231 odfSample = complexSpectralDifferenceHWR();
232 break;

Callers 2

processAudioFrameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected