aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2006-12-21 11:31:51 +0000
committerJamie Bullock <jamie@postlude.co.uk>2006-12-21 11:31:51 +0000
commit0971d72ace9b0d4c956817bf88f97e15461af112 (patch)
tree184b385a0919bbe6e4dbb7a40c264fabccfdf04c /src
parent55e12c391bbfb4c6bd7054e78b807dfc97cd3ed5 (diff)
downloadLibXtract-0971d72ace9b0d4c956817bf88f97e15461af112.tar.gz
LibXtract-0971d72ace9b0d4c956817bf88f97e15461af112.tar.bz2
LibXtract-0971d72ace9b0d4c956817bf88f97e15461af112.zip
xtract_magnitude_spectrum() and xtract_peaks() share format of N/2 frequency values and N/2 magnitude coefficients. 'Fixed' xtract_loudness() so that N=1 can be used for specific loudness.
Diffstat (limited to 'src')
-rw-r--r--src/scalar.c9
-rw-r--r--src/vector.c8
2 files changed, 10 insertions, 7 deletions
diff --git a/src/scalar.c b/src/scalar.c
index 612fa3c..49c4408 100644
--- a/src/scalar.c
+++ b/src/scalar.c
@@ -291,14 +291,17 @@ int xtract_rolloff(const float *data, const int N, const void *argv, float *resu
int xtract_loudness(const float *data, const int N, const void *argv, float *result){
- int n = BARK_BANDS;
+ int n = N, rv;
- /*if(n != N) return BAD_VECTOR_SIZE; */
+ if(n > BARK_BANDS)
+ rv = BAD_VECTOR_SIZE;
+ else
+ rv = SUCCESS;
while(n--)
*result += pow(data[n], 0.23);
- return SUCCESS;
+ return rv;
}
int xtract_flatness(const float *data, const int N, const void *argv, float *result){
diff --git a/src/vector.c b/src/vector.c
index 739004e..bc7140b 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -51,12 +51,12 @@ int xtract_magnitude_spectrum(const float *data, const int N, const void *argv,
fftwf_execute(plan);
for(n = 1; n < M; n++){
- result[n] = sqrt(SQ(temp[n]) + SQ(temp[N - n])) / N;
- result[M + n] = n * q;
+ result[M + n] = sqrt(SQ(temp[n]) + SQ(temp[N - n])) / N;
+ result[n] = n * q;
}
- result[0] = fabs(temp[0]) / N;
- result[M] = q * .5;
+ result[M] = fabs(temp[0]) / N;
+ result[0] = q * .5;
fftwf_destroy_plan(plan);
fftwf_free(temp);