aboutsummaryrefslogtreecommitdiff
path: root/src/scalar.c
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2006-10-08 15:31:40 +0000
committerJamie Bullock <jamie@postlude.co.uk>2006-10-08 15:31:40 +0000
commit9bcdb2f6cb48da938975f618e36ebd54f67766cb (patch)
tree77df7ce218d046107be383e5cca45e979eee362e /src/scalar.c
parent2260b6a200016010fa9704dd3024d2c28b4fee74 (diff)
downloadLibXtract-9bcdb2f6cb48da938975f618e36ebd54f67766cb.tar.gz
LibXtract-9bcdb2f6cb48da938975f618e36ebd54f67766cb.tar.bz2
LibXtract-9bcdb2f6cb48da938975f618e36ebd54f67766cb.zip
Added spectral centroid
Diffstat (limited to 'src/scalar.c')
-rw-r--r--src/scalar.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/scalar.c b/src/scalar.c
index 1cc3128..111c300 100644
--- a/src/scalar.c
+++ b/src/scalar.c
@@ -84,6 +84,25 @@ int xtract_kurtosis(float *data, int N, void *argv, float *result){
}
+
+int xtract_centroid(float *data, int N, void *argv, float *result){
+
+ int n = N;
+
+ float *freqs, *amps, FA, A;
+
+ freqs = data;
+ amps = data + (N >> 1);
+
+ while(n--){
+ FA += freqs[n] * amps[n];
+ A += amps[n];
+ }
+
+ *result = FA / A;
+
+}
+
int xtract_irregularity_k(float *data, int N, void *argv, float *result){
int n,