shithub: aubio

Download patch

ref: feb694b1e033d7ebae4249e6c9e998dc1f92b941
parent: ce3ff2bd7f533f9b7d3f511bd842160347fc8d99
author: Paul Brossier <piem@piem.org>
date: Thu Apr 21 15:36:56 EDT 2016

src/spectral/: add const qualifiers

--- a/src/spectral/fft.c
+++ b/src/spectral/fft.c
@@ -230,17 +230,17 @@
   AUBIO_FREE(s);
 }
 
-void aubio_fft_do(aubio_fft_t * s, fvec_t * input, cvec_t * spectrum) {
+void aubio_fft_do(aubio_fft_t * s, const fvec_t * input, cvec_t * spectrum) {
   aubio_fft_do_complex(s, input, s->compspec);
   aubio_fft_get_spectrum(s->compspec, spectrum);
 }
 
-void aubio_fft_rdo(aubio_fft_t * s, cvec_t * spectrum, fvec_t * output) {
+void aubio_fft_rdo(aubio_fft_t * s, const cvec_t * spectrum, fvec_t * output) {
   aubio_fft_get_realimag(spectrum, s->compspec);
   aubio_fft_rdo_complex(s, s->compspec, output);
 }
 
-void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) {
+void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compspec) {
   uint_t i;
 #ifndef HAVE_MEMCPY_HACKS
   for (i=0; i < s->winsize; i++) {
@@ -291,7 +291,7 @@
 #endif /* HAVE_FFTW3 */
 }
 
-void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) {
+void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * output) {
   uint_t i;
 #ifdef HAVE_FFTW3
   const smpl_t renorm = 1./(smpl_t)s->winsize;
@@ -346,17 +346,17 @@
 #endif /* HAVE_FFTW3 */
 }
 
-void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum) {
+void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum) {
   aubio_fft_get_phas(compspec, spectrum);
   aubio_fft_get_norm(compspec, spectrum);
 }
 
-void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec) {
+void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec) {
   aubio_fft_get_imag(spectrum, compspec);
   aubio_fft_get_real(spectrum, compspec);
 }
 
-void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) {
+void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum) {
   uint_t i;
   if (compspec->data[0] < 0) {
     spectrum->phas[0] = PI;
@@ -374,7 +374,7 @@
   }
 }
 
-void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum) {
+void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum) {
   uint_t i = 0;
   spectrum->norm[0] = ABS(compspec->data[0]);
   for (i=1; i < spectrum->length - 1; i++) {
@@ -385,7 +385,7 @@
     ABS(compspec->data[compspec->length/2]);
 }
 
-void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec) {
+void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec) {
   uint_t i;
   for (i = 1; i < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; i++) {
     compspec->data[compspec->length - i] =
@@ -393,7 +393,7 @@
   }
 }
 
-void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec) {
+void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec) {
   uint_t i;
   for (i = 0; i < compspec->length / 2 + 1; i++) {
     compspec->data[i] =
--- a/src/spectral/fft.h
+++ b/src/spectral/fft.h
@@ -65,7 +65,7 @@
   \param spectrum output spectrum
 
 */
-void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum);
+void aubio_fft_do (aubio_fft_t *s, const fvec_t * input, cvec_t * spectrum);
 /** compute backward (inverse) FFT
 
   \param s fft object as returned by new_aubio_fft
@@ -73,7 +73,7 @@
   \param output output signal
 
 */
-void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output);
+void aubio_fft_rdo (aubio_fft_t *s, const cvec_t * spectrum, fvec_t * output);
 
 /** compute forward FFT
 
@@ -82,7 +82,7 @@
   \param compspec complex output fft real/imag
 
 */
-void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec);
+void aubio_fft_do_complex (aubio_fft_t *s, const fvec_t * input, fvec_t * compspec);
 /** compute backward (inverse) FFT from real/imag
 
   \param s fft object as returned by new_aubio_fft
@@ -90,7 +90,7 @@
   \param output real output array
 
 */
-void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output);
+void aubio_fft_rdo_complex (aubio_fft_t *s, const fvec_t * compspec, fvec_t * output);
 
 /** convert real/imag spectrum to norm/phas spectrum
 
@@ -98,7 +98,7 @@
   \param spectrum cvec norm/phas output array
 
 */
-void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum);
+void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum);
 /** convert real/imag spectrum to norm/phas spectrum
 
   \param compspec real/imag input fft array
@@ -105,7 +105,7 @@
   \param spectrum cvec norm/phas output array
 
 */
-void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec);
+void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec);
 
 /** compute phas spectrum from real/imag parts
 
@@ -113,7 +113,7 @@
   \param spectrum cvec norm/phas output array
 
 */
-void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum);
+void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum);
 /** compute imaginary part from the norm/phas cvec
 
   \param spectrum norm/phas input array
@@ -120,7 +120,7 @@
   \param compspec real/imag output fft array
 
 */
-void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec);
+void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec);
 
 /** compute norm component from real/imag parts
 
@@ -128,7 +128,7 @@
   \param spectrum cvec norm/phas output array
 
 */
-void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum);
+void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum);
 /** compute real part from norm/phas components
 
   \param spectrum norm/phas input array
@@ -135,7 +135,7 @@
   \param compspec real/imag output fft array
 
 */
-void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec);
+void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec);
 
 #ifdef __cplusplus
 }
--- a/src/spectral/filterbank.c
+++ b/src/spectral/filterbank.c
@@ -56,7 +56,7 @@
 }
 
 void
-aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out)
+aubio_filterbank_do (aubio_filterbank_t * f, const cvec_t * in, fvec_t * out)
 {
   /* apply filter to all input channel, provided out has enough channels */
   //uint_t max_filters = MIN (f->n_filters, out->length);
@@ -73,13 +73,13 @@
 }
 
 fmat_t *
-aubio_filterbank_get_coeffs (aubio_filterbank_t * f)
+aubio_filterbank_get_coeffs (const aubio_filterbank_t * f)
 {
   return f->filters;
 }
 
 uint_t
-aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filter_coeffs)
+aubio_filterbank_set_coeffs (aubio_filterbank_t * f, const fmat_t * filter_coeffs)
 {
   fmat_copy(filter_coeffs, f->filters);
   return 0;
--- a/src/spectral/filterbank.h
+++ b/src/spectral/filterbank.h
@@ -66,7 +66,7 @@
   \param out output vector containing the energy found in each band, `nfilt` output values
 
 */
-void aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out);
+void aubio_filterbank_do (aubio_filterbank_t * f, const cvec_t * in, fvec_t * out);
 
 /** return a pointer to the matrix object containing all filter coefficients
 
@@ -73,7 +73,7 @@
   \param f filterbank object, as returned by new_aubio_filterbank()
 
  */
-fmat_t *aubio_filterbank_get_coeffs (aubio_filterbank_t * f);
+fmat_t *aubio_filterbank_get_coeffs (const aubio_filterbank_t * f);
 
 /** copy filter coefficients to the filterbank
 
@@ -81,7 +81,7 @@
   \param filters filter bank coefficients to copy from
 
  */
-uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filters);
+uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, const fmat_t * filters);
 
 #ifdef __cplusplus
 }
--- a/src/spectral/filterbank_mel.c
+++ b/src/spectral/filterbank_mel.c
@@ -29,7 +29,7 @@
 
 uint_t
 aubio_filterbank_set_triangle_bands (aubio_filterbank_t * fb,
-    fvec_t * freqs, smpl_t samplerate)
+    const fvec_t * freqs, smpl_t samplerate)
 {
 
   fmat_t *filters = aubio_filterbank_get_coeffs (fb);
--- a/src/spectral/filterbank_mel.h
+++ b/src/spectral/filterbank_mel.h
@@ -50,7 +50,7 @@
 
 */
 uint_t aubio_filterbank_set_triangle_bands (aubio_filterbank_t * fb,
-    fvec_t * freqs, smpl_t samplerate);
+    const fvec_t * freqs, smpl_t samplerate);
 
 /** filterbank initialization for Mel filters using Slaney's coefficients
 
--- a/src/spectral/mfcc.c
+++ b/src/spectral/mfcc.c
@@ -100,7 +100,7 @@
 
 
 void
-aubio_mfcc_do (aubio_mfcc_t * mf, cvec_t * in, fvec_t * out)
+aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out)
 {
   /* compute filterbank */
   aubio_filterbank_do (mf->fb, in, mf->in_dct);
--- a/src/spectral/mfcc.h
+++ b/src/spectral/mfcc.h
@@ -70,7 +70,7 @@
   \param out output mel coefficients buffer (n_coeffs long)
 
 */
-void aubio_mfcc_do (aubio_mfcc_t * mf, cvec_t * in, fvec_t * out);
+void aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out);
 
 #ifdef __cplusplus
 }
--- a/src/spectral/phasevoc.c
+++ b/src/spectral/phasevoc.c
@@ -44,12 +44,12 @@
 
 
 /** returns data and dataold slided by hop_s */
-static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, fvec_t *new);
+static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, const fvec_t *new);
 
 /** do additive synthesis from 'old' and 'cur' */
 static void aubio_pvoc_addsynth(aubio_pvoc_t *pv, fvec_t * synthnew);
 
-void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) {
+void aubio_pvoc_do(aubio_pvoc_t *pv, const fvec_t * datanew, cvec_t *fftgrain) {
   /* slide  */
   aubio_pvoc_swapbuffers(pv, datanew);
   /* windowing */
@@ -136,7 +136,7 @@
   AUBIO_FREE(pv);
 }
 
-static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, fvec_t *new)
+static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, const fvec_t *new)
 {
   /* some convenience pointers */
   smpl_t * data = pv->data->data;
--- a/src/spectral/phasevoc.h
+++ b/src/spectral/phasevoc.h
@@ -67,7 +67,7 @@
   \param fftgrain output spectral frame
 
 */
-void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t *in, cvec_t * fftgrain);
+void aubio_pvoc_do(aubio_pvoc_t *pv, const fvec_t *in, cvec_t * fftgrain);
 /** compute signal from spectral frame
 
   This function takes an input spectral frame fftgrain of size
--- a/src/spectral/specdesc.c
+++ b/src/spectral/specdesc.c
@@ -26,28 +26,28 @@
 #include "mathutils.h"
 #include "utils/hist.h"
 
-void aubio_specdesc_energy(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_specdesc_hfc(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_specdesc_complex(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_specdesc_phase(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_specdesc_specdiff(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_specdesc_kl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_specdesc_mkl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_specdesc_specflux(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_energy(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_hfc(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_complex(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_phase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_specdiff(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_kl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_mkl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_specflux(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
 
-extern void aubio_specdesc_centroid (aubio_specdesc_t * o, cvec_t * spec,
+extern void aubio_specdesc_centroid (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-extern void aubio_specdesc_spread (aubio_specdesc_t * o, cvec_t * spec,
+extern void aubio_specdesc_spread (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-extern void aubio_specdesc_skewness (aubio_specdesc_t * o, cvec_t * spec,
+extern void aubio_specdesc_skewness (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-extern void aubio_specdesc_kurtosis (aubio_specdesc_t * o, cvec_t * spec,
+extern void aubio_specdesc_kurtosis (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-extern void aubio_specdesc_slope (aubio_specdesc_t * o, cvec_t * spec,
+extern void aubio_specdesc_slope (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-extern void aubio_specdesc_decrease (aubio_specdesc_t * o, cvec_t * spec,
+extern void aubio_specdesc_decrease (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-extern void aubio_specdesc_rolloff (aubio_specdesc_t * o, cvec_t * spec,
+extern void aubio_specdesc_rolloff (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
 
 /** onsetdetection types */
@@ -75,7 +75,7 @@
   aubio_specdesc_type onset_type; /**< onset detection type */
   /** Pointer to aubio_specdesc_<type> function */
   void (*funcpointer)(aubio_specdesc_t *o,
-      cvec_t * fftgrain, fvec_t * onset);
+      const cvec_t * fftgrain, fvec_t * onset);
   smpl_t threshold;      /**< minimum norm threshold for phase and specdiff */
   fvec_t *oldmag;        /**< previous norm vector */
   fvec_t *dev1 ;         /**< current onset detection measure vector */
@@ -87,7 +87,7 @@
 
 /* Energy based onset detection function */
 void aubio_specdesc_energy  (aubio_specdesc_t *o UNUSED,
-    cvec_t * fftgrain, fvec_t * onset) {
+    const cvec_t * fftgrain, fvec_t * onset) {
   uint_t j;
   onset->data[0] = 0.;
   for (j=0;j<fftgrain->length;j++) {
@@ -97,7 +97,7 @@
 
 /* High Frequency Content onset detection function */
 void aubio_specdesc_hfc(aubio_specdesc_t *o UNUSED,
-    cvec_t * fftgrain, fvec_t * onset){
+    const cvec_t * fftgrain, fvec_t * onset){
   uint_t j;
   onset->data[0] = 0.;
   for (j=0;j<fftgrain->length;j++) {
@@ -107,7 +107,7 @@
 
 
 /* Complex Domain Method onset detection function */
-void aubio_specdesc_complex (aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset) {
+void aubio_specdesc_complex (aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset) {
   uint_t j;
   uint_t nbins = fftgrain->length;
   onset->data[0] = 0.;
@@ -131,7 +131,7 @@
 
 /* Phase Based Method onset detection function */
 void aubio_specdesc_phase(aubio_specdesc_t *o, 
-    cvec_t * fftgrain, fvec_t * onset){
+    const cvec_t * fftgrain, fvec_t * onset){
   uint_t j;
   uint_t nbins = fftgrain->length;
   onset->data[0] = 0.0;
@@ -161,7 +161,7 @@
 
 /* Spectral difference method onset detection function */
 void aubio_specdesc_specdiff(aubio_specdesc_t *o,
-    cvec_t * fftgrain, fvec_t * onset){
+    const cvec_t * fftgrain, fvec_t * onset){
   uint_t j;
   uint_t nbins = fftgrain->length;
     onset->data[0] = 0.0;
@@ -188,7 +188,7 @@
 /* Kullback Liebler onset detection function
  * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 
  * negative (1.+) and infinite values (+1.e-10) */
-void aubio_specdesc_kl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){
+void aubio_specdesc_kl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset){
   uint_t j;
     onset->data[0] = 0.;
     for (j=0;j<fftgrain->length;j++) {
@@ -202,7 +202,7 @@
 /* Modified Kullback Liebler onset detection function
  * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 
  * negative (1.+) and infinite values (+1.e-10) */
-void aubio_specdesc_mkl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){
+void aubio_specdesc_mkl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset){
   uint_t j;
     onset->data[0] = 0.;
     for (j=0;j<fftgrain->length;j++) {
@@ -213,7 +213,7 @@
 }
 
 /* Spectral flux */
-void aubio_specdesc_specflux(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){ 
+void aubio_specdesc_specflux(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset){ 
   uint_t j;
   onset->data[0] = 0.;
   for (j=0;j<fftgrain->length;j++) {
@@ -225,7 +225,7 @@
 
 /* Generic function pointing to the choosen one */
 void 
-aubio_specdesc_do (aubio_specdesc_t *o, cvec_t * fftgrain, 
+aubio_specdesc_do (aubio_specdesc_t *o, const cvec_t * fftgrain, 
     fvec_t * onset) {
   o->funcpointer(o,fftgrain,onset);
 }
@@ -234,7 +234,7 @@
  * depending on the choosen type, allocate memory as needed
  */
 aubio_specdesc_t * 
-new_aubio_specdesc (char_t * onset_mode, uint_t size){
+new_aubio_specdesc (const char_t * onset_mode, uint_t size){
   aubio_specdesc_t * o = AUBIO_NEW(aubio_specdesc_t);
   uint_t rsize = size/2+1;
   aubio_specdesc_type onset_type;
--- a/src/spectral/specdesc.h
+++ b/src/spectral/specdesc.h
@@ -164,7 +164,7 @@
   \param desc output vector (one sample long, to send to the peak picking)
 
 */
-void aubio_specdesc_do (aubio_specdesc_t * o, cvec_t * fftgrain,
+void aubio_specdesc_do (aubio_specdesc_t * o, const cvec_t * fftgrain,
     fvec_t * desc);
 
 /** creation of a spectral description object
@@ -178,7 +178,7 @@
     - `centroid`, `spread`, `skewness`, `kurtosis`, `slope`, `decrease`, `rolloff`
 
 */
-aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size);
+aubio_specdesc_t *new_aubio_specdesc (const char_t * method, uint_t buf_size);
 
 /** deletion of a spectral descriptor
 
--- a/src/spectral/statistics.c
+++ b/src/spectral/statistics.c
@@ -22,29 +22,29 @@
 #include "cvec.h"
 #include "spectral/specdesc.h"
 
-void aubio_specdesc_centroid (aubio_specdesc_t * o, cvec_t * spec,
+void aubio_specdesc_centroid (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-void aubio_specdesc_spread (aubio_specdesc_t * o, cvec_t * spec,
+void aubio_specdesc_spread (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-void aubio_specdesc_skewness (aubio_specdesc_t * o, cvec_t * spec,
+void aubio_specdesc_skewness (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-void aubio_specdesc_kurtosis (aubio_specdesc_t * o, cvec_t * spec,
+void aubio_specdesc_kurtosis (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-void aubio_specdesc_slope (aubio_specdesc_t * o, cvec_t * spec,
+void aubio_specdesc_slope (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-void aubio_specdesc_decrease (aubio_specdesc_t * o, cvec_t * spec,
+void aubio_specdesc_decrease (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
-void aubio_specdesc_rolloff (aubio_specdesc_t * o, cvec_t * spec,
+void aubio_specdesc_rolloff (aubio_specdesc_t * o, const cvec_t * spec,
     fvec_t * desc);
 
 
-smpl_t cvec_sum (cvec_t * s);
-smpl_t cvec_mean (cvec_t * s);
-smpl_t cvec_centroid (cvec_t * s);
-smpl_t cvec_moment (cvec_t * s, uint_t moment);
+smpl_t cvec_sum (const cvec_t * s);
+smpl_t cvec_mean (const cvec_t * s);
+smpl_t cvec_centroid (const cvec_t * s);
+smpl_t cvec_moment (const cvec_t * s, uint_t moment);
 
 smpl_t
-cvec_sum (cvec_t * s)
+cvec_sum (const cvec_t * s)
 {
   uint_t j;
   smpl_t tmp = 0.0;
@@ -55,13 +55,13 @@
 }
 
 smpl_t
-cvec_mean (cvec_t * s)
+cvec_mean (const cvec_t * s)
 {
   return cvec_sum (s) / (smpl_t) (s->length);
 }
 
 smpl_t
-cvec_centroid (cvec_t * spec)
+cvec_centroid (const cvec_t * spec)
 {
   smpl_t sum = 0., sc = 0.;
   uint_t j;
@@ -77,7 +77,7 @@
 }
 
 smpl_t
-cvec_moment (cvec_t * spec, uint_t order)
+cvec_moment (const cvec_t * spec, uint_t order)
 {
   smpl_t sum = 0., centroid = 0., sc = 0.;
   uint_t j;
@@ -94,7 +94,7 @@
 }
 
 void
-aubio_specdesc_centroid (aubio_specdesc_t * o UNUSED, cvec_t * spec,
+aubio_specdesc_centroid (aubio_specdesc_t * o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
   desc->data[0] = cvec_centroid (spec); 
@@ -101,7 +101,7 @@
 }
 
 void
-aubio_specdesc_spread (aubio_specdesc_t * o UNUSED, cvec_t * spec,
+aubio_specdesc_spread (aubio_specdesc_t * o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
   desc->data[0] = cvec_moment (spec, 2);
@@ -108,7 +108,7 @@
 }
 
 void
-aubio_specdesc_skewness (aubio_specdesc_t * o UNUSED, cvec_t * spec,
+aubio_specdesc_skewness (aubio_specdesc_t * o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
   smpl_t spread;
@@ -122,7 +122,7 @@
 }
 
 void
-aubio_specdesc_kurtosis (aubio_specdesc_t * o UNUSED, cvec_t * spec,
+aubio_specdesc_kurtosis (aubio_specdesc_t * o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
   smpl_t spread;
@@ -136,7 +136,7 @@
 }
 
 void
-aubio_specdesc_slope (aubio_specdesc_t * o UNUSED, cvec_t * spec,
+aubio_specdesc_slope (aubio_specdesc_t * o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
   uint_t j;
@@ -164,7 +164,7 @@
 }
 
 void
-aubio_specdesc_decrease (aubio_specdesc_t *o UNUSED, cvec_t * spec,
+aubio_specdesc_decrease (aubio_specdesc_t *o UNUSED, const cvec_t * spec,
     fvec_t * desc)
 {
   uint_t j; smpl_t sum;
@@ -182,7 +182,7 @@
 }
 
 void
-aubio_specdesc_rolloff (aubio_specdesc_t *o UNUSED, cvec_t * spec,
+aubio_specdesc_rolloff (aubio_specdesc_t *o UNUSED, const cvec_t * spec,
     fvec_t *desc)
 {
   uint_t j; smpl_t cumsum, rollsum;
--- a/src/spectral/tss.c
+++ b/src/spectral/tss.c
@@ -40,7 +40,7 @@
   fvec_t *dev;
 };
 
-void aubio_tss_do(aubio_tss_t *o, cvec_t * input, 
+void aubio_tss_do(aubio_tss_t *o, const cvec_t * input,
     cvec_t * trans, cvec_t * stead)
 {
   uint_t j;
--- a/src/spectral/tss.h
+++ b/src/spectral/tss.h
@@ -69,7 +69,7 @@
   \param stead output steady state components
 
 */
-void aubio_tss_do (aubio_tss_t * o, cvec_t * input, cvec_t * trans,
+void aubio_tss_do (aubio_tss_t * o, const cvec_t * input, cvec_t * trans,
     cvec_t * stead);
 
 /** set transient / steady state separation threshold