From: Paul Brossier Date: Thu, 21 Apr 2016 17:32:58 +0000 (+0200) Subject: src/pitch/: add const qualifiers, filter_do_outplace to avoid modifying input X-Git-Tag: 0.4.4~300^2~290 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=ce3ff2bd7f533f9b7d3f511bd842160347fc8d99;p=aubio.git src/pitch/: add const qualifiers, filter_do_outplace to avoid modifying input --- diff --git a/src/pitch/pitch.c b/src/pitch/pitch.c index 778c4874..bee0ea33 100644 --- a/src/pitch/pitch.c +++ b/src/pitch/pitch.c @@ -61,7 +61,7 @@ typedef enum } aubio_pitch_mode; /** callback to get pitch candidate, defined below */ -typedef void (*aubio_pitch_detect_t) (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); +typedef void (*aubio_pitch_detect_t) (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); /** callback to convert pitch from one unit to another, defined below */ typedef smpl_t(*aubio_pitch_convert_t) (smpl_t value, uint_t samplerate, uint_t bufsize); @@ -78,6 +78,7 @@ struct _aubio_pitch_t uint_t bufsize; /**< buffer size */ void *p_object; /**< pointer to pitch object */ aubio_filter_t *filter; /**< filter */ + fvec_t *filtered; /**< filtered input */ aubio_pvoc_t *pv; /**< phase vocoder for mcomb */ cvec_t *fftgrain; /**< spectral frame for mcomb */ fvec_t *buf; /**< temporary buffer for yin */ @@ -88,12 +89,12 @@ struct _aubio_pitch_t }; /* callback functions for pitch detection */ -static void aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); -static void aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); -static void aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); -static void aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); -static void aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); -static void aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); +static void aubio_pitch_do_mcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); +static void aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); +static void aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); +static void aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); +static void aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); +static void aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); /* conversion functions for frequency conversions */ smpl_t freqconvbin (smpl_t f, uint_t samplerate, uint_t bufsize); @@ -101,11 +102,11 @@ smpl_t freqconvmidi (smpl_t f, uint_t samplerate, uint_t bufsize); smpl_t freqconvpass (smpl_t f, uint_t samplerate, uint_t bufsize); /* adapter to stack ibuf new samples at the end of buf, and trim `buf` to `bufsize` */ -void aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf); +void aubio_pitch_slideblock (aubio_pitch_t * p, const fvec_t * ibuf); aubio_pitch_t * -new_aubio_pitch (char_t * pitch_mode, +new_aubio_pitch (const char_t * pitch_mode, uint_t bufsize, uint_t hopsize, uint_t samplerate) { aubio_pitch_t *p = AUBIO_NEW (aubio_pitch_t); @@ -160,6 +161,7 @@ new_aubio_pitch (char_t * pitch_mode, aubio_pitchyin_set_tolerance (p->p_object, 0.15); break; case aubio_pitcht_mcomb: + p->filtered = new_fvec (hopsize); p->pv = new_aubio_pvoc (bufsize, hopsize); p->fftgrain = new_cvec (bufsize); p->p_object = new_aubio_pitchmcomb (bufsize, hopsize); @@ -209,6 +211,7 @@ del_aubio_pitch (aubio_pitch_t * p) del_aubio_pitchyin (p->p_object); break; case aubio_pitcht_mcomb: + del_fvec (p->filtered); del_aubio_pvoc (p->pv); del_cvec (p->fftgrain); del_aubio_filter (p->filter); @@ -237,7 +240,7 @@ del_aubio_pitch (aubio_pitch_t * p) } void -aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf) +aubio_pitch_slideblock (aubio_pitch_t * p, const fvec_t * ibuf) { uint_t overlap_size = p->buf->length - ibuf->length; #if 1 //!HAVE_MEMCPY_HACKS @@ -257,7 +260,7 @@ aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf) } uint_t -aubio_pitch_set_unit (aubio_pitch_t * p, char_t * pitch_unit) +aubio_pitch_set_unit (aubio_pitch_t * p, const char_t * pitch_unit) { uint_t err = AUBIO_OK; aubio_pitch_mode pitch_mode; @@ -342,7 +345,7 @@ aubio_pitch_get_silence (aubio_pitch_t * p) /* do method, calling the detection callback, then the conversion callback */ void -aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +aubio_pitch_do (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) { p->detect_cb (p, ibuf, obuf); if (aubio_silence_detection(ibuf, p->silence) == 1) { @@ -353,16 +356,16 @@ aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) /* do method for each algorithm */ void -aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +aubio_pitch_do_mcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) { - aubio_filter_do (p->filter, ibuf); + aubio_filter_do_outplace (p->filter, ibuf, p->filtered); aubio_pvoc_do (p->pv, ibuf, p->fftgrain); aubio_pitchmcomb_do (p->p_object, p->fftgrain, obuf); obuf->data[0] = aubio_bintofreq (obuf->data[0], p->samplerate, p->bufsize); } void -aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) { smpl_t pitch = 0.; aubio_pitch_slideblock (p, ibuf); @@ -378,7 +381,7 @@ aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) void -aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) { smpl_t pitch = 0.; aubio_pitch_slideblock (p, ibuf); @@ -393,7 +396,7 @@ aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) } void -aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) +aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) { smpl_t pitch = 0., period; aubio_pitch_slideblock (p, ibuf); @@ -409,7 +412,7 @@ aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) } void -aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) +aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) { aubio_pitch_slideblock (p, ibuf); aubio_pitchfcomb_do (p->p_object, p->buf, out); @@ -417,7 +420,7 @@ aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) } void -aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) +aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) { smpl_t period, pitch = 0.; aubio_pitch_slideblock (p, ibuf); diff --git a/src/pitch/pitch.h b/src/pitch/pitch.h index a7780714..18fc13c6 100644 --- a/src/pitch/pitch.h +++ b/src/pitch/pitch.h @@ -107,7 +107,7 @@ typedef struct _aubio_pitch_t aubio_pitch_t; \param out output pitch candidates of size [1] */ -void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, fvec_t * out); +void aubio_pitch_do (aubio_pitch_t * o, const fvec_t * in, fvec_t * out); /** change yin or yinfft tolerance threshold @@ -134,7 +134,7 @@ void del_aubio_pitch (aubio_pitch_t * o); \return newly created ::aubio_pitch_t */ -aubio_pitch_t *new_aubio_pitch (char_t * method, +aubio_pitch_t *new_aubio_pitch (const char_t * method, uint_t buf_size, uint_t hop_size, uint_t samplerate); /** set the output unit of the pitch detection object @@ -145,7 +145,7 @@ aubio_pitch_t *new_aubio_pitch (char_t * method, \return 0 if successfull, non-zero otherwise */ -uint_t aubio_pitch_set_unit (aubio_pitch_t * o, char_t * mode); +uint_t aubio_pitch_set_unit (aubio_pitch_t * o, const char_t * mode); /** set the silence threshold of the pitch detection object diff --git a/src/pitch/pitchfcomb.c b/src/pitch/pitchfcomb.c index 83bc6b11..2bdc5092 100644 --- a/src/pitch/pitchfcomb.c +++ b/src/pitch/pitchfcomb.c @@ -63,7 +63,7 @@ new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize) /* input must be stepsize long */ void -aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, fvec_t * output) +aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, const fvec_t * input, fvec_t * output) { uint_t k, l, maxharm = 0; smpl_t phaseDifference = TWO_PI * (smpl_t) p->stepSize / (smpl_t) p->fftSize; diff --git a/src/pitch/pitchfcomb.h b/src/pitch/pitchfcomb.h index 9203cc12..f8727449 100644 --- a/src/pitch/pitchfcomb.h +++ b/src/pitch/pitchfcomb.h @@ -51,7 +51,7 @@ typedef struct _aubio_pitchfcomb_t aubio_pitchfcomb_t; \param output pitch candidates in bins */ -void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, +void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, const fvec_t * input, fvec_t * output); /** creation of the pitch detection object diff --git a/src/pitch/pitchmcomb.c b/src/pitch/pitchmcomb.c index 66103c7e..f9ec6107 100644 --- a/src/pitch/pitchmcomb.c +++ b/src/pitch/pitchmcomb.c @@ -31,9 +31,9 @@ typedef struct _aubio_spectralcandidate_t aubio_spectralcandidate_t; uint_t aubio_pitchmcomb_get_root_peak (aubio_spectralpeak_t * peaks, uint_t length); uint_t aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, - fvec_t * X); -void aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * oldmag); -void aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag); + const fvec_t * X); +void aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, const fvec_t * oldmag); +void aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, const fvec_t * newmag); /* not used but useful : sort by amplitudes (or anything else) * sort_pitchpeak(peaks, length); */ @@ -42,7 +42,7 @@ static sint_t aubio_pitchmcomb_sort_peak_comp (const void *x, const void *y); /** sort spectral_peak against their mag */ void aubio_pitchmcomb_sort_peak (aubio_spectralpeak_t * peaks, uint_t nbins); /** select the best candidates */ -uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, +uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, smpl_t * cands); /** sort spectral_candidate against their comb ene */ @@ -101,7 +101,7 @@ struct _aubio_spectralcandidate_t void -aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output) +aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, fvec_t * output) { uint_t j; smpl_t instfreq; @@ -134,7 +134,7 @@ aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output) } uint_t -aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands) +aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, smpl_t * cands) { uint_t j; uint_t k; @@ -165,7 +165,7 @@ aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands) } void -aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag) +aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, const fvec_t * newmag) { fvec_t *mag = (fvec_t *) p->scratch; fvec_t *tmp = (fvec_t *) p->scratch2; @@ -197,7 +197,7 @@ aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag) } void -aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag) +aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, const fvec_t * newmag) { aubio_spectralpeak_t *peaks = (aubio_spectralpeak_t *) p->peaks; aubio_spectralcandidate_t **candidate = @@ -285,7 +285,7 @@ aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag) * \bug peak-picking too picky, sometimes counts too many peaks ? */ uint_t -aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, fvec_t * X) +aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, const fvec_t * X) { uint_t j, ispeak, count = 0; for (j = 1; j < X->length - 1; j++) { diff --git a/src/pitch/pitchmcomb.h b/src/pitch/pitchmcomb.h index 15c6c0da..b9fbcbd4 100644 --- a/src/pitch/pitchmcomb.h +++ b/src/pitch/pitchmcomb.h @@ -52,7 +52,7 @@ typedef struct _aubio_pitchmcomb_t aubio_pitchmcomb_t; \param out_cands pitch candidate frequenciess, in bins */ -void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * in_fftgrain, +void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, const cvec_t * in_fftgrain, fvec_t * out_cands); /** creation of the pitch detection object diff --git a/src/pitch/pitchschmitt.c b/src/pitch/pitchschmitt.c index 0c9acbc7..06a34e8e 100644 --- a/src/pitch/pitchschmitt.c +++ b/src/pitch/pitchschmitt.c @@ -47,7 +47,7 @@ new_aubio_pitchschmitt (uint_t size) } void -aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * input, +aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, const fvec_t * input, fvec_t * output) { uint_t j; diff --git a/src/pitch/pitchschmitt.h b/src/pitch/pitchschmitt.h index 6052bad7..f7e7760b 100644 --- a/src/pitch/pitchschmitt.h +++ b/src/pitch/pitchschmitt.h @@ -51,7 +51,7 @@ typedef struct _aubio_pitchschmitt_t aubio_pitchschmitt_t; \param cands_out pitch period estimates, in samples */ -void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * samples_in, +void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, const fvec_t * samples_in, fvec_t * cands_out); /** creation of the pitch detection object diff --git a/src/pitch/pitchspecacf.c b/src/pitch/pitchspecacf.c index cae5eecc..a010041c 100644 --- a/src/pitch/pitchspecacf.c +++ b/src/pitch/pitchspecacf.c @@ -54,7 +54,7 @@ new_aubio_pitchspecacf (uint_t bufsize) } void -aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, fvec_t * input, fvec_t * output) +aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, const fvec_t * input, fvec_t * output) { uint_t l, tau; fvec_t *fftout = p->fftout; @@ -91,7 +91,7 @@ del_aubio_pitchspecacf (aubio_pitchspecacf_t * p) } smpl_t -aubio_pitchspecacf_get_confidence (aubio_pitchspecacf_t * o) { +aubio_pitchspecacf_get_confidence (const aubio_pitchspecacf_t * o) { // no confidence for now return o->confidence; } @@ -104,7 +104,7 @@ aubio_pitchspecacf_set_tolerance (aubio_pitchspecacf_t * p, smpl_t tol) } smpl_t -aubio_pitchspecacf_get_tolerance (aubio_pitchspecacf_t * p) +aubio_pitchspecacf_get_tolerance (const aubio_pitchspecacf_t * p) { return p->tol; } diff --git a/src/pitch/pitchspecacf.h b/src/pitch/pitchspecacf.h index 5d3d1b00..3c539745 100644 --- a/src/pitch/pitchspecacf.h +++ b/src/pitch/pitchspecacf.h @@ -55,7 +55,7 @@ typedef struct _aubio_pitchspecacf_t aubio_pitchspecacf_t; \param cands_out pitch period candidates, in samples */ -void aubio_pitchspecacf_do (aubio_pitchspecacf_t * o, fvec_t * samples_in, fvec_t * cands_out); +void aubio_pitchspecacf_do (aubio_pitchspecacf_t * o, const fvec_t * samples_in, fvec_t * cands_out); /** creation of the pitch detection object \param buf_size size of the input buffer to analyse @@ -76,7 +76,7 @@ void del_aubio_pitchspecacf (aubio_pitchspecacf_t * o); \return tolerance parameter for minima selection [default 1.] */ -smpl_t aubio_pitchspecacf_get_tolerance (aubio_pitchspecacf_t * o); +smpl_t aubio_pitchspecacf_get_tolerance (const aubio_pitchspecacf_t * o); /** set tolerance parameter for `specacf` pitch detection object @@ -94,7 +94,7 @@ uint_t aubio_pitchspecacf_set_tolerance (aubio_pitchspecacf_t * o, smpl_t tol); \return confidence parameter */ -smpl_t aubio_pitchspecacf_get_confidence (aubio_pitchspecacf_t * o); +smpl_t aubio_pitchspecacf_get_confidence (const aubio_pitchspecacf_t * o); #ifdef __cplusplus } diff --git a/src/pitch/pitchyin.c b/src/pitch/pitchyin.c index 6061f911..b65e3f7e 100644 --- a/src/pitch/pitchyin.c +++ b/src/pitch/pitchyin.c @@ -40,26 +40,26 @@ struct _aubio_pitchyin_t }; /** compute difference function - - \param input input signal + + \param input input signal \param yinbuf output buffer to store difference function (half shorter than input) */ void aubio_pitchyin_diff (fvec_t * input, fvec_t * yinbuf); -/** in place computation of the YIN cumulative normalised function - - \param yinbuf input signal (a square difference function), also used to store function +/** in place computation of the YIN cumulative normalised function + + \param yinbuf input signal (a square difference function), also used to store function */ void aubio_pitchyin_getcum (fvec_t * yinbuf); /** detect pitch in a YIN function - + \param yinbuf input buffer as computed by aubio_pitchyin_getcum */ -uint_t aubio_pitchyin_getpitch (fvec_t * yinbuf); +uint_t aubio_pitchyin_getpitch (const fvec_t * yinbuf); aubio_pitchyin_t * new_aubio_pitchyin (uint_t bufsize) @@ -111,7 +111,7 @@ aubio_pitchyin_getcum (fvec_t * yin) } uint_t -aubio_pitchyin_getpitch (fvec_t * yin) +aubio_pitchyin_getpitch (const fvec_t * yin) { uint_t tau = 1; do { @@ -130,7 +130,7 @@ aubio_pitchyin_getpitch (fvec_t * yin) /* all the above in one */ void -aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * input, fvec_t * out) +aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out) { smpl_t tol = o->tol; fvec_t *yin = o->yin; diff --git a/src/pitch/pitchyin.h b/src/pitch/pitchyin.h index 7835673b..acb9afe5 100644 --- a/src/pitch/pitchyin.h +++ b/src/pitch/pitchyin.h @@ -66,7 +66,7 @@ void del_aubio_pitchyin (aubio_pitchyin_t * o); \param cands_out pitch period candidates, in samples */ -void aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * samples_in, fvec_t * cands_out); +void aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * samples_in, fvec_t * cands_out); /** set tolerance parameter for YIN algorithm diff --git a/src/pitch/pitchyinfft.c b/src/pitch/pitchyinfft.c index 9084547b..98de63c7 100644 --- a/src/pitch/pitchyinfft.c +++ b/src/pitch/pitchyinfft.c @@ -98,7 +98,7 @@ new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize) } void -aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output) +aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, const fvec_t * input, fvec_t * output) { uint_t tau, l; uint_t length = p->fftout->length; diff --git a/src/pitch/pitchyinfft.h b/src/pitch/pitchyinfft.h index 8f32ee91..a23927cd 100644 --- a/src/pitch/pitchyinfft.h +++ b/src/pitch/pitchyinfft.h @@ -52,7 +52,7 @@ typedef struct _aubio_pitchyinfft_t aubio_pitchyinfft_t; \param cands_out pitch period candidates, in samples */ -void aubio_pitchyinfft_do (aubio_pitchyinfft_t * o, fvec_t * samples_in, fvec_t * cands_out); +void aubio_pitchyinfft_do (aubio_pitchyinfft_t * o, const fvec_t * samples_in, fvec_t * cands_out); /** creation of the pitch detection object \param samplerate samplerate of the input signal diff --git a/src/synth/sampler.h b/src/synth/sampler.h index b27a8df8..39e974f7 100644 --- a/src/synth/sampler.h +++ b/src/synth/sampler.h @@ -59,7 +59,7 @@ aubio_sampler_t * new_aubio_sampler(uint_t samplerate, uint_t hop_size); \return 0 if successful, non-zero otherwise */ -uint_t aubio_sampler_load( aubio_sampler_t * o, char_t * uri ); +uint_t aubio_sampler_load( aubio_sampler_t * o, const char_t * uri ); /** process sampler function @@ -73,7 +73,7 @@ If `input` is not NULL and different from `output`, then the samples from `input are added to the output. */ -void aubio_sampler_do ( aubio_sampler_t * o, fvec_t * input, fvec_t * output); +void aubio_sampler_do ( aubio_sampler_t * o, const fvec_t * input, fvec_t * output); /** process sampler function, multiple channels @@ -87,7 +87,7 @@ If `input` is not NULL and different from `output`, then the samples from `input are added to the output. */ -void aubio_sampler_do_multi ( aubio_sampler_t * o, fmat_t * input, fmat_t * output); +void aubio_sampler_do_multi ( aubio_sampler_t * o, const fmat_t * input, fmat_t * output); /** get current playing state @@ -96,7 +96,7 @@ void aubio_sampler_do_multi ( aubio_sampler_t * o, fmat_t * input, fmat_t * outp \return 0 if not playing, 1 if playing */ -uint_t aubio_sampler_get_playing ( aubio_sampler_t * o ); +uint_t aubio_sampler_get_playing ( const aubio_sampler_t * o ); /** set current playing state diff --git a/src/synth/wavetable.c b/src/synth/wavetable.c index e4e08953..830ffd75 100644 --- a/src/synth/wavetable.c +++ b/src/synth/wavetable.c @@ -68,7 +68,7 @@ beach: return NULL; } -static smpl_t interp_2(fvec_t *input, smpl_t pos) { +static smpl_t interp_2(const fvec_t *input, smpl_t pos) { uint_t idx = (uint_t)FLOOR(pos); smpl_t frac = pos - (smpl_t)idx; smpl_t a = input->data[idx]; @@ -76,7 +76,7 @@ static smpl_t interp_2(fvec_t *input, smpl_t pos) { return a + frac * ( b - a ); } -void aubio_wavetable_do ( aubio_wavetable_t * s, fvec_t * input, fvec_t * output) +void aubio_wavetable_do ( aubio_wavetable_t * s, const fvec_t * input, fvec_t * output) { uint_t i; if (s->playing) { @@ -107,7 +107,7 @@ void aubio_wavetable_do ( aubio_wavetable_t * s, fvec_t * input, fvec_t * output } } -void aubio_wavetable_do_multi ( aubio_wavetable_t * s, fmat_t * input, fmat_t * output) +void aubio_wavetable_do_multi ( aubio_wavetable_t * s, const fmat_t * input, fmat_t * output) { uint_t i, j; if (s->playing) { @@ -142,7 +142,7 @@ void aubio_wavetable_do_multi ( aubio_wavetable_t * s, fmat_t * input, fmat_t * } } -uint_t aubio_wavetable_get_playing ( aubio_wavetable_t * s ) +uint_t aubio_wavetable_get_playing ( const aubio_wavetable_t * s ) { return s->playing; } @@ -172,7 +172,7 @@ uint_t aubio_wavetable_set_freq ( aubio_wavetable_t * s, smpl_t freq ) return aubio_parameter_set_target_value ( s->freq, freq ); } -smpl_t aubio_wavetable_get_freq ( aubio_wavetable_t * s) { +smpl_t aubio_wavetable_get_freq ( const aubio_wavetable_t * s) { return aubio_parameter_get_current_value ( s->freq); } @@ -181,7 +181,7 @@ uint_t aubio_wavetable_set_amp ( aubio_wavetable_t * s, smpl_t amp ) return aubio_parameter_set_target_value ( s->amp, amp ); } -smpl_t aubio_wavetable_get_amp ( aubio_wavetable_t * s) { +smpl_t aubio_wavetable_get_amp ( const aubio_wavetable_t * s) { return aubio_parameter_get_current_value ( s->amp ); } diff --git a/src/synth/wavetable.h b/src/synth/wavetable.h index a719ad95..0798940a 100644 --- a/src/synth/wavetable.h +++ b/src/synth/wavetable.h @@ -59,7 +59,7 @@ aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size); \return 0 if successful, non-zero otherwise */ -uint_t aubio_wavetable_load( aubio_wavetable_t * o, char_t * uri ); +uint_t aubio_wavetable_load( aubio_wavetable_t * o, const char_t * uri ); /** process wavetable function @@ -73,7 +73,7 @@ If `input` is not NULL and different from `output`, then the samples from `input are added to the output. */ -void aubio_wavetable_do ( aubio_wavetable_t * o, fvec_t * input, fvec_t * output); +void aubio_wavetable_do ( aubio_wavetable_t * o, const fvec_t * input, fvec_t * output); /** process wavetable function, multiple channels @@ -87,7 +87,7 @@ If `input` is not NULL and different from `output`, then the samples from `input are added to the output. */ -void aubio_wavetable_do_multi ( aubio_wavetable_t * o, fmat_t * input, fmat_t * output); +void aubio_wavetable_do_multi ( aubio_wavetable_t * o, const fmat_t * input, fmat_t * output); /** get current playing state @@ -96,7 +96,7 @@ void aubio_wavetable_do_multi ( aubio_wavetable_t * o, fmat_t * input, fmat_t * \return 0 if not playing, 1 if playing */ -uint_t aubio_wavetable_get_playing ( aubio_wavetable_t * o ); +uint_t aubio_wavetable_get_playing ( const aubio_wavetable_t * o ); /** set current playing state @@ -143,7 +143,7 @@ uint_t aubio_wavetable_set_freq ( aubio_wavetable_t * o, smpl_t freq ); \return current frequency, in Hz */ -smpl_t aubio_wavetable_get_freq ( aubio_wavetable_t * o); +smpl_t aubio_wavetable_get_freq ( const aubio_wavetable_t * o); /** set wavetable amplitude @@ -162,7 +162,7 @@ uint_t aubio_wavetable_set_amp ( aubio_wavetable_t * o, smpl_t amp ); \return current amplitude */ -smpl_t aubio_wavetable_get_amp ( aubio_wavetable_t * o); +smpl_t aubio_wavetable_get_amp ( const aubio_wavetable_t * o); /** destroy aubio_wavetable_t object