comparison src/scalar.c @ 124:fc4bc58b92da

- fixed xtract_spread() -- now just calls xtract_spectral_variance()
author Jamie Bullock <jamie@postlude.co.uk>
date Thu, 31 Mar 2011 12:22:29 +0000
parents efb1c1ae2ba8
children 67f6b6e63d45
comparison
equal deleted inserted replaced
123:efb1c1ae2ba8 124:fc4bc58b92da
409 return XTRACT_SUCCESS; 409 return XTRACT_SUCCESS;
410 } 410 }
411 411
412 int xtract_spread(const float *data, const int N, const void *argv, float *result){ 412 int xtract_spread(const float *data, const int N, const void *argv, float *result){
413 413
414 int n = N; 414 return xtract_spectral_variance(data, N, argv, result);
415
416 float num = 0.f, den = 0.f, temp = 0.f;
417
418 if(argv == NULL)
419 return XTRACT_BAD_ARGV;
420
421 while(n--){
422 temp = n - *(float *)argv;
423 num += XTRACT_SQ(temp) * data[n];
424 den += data[n];
425 }
426
427 /* FIX: spectral spread is mathematically equivalent to spectral variance --
428 * here we are computing the spectral standard deviation */
429 *result = sqrtf(num / den);
430
431 return XTRACT_SUCCESS;
432 } 415 }
433 416
434 int xtract_zcr(const float *data, const int N, const void *argv, float *result){ 417 int xtract_zcr(const float *data, const int N, const void *argv, float *result){
435 418
436 int n = N; 419 int n = N;