source: src/temporal/filter.h @ a54502c

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since a54502c was a54502c, checked in by Paul Brossier <piem@piem.org>, 15 years ago

src/temporal/filter.{c,h}: indent, update copyright and license

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#ifndef FILTER_H
22#define FILTER_H
23
24/** \file
25
26  Digital filter
27
28  This object stores a digital filter of order \f$n\f$ for \f$c\f$ channels.
29  It contains the following data:
30    - \f$ n*1 b_i \f$ feedforward coefficients
31    - \f$ n*1 a_i \f$ feedback coefficients
32    - \f$ n*c x_i \f$ input signal
33    - \f$ n*c y_i \f$ output signal
34
35  For convenience, the samplerate of the input signal is also stored in the object.
36
37  Feedforward and feedback parameters can be modified using
38  aubio_filter_get_feedback() and aubio_filter_get_feedforward().
39
40  The function aubio_filter_do_outplace() computes the following output signal
41  \f$ y[n] \f$ from the input signal \f$ x[n] \f$:
42 
43  \f{eqnarray*}{
44     y[n] = b_0 x[n] & + & b_1 x[n-1] + b_2 x[n-2] + ... + b_P x[n-P] \\
45                     & - & a_1 y[n-1] - a_2 y[n-2] - ... - a_P y[n-P] \\
46  \f}
47
48  The function aubio_filter_do() executes the same computation but modifies
49  directly the input signal (in-place).
50
51  The function aubio_filter_do_filtfilt() version runs the filter twice, first
52  forward then backward, to compensate with the phase shifting of the forward
53  operation.
54
55  Some convenience functions are provided:
56    - new_aubio_filter_a_weighting() and aubio_filter_set_a_weighting(),
57    - new_aubio_filter_c_weighting() and aubio_filter_set_c_weighting().
58 
59*/
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65/** Digital filter
66
67*/
68typedef struct _aubio_filter_t aubio_filter_t;
69
70/** filter input vector (in-place)
71
72  \param f filter object as returned by new_aubio_filter()
73  \param in input vector to filter
74
75*/
76void aubio_filter_do (aubio_filter_t * f, fvec_t * in);
77
78/** filter input vector (out-of-place)
79
80  \param f filter object as returned by new_aubio_filter()
81  \param in input vector to filter
82  \param out output vector to store filtered input
83
84*/
85void aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out);
86
87/** filter input vector forward and backward
88
89  \param f ::aubio_filter_t object as returned by new_aubio_filter()
90  \param in ::fvec_t input vector to filter
91  \param tmp memory space to use for computation
92
93*/
94void aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp);
95
96/** returns a pointer to feedback coefficients \f$ a_i \f$
97
98  \param f filter object to get parameters from
99
100  \return a pointer to the \f$ a_0 ... a_i ... a_P \f$ coefficients
101
102*/
103lvec_t *aubio_filter_get_feedback (aubio_filter_t * f);
104
105/** returns a pointer to feedforward coefficients \f$ b_i \f$
106
107  \param f filter object to get coefficients from
108
109  \return a pointer to the \f$ b_0 ... b_i ... b_P \f$ coefficients
110
111*/
112lvec_t *aubio_filter_get_feedforward (aubio_filter_t * f);
113
114/** get order of the filter
115
116  \param f filter to get order from
117
118  \return the order of the filter
119
120*/
121uint_t aubio_filter_get_order (aubio_filter_t * f);
122
123/** get sampling rate of the filter
124
125  \param f filter to get sampling rate from
126
127  \return the sampling rate of the filter, in Hz
128
129*/
130uint_t aubio_filter_get_samplerate (aubio_filter_t * f);
131
132/** create new filter object
133
134  This function creates a new ::aubio_filter_t object, given an order
135  and a specific number of channels.
136
137  \param samplerate signal sampling rate
138  \param order order of the filter (number of coefficients)
139  \param channels number of channels to allocate
140
141  \return the newly created filter object
142
143*/
144aubio_filter_t *new_aubio_filter (uint_t samplerate, uint_t order,
145    uint_t channels);
146
147/** delete a filter object
148 
149  \param f filter object to delete
150
151*/
152void del_aubio_filter (aubio_filter_t * f);
153
154#ifdef __cplusplus
155}
156#endif
157
158#endif /*FILTER_H*/
Note: See TracBrowser for help on using the repository browser.