MCPcopy Create free account
hub / github.com/audeering/opensmile / dataProcessorCustomFinalise

Method dataProcessorCustomFinalise

src/dsp/specScale.cpp:248–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248int cSpecScale::dataProcessorCustomFinalise()
249{
250 int i;
251 int ret = cVectorProcessor::dataProcessorCustomFinalise();
252 if (!ret) return ret;
253
254 // check maxF < sampleFreq.
255 double samplF = deltaF * (double)(nMag - 1); // sampling frequency
256 if ((maxF <= minF)||(maxF > samplF)) {
257 maxF = samplF;
258 }
259
260 // transform from source to target scale:
261
262 fmin_t = smileDsp_specScaleTransfFwd(minF,scale,param);
263 fmax_t = smileDsp_specScaleTransfFwd(maxF,scale,param);
264
265 // target delta f
266 deltaF_t = (fmax_t - fmin_t) / (nPointsTarget - 1);
267
268 // calculate the target frequencies of the linear scale fft input points
269 if (f_t == NULL) f_t = (double*)malloc(sizeof(double)*nMag);
270
271 if (scale == SPECTSCALE_LOG) {
272 for (i=1; i < nMag; i++) {
273 f_t[i] = smileDsp_specScaleTransfFwd( (double)i * (double)deltaF , scale, param );
274 }
275 f_t[0] = 2.0 * f_t[1] - f_t[2]; // heuristic for the 0th frequency (only valid for log2 ??)
276 } else { // generic transform:
277 for (i=0; i < nMag; i++) {
278 f_t[i] = smileDsp_specScaleTransfFwd( (double)i * (double)deltaF , scale, param );
279 }
280 }
281
282 splineCache = std::unique_ptr<sSmileMath_splineCache>(new sSmileMath_splineCache());
283 smileMath_cspline_init(f_t, nMag, splineCache.get());
284
285 double *x = (double*)malloc(sizeof(double)*nPointsTarget);
286 for (i=0; i < nPointsTarget; i++) {
287 x[i] = fmin_t + (double)i * deltaF_t;
288 }
289 splintCache = std::unique_ptr<sSmileMath_splintCache>(new sSmileMath_splintCache());
290 if (!smileMath_csplint_init(f_t, nMag, x, nPointsTarget, splintCache.get())) {
291 SMILE_IERR(1,"smileMath_csplint_init failed. Output of this component will be invalid!");
292 splintCache = NULL;
293 }
294 free(x);
295
296 double nOctaves = log(maxF / minF)/log(2.0);
297 double nPointsPerOctave = nPointsTarget / nOctaves; // this is valid for log(2.0) scale only...
298 if (auditoryWeighting) {
299 /* auditory weighting function (octave scale only...)*/
300 double atan_s = nPointsPerOctave * smileMath_log2(65.0 / 50.0) - 1.0;
301 audw = (double*)malloc(sizeof(double)*nPointsTarget);
302 for (i=0; i < nPointsTarget; i++) {
303 audw[i] = 0.5 + atan (3.0 * (i + 1 - atan_s) / nPointsPerOctave) / M_PI;
304 }
305 }

Callers

nothing calls this directly

Calls 6

smileMath_cspline_initFunction · 0.85
smileMath_csplint_initFunction · 0.85
smileMath_log2Function · 0.85
getMethod · 0.45
getLevelMetaDataPtrMethod · 0.45

Tested by

no test coverage detected