ref: fc6c831353a0be625d6ea77b38399b9ace2cf9d0
parent: e2da2952a2cdfc964247ee454440bf0678e9fac2
author: Paul Brossier <piem@piem.org>
date: Sat Nov 24 17:47:15 EST 2007
moved spectral_centroid to new file
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,7 @@
spectral/phasevoc.h \
spectral/fft.h \
spectral/tss.h \
+ spectral/spectral_centroid.h \
pitch/pitchdetection.h \
pitch/pitchmcomb.h \
pitch/pitchyin.h \
@@ -57,6 +58,8 @@
spectral/fft.h \
spectral/tss.c \
spectral/tss.h \
+ spectral/spectral_centroid.c \
+ spectral/spectral_centroid.h \
pitch/pitchdetection.c \
pitch/pitchdetection.h \
pitch/pitchmcomb.c \
--- a/src/aubio.h
+++ b/src/aubio.h
@@ -59,8 +59,6 @@
/* in this order */
#include "types.h"
#include "sample.h"
-#include "spectral/fft.h"
-#include "spectral/phasevoc.h"
#include "mathutils.h"
#include "utils/scale.h"
#include "utils/hist.h"
@@ -68,6 +66,11 @@
#include "temporal/resample.h"
#include "temporal/biquad.h"
#include "temporal/filter.h"
+#include "spectral/filterbank.h"
+#include "spectral/mfcc.h"
+#include "spectral/fft.h"
+#include "spectral/phasevoc.h"
+#include "spectral/spectral_centroid.h"
#include "pitch/pitchdetection.h"
#include "pitch/pitchmcomb.h"
#include "pitch/pitchyin.h"
@@ -79,8 +82,6 @@
#include "onset/peakpick.h"
#include "tempo/beattracking.h"
#include "tempo/tempo.h"
-#include "spectral/filterbank.h"
-#include "spectral/mfcc.h"
#ifdef __cplusplus
} /* extern "C" */
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -432,19 +432,6 @@
return zcr/(smpl_t)input->length;
}
-smpl_t aubio_spectral_centroid(cvec_t * spectrum, smpl_t samplerate) {
- uint_t i=0, j;
- smpl_t sum = 0., sc = 0.;
- for ( j = 0; j < spectrum->length; j++ ) {
- sum += spectrum->norm[i][j];
- }
- if (sum == 0.) return 0.;
- for ( j = 0; j < spectrum->length; j++ ) {
- sc += (smpl_t)j * spectrum->norm[i][j];
- }
- return sc / sum * samplerate / (smpl_t)(spectrum->length);
-}
-
void aubio_autocorr(fvec_t * input, fvec_t * output) {
uint_t i = 0, j = 0, length = input->length;
smpl_t * data = input->data[0];
--- a/src/mathutils.h
+++ b/src/mathutils.h
@@ -208,10 +208,6 @@
*/
smpl_t aubio_zero_crossing_rate(fvec_t * input);
/**
- * spectrum centroid computed on a cvec
- */
-smpl_t aubio_spectral_centroid(cvec_t * input, smpl_t samplerate);
-/**
* clean up cached memory at the end of program
*
* use this function at the end of programs to purge all
--- /dev/null
+++ b/src/spectral/spectral_centroid.c
@@ -1,0 +1,37 @@
+/*
+ Copyright (C) 2007 Paul Brossier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "aubio_priv.h"
+#include "cvec.h"
+#include "spectral/spectral_centroid.h"
+
+smpl_t aubio_spectral_centroid(cvec_t * spectrum, smpl_t samplerate) {
+ uint_t i=0, j;
+ smpl_t sum = 0., sc = 0.;
+ for ( j = 0; j < spectrum->length; j++ ) {
+ sum += spectrum->norm[i][j];
+ }
+ if (sum == 0.) return 0.;
+ for ( j = 0; j < spectrum->length; j++ ) {
+ sc += (smpl_t)j * spectrum->norm[i][j];
+ }
+ return sc / sum * samplerate / (smpl_t)(spectrum->length);
+}
+
+
--- /dev/null
+++ b/src/spectral/spectral_centroid.h
@@ -1,0 +1,27 @@
+/*
+ Copyright (C) 2007 Paul Brossier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @file
+ * compute spectrum centroid of a cvec object
+ */
+
+/**
+ * spectrum centroid computed on a cvec
+ */
+smpl_t aubio_spectral_centroid(cvec_t * input, smpl_t samplerate);