comparison src/scalar.c @ 41:afb9e6fee244

Changes to xtract_inharmonicity - made parameters consistent with other xtractors that use peak spectrum. Fixed memory alloc bug in pd example.
author Jamie Bullock <jamie@postlude.co.uk>
date Mon, 11 Dec 2006 17:57:27 +0000
parents 0ea4d6430cfc
children 84e69b155098
comparison
equal deleted inserted replaced
40:678667039077 41:afb9e6fee244
314 return SUCCESS; 314 return SUCCESS;
315 } 315 }
316 316
317 int xtract_inharmonicity(float *data, int N, void *argv, float *result){ 317 int xtract_inharmonicity(float *data, int N, void *argv, float *result){
318 318
319 int n = N; 319 int n = N >> 1;
320 float num = 0.f, den = 0.f, 320 float num = 0.f, den = 0.f,
321 *fund, *freq; 321 fund, *freqs, *amps;
322 322
323 fund = *(float **)argv; 323 fund = *(float *)argv;
324 freq = fund+1; 324 freqs = data;
325 amps = data + n;
325 326
326 while(n--){ 327 while(n--){
327 num += abs(freq[n] - n * *fund) * SQ(data[n]); 328 num += abs(freqs[n] - n * fund) * SQ(amps[n]);
328 den += SQ(data[n]); 329 den += SQ(amps[n]);
329 } 330 }
330 331
331 *result = (2 * num) / (*fund * den); 332 *result = (2 * num) / (fund * den);
332 333
333 return SUCCESS; 334 return SUCCESS;
334 } 335 }
335 336
336 337