From e4ec6cf645cde04c282c138eaf1ed5856d5db3b3 Mon Sep 17 00:00:00 2001 From: Sean Enderby Date: Mon, 24 Feb 2014 13:00:25 +0000 Subject: correction to xtract_spectral_inharmonicicty --- src/scalar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/scalar.c') diff --git a/src/scalar.c b/src/scalar.c index 2e93934..47d3a8f 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -623,7 +623,7 @@ int xtract_rms_amplitude(const double *data, const int N, const void *argv, doub int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result) { - int n = N >> 1; + int n = N >> 1, h = 0; double num = 0.0, den = 0.0, fund; const double *freqs, *amps; @@ -635,7 +635,8 @@ int xtract_spectral_inharmonicity(const double *data, const int N, const void *a { if(amps[n]) { - num += fabs(freqs[n] - n * fund) * XTRACT_SQ(amps[n]); + h = round(freqs[n] / fund); + num += fabs(freqs[n] - h * fund) * XTRACT_SQ(amps[n]); den += XTRACT_SQ(amps[n]); } } -- cgit v1.2.3 From 2b976e4bce32413fc3e76dc81a48178f4d871270 Mon Sep 17 00:00:00 2001 From: Sean Enderby Date: Mon, 24 Feb 2014 14:32:04 +0000 Subject: correction to xtract_odd_even_ratio --- src/scalar.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/scalar.c') diff --git a/src/scalar.c b/src/scalar.c index 47d3a8f..3a9abdf 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -622,7 +622,6 @@ int xtract_rms_amplitude(const double *data, const int N, const void *argv, doub int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result) { - int n = N >> 1, h = 0; double num = 0.0, den = 0.0, fund; const double *freqs, *amps; @@ -656,16 +655,19 @@ int xtract_power(const double *data, const int N, const void *argv, double *resu int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result) { + int n = N >> 1, h = 0; + double odd = 0.0, even = 0.0, fund, temp; + const double *freqs; - int M = (N >> 1), n; - - double odd = 0.0, even = 0.0, temp; + fund = *(double *)argv; + freqs = data + n; - for(n = 0; n < M; n++) + while(n--) { if((temp = data[n])) { - if(XTRACT_IS_ODD(n)) + h = round(freqs[n] / fund); + if(XTRACT_IS_ODD(h)) { odd += temp; } -- cgit v1.2.3 From 08de2740a76f38d50adaa326c8c6c2f0988316b9 Mon Sep 17 00:00:00 2001 From: Sean Enderby Date: Tue, 25 Feb 2014 13:19:04 +0000 Subject: tristimulus1 correction --- src/scalar.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 113 insertions(+), 9 deletions(-) (limited to 'src/scalar.c') diff --git a/src/scalar.c b/src/scalar.c index 3a9abdf..84c3900 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -298,22 +298,126 @@ int xtract_irregularity_j(const double *data, const int N, const void *argv, dou return XTRACT_SUCCESS; } +/* + *int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result) + *{ + * + * int n = N; + * + * double den, p1, temp; + * + * den = p1 = temp = 0.0; + * + * for(n = 0; n < N; n++) + * { + * if((temp = data[n])) + * { + * den += temp; + * if(!p1) + * p1 = temp; + * } + * } + * + * if(den == 0.0 || p1 == 0.0) + * { + * *result = 0.0; + * return XTRACT_NO_RESULT; + * } + * else + * { + * *result = p1 / den; + * return XTRACT_SUCCESS; + * } + *} + * + *int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result) + *{ + * + * int n = N; + * + * double den, p2, p3, p4, ps, temp; + * + * den = p2 = p3 = p4 = ps = temp = 0.0; + * + * for(n = 0; n < N; n++) + * { + * if((temp = data[n])) + * { + * den += temp; + * if(!p2) + * p2 = temp; + * else if(!p3) + * p3 = temp; + * else if(!p4) + * p4 = temp; + * } + * } + * + * ps = p2 + p3 + p4; + * + * if(den == 0.0 || ps == 0.0) + * { + * *result = 0.0; + * return XTRACT_NO_RESULT; + * } + * else + * { + * *result = ps / den; + * return XTRACT_SUCCESS; + * } + * + *} + * + *int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result) + *{ + * + * int n = N, count = 0; + * + * double den, num, temp; + * + * den = num = temp = 0.0; + * + * for(n = 0; n < N; n++) + * { + * if((temp = data[n])) + * { + * den += temp; + * if(count >= 5) + * num += temp; + * count++; + * } + * } + * + * if(den == 0.0 || num == 0.0) + * { + * *result = 0.0; + * return XTRACT_NO_RESULT; + * } + * else + * { + * *result = num / den; + * return XTRACT_SUCCESS; + * } + *} + */ + int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result) { + int n = N >> 1, h = 0, i; + double den = 0.0, p1 = 0.0, fund = 0.0, temp = 0.0; + const double *freqs; - int n = N; - - double den, p1, temp; - - den = p1 = temp = 0.0; + fund = *(double *)argv; + freqs = data + n; - for(n = 0; n < N; n++) + for(i = 0; i < n; i++) { - if((temp = data[n])) + if((temp = data[i])) { den += temp; - if(!p1) - p1 = temp; + h = round(freqs[i] / fund); + if(h == 1) + p1 += temp; } } -- cgit v1.2.3 From 1e53c1ea582a5927f8e6d900b2a06165962b77b5 Mon Sep 17 00:00:00 2001 From: Sean Enderby Date: Tue, 25 Feb 2014 13:53:39 +0000 Subject: tristimulus2 correction --- src/scalar.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src/scalar.c') diff --git a/src/scalar.c b/src/scalar.c index 84c3900..d064840 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -436,23 +436,36 @@ int xtract_tristimulus_1(const double *data, const int N, const void *argv, doub int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result) { - int n = N; - - double den, p2, p3, p4, ps, temp; + int n = N >> 1, h = 0, i; + double den, p2, p3, p4, ps, fund, temp; + den = p2 = p3 = p4 = ps = fund = temp = 0.0; + const double *freqs; - den = p2 = p3 = p4 = ps = temp = 0.0; + fund = *(double *)argv; + freqs = data + n; - for(n = 0; n < N; n++) + for(i = 0; i < n; i++) { - if((temp = data[n])) + if((temp = data[i])) { den += temp; - if(!p2) - p2 = temp; - else if(!p3) - p3 = temp; - else if(!p4) - p4 = temp; + h = round(freqs[i] / fund); + switch (h) + { + case 2: + p2 += temp; + break; + + case 3: + p3 += temp; + break; + + case 4: + p4 += temp; + + default: + break; + } } } -- cgit v1.2.3 From 8fad3a92195af9f58d008ec82c267c7a992456cc Mon Sep 17 00:00:00 2001 From: Sean Enderby Date: Tue, 25 Feb 2014 14:12:29 +0000 Subject: tristimulus3 correction --- src/scalar.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/scalar.c') diff --git a/src/scalar.c b/src/scalar.c index d064840..ba662f2 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -486,21 +486,21 @@ int xtract_tristimulus_2(const double *data, const int N, const void *argv, doub int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result) { + int n = N >> 1, h = 0, i; + double den = 0.0, num = 0.0, fund = 0.0, temp = 0.0; + const double *freqs; - int n = N, count = 0; - - double den, num, temp; - - den = num = temp = 0.0; + fund = *(double *)argv; + freqs = data + n; - for(n = 0; n < N; n++) + for(i = 0; i < n; i++) { - if((temp = data[n])) + if((temp = data[i])) { den += temp; - if(count >= 5) + h = round(freqs[i] / fund); + if(h >= 5) num += temp; - count++; } } -- cgit v1.2.3 From 71ae0bc782330606c03cd01f31aa22211ff8c857 Mon Sep 17 00:00:00 2001 From: Sean Enderby Date: Tue, 25 Feb 2014 14:27:25 +0000 Subject: updated docs and removed commented out code --- src/scalar.c | 103 ----------------------------------------------------------- 1 file changed, 103 deletions(-) (limited to 'src/scalar.c') diff --git a/src/scalar.c b/src/scalar.c index ba662f2..becf341 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -298,109 +298,6 @@ int xtract_irregularity_j(const double *data, const int N, const void *argv, dou return XTRACT_SUCCESS; } -/* - *int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result) - *{ - * - * int n = N; - * - * double den, p1, temp; - * - * den = p1 = temp = 0.0; - * - * for(n = 0; n < N; n++) - * { - * if((temp = data[n])) - * { - * den += temp; - * if(!p1) - * p1 = temp; - * } - * } - * - * if(den == 0.0 || p1 == 0.0) - * { - * *result = 0.0; - * return XTRACT_NO_RESULT; - * } - * else - * { - * *result = p1 / den; - * return XTRACT_SUCCESS; - * } - *} - * - *int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result) - *{ - * - * int n = N; - * - * double den, p2, p3, p4, ps, temp; - * - * den = p2 = p3 = p4 = ps = temp = 0.0; - * - * for(n = 0; n < N; n++) - * { - * if((temp = data[n])) - * { - * den += temp; - * if(!p2) - * p2 = temp; - * else if(!p3) - * p3 = temp; - * else if(!p4) - * p4 = temp; - * } - * } - * - * ps = p2 + p3 + p4; - * - * if(den == 0.0 || ps == 0.0) - * { - * *result = 0.0; - * return XTRACT_NO_RESULT; - * } - * else - * { - * *result = ps / den; - * return XTRACT_SUCCESS; - * } - * - *} - * - *int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result) - *{ - * - * int n = N, count = 0; - * - * double den, num, temp; - * - * den = num = temp = 0.0; - * - * for(n = 0; n < N; n++) - * { - * if((temp = data[n])) - * { - * den += temp; - * if(count >= 5) - * num += temp; - * count++; - * } - * } - * - * if(den == 0.0 || num == 0.0) - * { - * *result = 0.0; - * return XTRACT_NO_RESULT; - * } - * else - * { - * *result = num / den; - * return XTRACT_SUCCESS; - * } - *} - */ - int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result) { int n = N >> 1, h = 0, i; -- cgit v1.2.3