aubio_filter_set_samplerate (f, samplerate);
lvec_t *bs = aubio_filter_get_feedforward (f);
lvec_t *as = aubio_filter_get_feedback (f);
- lsmp_t *b = bs->data[0], *a = as->data[0];
+ lsmp_t *b = bs->data, *a = as->data;
uint_t order = aubio_filter_get_order (f);
if (order != 7) {
}
aubio_filter_t *
-new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate)
+new_aubio_filter_a_weighting (uint_t samplerate)
{
- aubio_filter_t *f = new_aubio_filter (7, channels);
+ aubio_filter_t *f = new_aubio_filter (7);
aubio_filter_set_a_weighting (f, samplerate);
return f;
}
/** create new A-design filter
- \param channels number of channels to allocate
\param samplerate sampling frequency of the signal to filter. Should be one of
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
192000 Hz
\return a new filter object
*/
-aubio_filter_t *new_aubio_filter_a_weighting (uint_t channels,
- uint_t samplerate);
+aubio_filter_t *new_aubio_filter_a_weighting (uint_t samplerate);
/** set feedback and feedforward coefficients of a A-weighting filter
AUBIO_ERROR ("order of biquad filter must be 3, not %d\n", order);
return AUBIO_FAIL;
}
- bs->data[0][0] = b0;
- bs->data[0][1] = b1;
- bs->data[0][2] = b2;
- as->data[0][0] = 1.;
- as->data[0][1] = a1;
- as->data[0][1] = a2;
+ bs->data[0] = b0;
+ bs->data[1] = b1;
+ bs->data[2] = b2;
+ as->data[0] = 1.;
+ as->data[1] = a1;
+ as->data[1] = a2;
return AUBIO_OK;
}
aubio_filter_t *
-new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2,
- uint_t channels)
+new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2)
{
- aubio_filter_t *f = new_aubio_filter (3, channels);
+ aubio_filter_t *f = new_aubio_filter (3);
aubio_filter_set_biquad (f, b0, b1, b2, a1, a2);
return f;
}
\param b2 forward filter coefficient
\param a1 feedback filter coefficient
\param a2 feedback filter coefficient
- \param channels number of channels to allocate
*/
aubio_filter_t *new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2,
- lsmp_t a1, lsmp_t a2, uint_t channels);
+ lsmp_t a1, lsmp_t a2);
#ifdef __cplusplus
}
aubio_filter_set_samplerate (f, samplerate);
lvec_t *bs = aubio_filter_get_feedforward (f);
lvec_t *as = aubio_filter_get_feedback (f);
- lsmp_t *b = bs->data[0], *a = as->data[0];
+ lsmp_t *b = bs->data, *a = as->data;
uint_t order = aubio_filter_get_order (f);
if ( order != 5 ) {
return 0;
}
-aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate) {
- aubio_filter_t * f = new_aubio_filter(5, channels);
+aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate) {
+ aubio_filter_t * f = new_aubio_filter(5);
aubio_filter_set_c_weighting (f, samplerate);
return f;
}
/** create new C-design filter
- \param channels number of channels to allocate
\param samplerate sampling frequency of the signal to filter. Should be one of
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
192000 Hz
\return a new filter object
*/
-aubio_filter_t *new_aubio_filter_c_weighting (uint_t channels,
- uint_t samplerate);
+aubio_filter_t *new_aubio_filter_c_weighting (uint_t samplerate);
/** set feedback and feedforward coefficients of a C-weighting filter
void
aubio_filter_do (aubio_filter_t * f, fvec_t * in)
{
- uint_t i, j, l, order = f->order;
- lsmp_t *x;
- lsmp_t *y;
- lsmp_t *a = f->a->data[0];
- lsmp_t *b = f->b->data[0];
-
- for (i = 0; i < in->channels; i++) {
- x = f->x->data[i];
- y = f->y->data[i];
- for (j = 0; j < in->length; j++) {
- /* new input */
- x[0] = KILL_DENORMAL (in->data[i][j]);
- y[0] = b[0] * x[0];
- for (l = 1; l < order; l++) {
- y[0] += b[l] * x[l];
- y[0] -= a[l] * y[l];
- }
- /* new output */
- in->data[i][j] = y[0];
- /* store for next sample */
- for (l = order - 1; l > 0; l--) {
- x[l] = x[l - 1];
- y[l] = y[l - 1];
- }
+ uint_t j, l, order = f->order;
+ lsmp_t *x = f->x->data;
+ lsmp_t *y = f->y->data;
+ lsmp_t *a = f->a->data;
+ lsmp_t *b = f->b->data;
+
+ for (j = 0; j < in->length; j++) {
+ /* new input */
+ x[0] = KILL_DENORMAL (in->data[j]);
+ y[0] = b[0] * x[0];
+ for (l = 1; l < order; l++) {
+ y[0] += b[l] * x[l];
+ y[0] -= a[l] * y[l];
+ }
+ /* new output */
+ in->data[j] = y[0];
+ /* store for next sample */
+ for (l = order - 1; l > 0; l--) {
+ x[l] = x[l - 1];
+ y[l] = y[l - 1];
}
- /* store for next run */
- f->x->data[i] = x;
- f->y->data[i] = y;
}
}
void
aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp)
{
- uint_t j, i = 0;
+ uint_t j;
uint_t length = in->length;
/* apply filtering */
aubio_filter_do (f, in);
aubio_filter_do_reset (f);
/* mirror */
for (j = 0; j < length; j++)
- tmp->data[i][length - j - 1] = in->data[i][j];
+ tmp->data[length - j - 1] = in->data[j];
/* apply filtering on mirrored */
aubio_filter_do (f, tmp);
aubio_filter_do_reset (f);
/* invert back */
for (j = 0; j < length; j++)
- in->data[i][j] = tmp->data[i][length - j - 1];
+ in->data[j] = tmp->data[length - j - 1];
}
lvec_t *
}
aubio_filter_t *
-new_aubio_filter (uint_t order, uint_t channels)
+new_aubio_filter (uint_t order)
{
aubio_filter_t *f = AUBIO_NEW (aubio_filter_t);
- f->x = new_lvec (order, channels);
- f->y = new_lvec (order, channels);
- f->a = new_lvec (order, 1);
- f->b = new_lvec (order, 1);
+ f->x = new_lvec (order);
+ f->y = new_lvec (order);
+ f->a = new_lvec (order);
+ f->b = new_lvec (order);
/* by default, samplerate is not set */
f->samplerate = 0;
f->order = order;
/* set default to identity */
- f->a->data[0][1] = 1.;
+ f->a->data[1] = 1.;
return f;
}
Digital filter
- This object stores a digital filter of order \f$n\f$ for \f$c\f$ channels.
+ This object stores a digital filter of order \f$n\f$.
It contains the following data:
- \f$ n*1 b_i \f$ feedforward coefficients
- \f$ n*1 a_i \f$ feedback coefficients
/** create new filter object
- This function creates a new ::aubio_filter_t object, given an order
- and a specific number of channels.
+ This function creates a new ::aubio_filter_t object, given the order of the
+ filter.
\param order order of the filter (number of coefficients)
- \param channels number of channels to allocate
\return the newly created filter object
*/
-aubio_filter_t *new_aubio_filter (uint_t order, uint_t channels);
+aubio_filter_t *new_aubio_filter (uint_t order);
/** delete a filter object
void
aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output)
{
- uint_t i;
s->proc->input_frames = input->length;
s->proc->output_frames = output->length;
s->proc->src_ratio = (double) s->ratio;
- for (i = 0; i < input->channels; i++) {
- /* make SRC_PROC data point to input outputs */
- s->proc->data_in = (float *) input->data[i];
- s->proc->data_out = (float *) output->data[i];
- /* do resampling */
- src_process (s->stat, s->proc);
- }
+ /* make SRC_PROC data point to input outputs */
+ s->proc->data_in = (float *) input->data;
+ s->proc->data_out = (float *) output->data;
+ /* do resampling */
+ src_process (s->stat, s->proc);
}
#else
}
void
-del_aubio_resampler (aubio_resampler_t * s)
+del_aubio_resampler (aubio_resampler_t * s UNUSED)
{
}
void
-aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output)
+aubio_resampler_do (aubio_resampler_t * s UNUSED, fvec_t * input UNUSED, fvec_t * output UNUSED)
{
}
#endif /* HAVE_SAMPLERATE */