Mercurial > hg > libxtract
comparison xtract/xtract_vector.h @ 146:baaa9d8b4d10
switched from single to double precision througout. closes #9
author | Jamie Bullock <jamie@jamiebullock.com> |
---|---|
date | Wed, 09 Jan 2013 12:45:29 +0000 |
parents | e4f704649c50 |
children |
comparison
equal
deleted
inserted
replaced
145:2663eac093a5 | 146:baaa9d8b4d10 |
---|---|
38 * @{ | 38 * @{ |
39 */ | 39 */ |
40 | 40 |
41 /** \brief Extract frequency domain spectrum from time domain signal | 41 /** \brief Extract frequency domain spectrum from time domain signal |
42 * | 42 * |
43 * \param *data: a pointer to the first element in an array of floats representing an audio vector | 43 * \param *data: a pointer to the first element in an array of doubles representing an audio vector |
44 * \param N: the number of array elements to be considered | 44 * \param N: the number of array elements to be considered |
45 * \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second will be cast to an integer and determines the spectrum type (e.g. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM). The third argument determines whether or not the DC component is included in the output. If argv[2] == 1, then the DC component is included in which case the size of the array pointed to by *result must be N+2. For any further use of the array pointed to by *result, the value of N must reflect the (larger) array size. The fourth argument determines whether the magnitude/power coefficients are to be normalised. If argv[3] == 1, then the coefficients are normalised. | 45 * \param *argv: a pointer to an array of doubles, the first representing (samplerate / N), the second will be cast to an integer and determines the spectrum type (e.g. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM). The third argument determines whether or not the DC component is included in the output. If argv[2] == 1, then the DC component is included in which case the size of the array pointed to by *result must be N+2. For any further use of the array pointed to by *result, the value of N must reflect the (larger) array size. The fourth argument determines whether the magnitude/power coefficients are to be normalised. If argv[3] == 1, then the coefficients are normalised. |
46 * \param *result: a pointer to an array of size N containing N/2 magnitude/power/log magnitude/log power coefficients and N/2 bin frequencies. | 46 * \param *result: a pointer to an array of size N containing N/2 magnitude/power/log magnitude/log power coefficients and N/2 bin frequencies. |
47 * | 47 * |
48 * The magnitude/power coefficients are scaled to the range 0-1 so that for a given coefficient x, 0 <= x <= 1 | 48 * The magnitude/power coefficients are scaled to the range 0-1 so that for a given coefficient x, 0 <= x <= 1 |
49 * | 49 * |
50 * \note Before calling xtract_spectrum(), the FFT must be initialised by calling xtract_init_fft(N, XTRACT_SPECTRUM) | 50 * \note Before calling xtract_spectrum(), the FFT must be initialised by calling xtract_init_fft(N, XTRACT_SPECTRUM) |
51 * | 51 * |
52 */ | 52 */ |
53 int xtract_spectrum(const float *data, const int N, const void *argv, float *result); | 53 int xtract_spectrum(const double *data, const int N, const void *argv, double *result); |
54 | 54 |
55 /** \brief Extract autocorrelation from time domain signal using FFT based method | 55 /** \brief Extract autocorrelation from time domain signal using FFT based method |
56 * | 56 * |
57 * \param *data: a pointer to the first element in an array of floats representing an audio vector | 57 * \param *data: a pointer to the first element in an array of doubles representing an audio vector |
58 * \param N: the number of array elements to be considered | 58 * \param N: the number of array elements to be considered |
59 * \param *argv: a pointer to NULL | 59 * \param *argv: a pointer to NULL |
60 * \param *result: the autocorrelation of N values from the array pointed to by *data | 60 * \param *result: the autocorrelation of N values from the array pointed to by *data |
61 */ | 61 */ |
62 int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result); | 62 int xtract_autocorrelation_fft(const double *data, const int N, const void *argv, double *result); |
63 | 63 |
64 /** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner | 64 /** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner |
65 * | 65 * |
66 * \param *data: a pointer to the first element in an array of spectral magnitudes, e.g. the first half of the array pointed to by *resul from xtract_spectrum() | 66 * \param *data: a pointer to the first element in an array of spectral magnitudes, e.g. the first half of the array pointed to by *resul from xtract_spectrum() |
67 * \param N: the number of array elements to be considered | 67 * \param N: the number of array elements to be considered |
68 * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank | 68 * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank |
69 * \param *result: a pointer to an array containing the resultant MFCC | 69 * \param *result: a pointer to an array containing the resultant MFCC |
70 * | 70 * |
71 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc | 71 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc |
72 */ | 72 */ |
73 int xtract_mfcc(const float *data, const int N, const void *argv, float *result); | 73 int xtract_mfcc(const double *data, const int N, const void *argv, double *result); |
74 | 74 |
75 /** \brief Extract the Discrete Cosine transform of a time domain signal | 75 /** \brief Extract the Discrete Cosine transform of a time domain signal |
76 * \param *data: a pointer to the first element in an array of floats representing an audio vector | 76 * \param *data: a pointer to the first element in an array of doubles representing an audio vector |
77 * \param N: the number of array elements to be considered | 77 * \param N: the number of array elements to be considered |
78 * \param *argv: a pointer to NULL | 78 * \param *argv: a pointer to NULL |
79 * \param *result: a pointer to an array containing resultant dct coefficients | 79 * \param *result: a pointer to an array containing resultant dct coefficients |
80 */ | 80 */ |
81 int xtract_dct(const float *data, const int N, const void *argv, float *result); | 81 int xtract_dct(const double *data, const int N, const void *argv, double *result); |
82 | 82 |
83 /** \brief Extract autocorrelation from time domain signal using time-domain autocorrelation technique | 83 /** \brief Extract autocorrelation from time domain signal using time-domain autocorrelation technique |
84 * | 84 * |
85 * \param *data: a pointer to the first element in an array of floats representing an audio vector | 85 * \param *data: a pointer to the first element in an array of doubles representing an audio vector |
86 * \param N: the number of array elements to be considered | 86 * \param N: the number of array elements to be considered |
87 * \param *argv: a pointer to NULL | 87 * \param *argv: a pointer to NULL |
88 * \param *result: the autocorrelation of N values from the array pointed to by *data | 88 * \param *result: the autocorrelation of N values from the array pointed to by *data |
89 */ | 89 */ |
90 int xtract_autocorrelation(const float *data, const int N, const void *argv, float *result); | 90 int xtract_autocorrelation(const double *data, const int N, const void *argv, double *result); |
91 | 91 |
92 /** \brief Extract Average Magnitude Difference Function from time domain signal | 92 /** \brief Extract Average Magnitude Difference Function from time domain signal |
93 * | 93 * |
94 * \param *data: a pointer to the first element in an array of floats representing an audio vector | 94 * \param *data: a pointer to the first element in an array of doubles representing an audio vector |
95 * \param N: the number of array elements to be considered | 95 * \param N: the number of array elements to be considered |
96 * \param *argv: a pointer to NULL | 96 * \param *argv: a pointer to NULL |
97 * \param *result: the AMDF of N values from the array pointed to by *data | 97 * \param *result: the AMDF of N values from the array pointed to by *data |
98 */ | 98 */ |
99 int xtract_amdf(const float *data, const int N, const void *argv, float *result); | 99 int xtract_amdf(const double *data, const int N, const void *argv, double *result); |
100 | 100 |
101 /** \brief Extract Average Squared Difference Function from time domain signal | 101 /** \brief Extract Average Squared Difference Function from time domain signal |
102 * | 102 * |
103 * \param *data: a pointer to the first element in an array of floats representing an audio vector | 103 * \param *data: a pointer to the first element in an array of doubles representing an audio vector |
104 * \param N: the number of array elements to be considered | 104 * \param N: the number of array elements to be considered |
105 * \param *argv: a pointer to NULL | 105 * \param *argv: a pointer to NULL |
106 * \param *result: the ASDF of N values from the array pointed to by *data | 106 * \param *result: the ASDF of N values from the array pointed to by *data |
107 */ | 107 */ |
108 int xtract_asdf(const float *data, const int N, const void *argv, float *result); | 108 int xtract_asdf(const double *data, const int N, const void *argv, double *result); |
109 | 109 |
110 /** \brief Extract Bark band coefficients based on a method | 110 /** \brief Extract Bark band coefficients based on a method |
111 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the magnitude spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). | 111 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the magnitude spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). |
112 * \param N: the number of array elements to be considered | 112 * \param N: the number of array elements to be considered |
113 * \param *argv: a pointer to an array of ints representing the limits of each bark band. This can be obtained by calling xtract_init_bark. | 113 * \param *argv: a pointer to an array of ints representing the limits of each bark band. This can be obtained by calling xtract_init_bark. |
114 * \param *result: a pointer to an array containing resultant bark coefficients | 114 * \param *result: a pointer to an array containing resultant bark coefficients |
115 * | 115 * |
116 * The limits array pointed to by *argv must be obtained by first calling xtract_init_bark | 116 * The limits array pointed to by *argv must be obtained by first calling xtract_init_bark |
117 * | 117 * |
118 */ | 118 */ |
119 int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result); | 119 int xtract_bark_coefficients(const double *data, const int N, const void *argv, double *result); |
120 | 120 |
121 /** \brief Extract the amplitude and frequency of spectral peaks from a magnitude spectrum | 121 /** \brief Extract the amplitude and frequency of spectral peaks from a magnitude spectrum |
122 * \param *data: a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum(). | 122 * \param *data: a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum(). |
123 * \param N: the size of the input array (note: it is assumed that enough memory has been allocated for an output array twice the size) | 123 * \param N: the size of the input array (note: it is assumed that enough memory has been allocated for an output array twice the size) |
124 * \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found | 124 * \param *argv: a pointer to an array of doubles, the first representing (samplerate / N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found |
125 * \param *result: a pointer to an array of size N * 2 containing N magnitude/power/log magnitude/log power coefficients and N bin frequencies. | 125 * \param *result: a pointer to an array of size N * 2 containing N magnitude/power/log magnitude/log power coefficients and N bin frequencies. |
126 * | 126 * |
127 */ | 127 */ |
128 int xtract_peak_spectrum(const float *data, const int N, const void *argv, float *result); | 128 int xtract_peak_spectrum(const double *data, const int N, const void *argv, double *result); |
129 | 129 |
130 /** \brief Extract the harmonic spectrum of from a of a peak spectrum | 130 /** \brief Extract the harmonic spectrum of from a of a peak spectrum |
131 * \param *data: a pointer to the first element in an array of floats representing the peak spectrum of an audio vector (e.g. *result from xtract_peaks). It is expected that the first half of the array pointed to by *data will contain amplitudes for each peak considered, and the the second half will contain the respective frequencies | 131 * \param *data: a pointer to the first element in an array of doubles representing the peak spectrum of an audio vector (e.g. *result from xtract_peaks). It is expected that the first half of the array pointed to by *data will contain amplitudes for each peak considered, and the the second half will contain the respective frequencies |
132 * \param N: the size of the array pointed to by *data | 132 * \param N: the size of the array pointed to by *data |
133 * \param *argv: a pointer to an array containing the fundamental (f0) of the spectrum, and a threshold (t) where 0<=t<=1.0, and t determines the distance from the nearest harmonic number within which a partial can be considered harmonic. | 133 * \param *argv: a pointer to an array containing the fundamental (f0) of the spectrum, and a threshold (t) where 0<=t<=1.0, and t determines the distance from the nearest harmonic number within which a partial can be considered harmonic. |
134 * \param *result: a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies. | 134 * \param *result: a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies. |
135 */ | 135 */ |
136 int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, float *result); | 136 int xtract_harmonic_spectrum(const double *data, const int N, const void *argv, double *result); |
137 | 137 |
138 /** \brief Extract Linear Predictive Coding Coefficients | 138 /** \brief Extract Linear Predictive Coding Coefficients |
139 * | 139 * |
140 * Based on algorithm in Rabiner and Juang as implemented by Jutta Degener in Dr. Dobb's Journal December, 1994. | 140 * Based on algorithm in Rabiner and Juang as implemented by Jutta Degener in Dr. Dobb's Journal December, 1994. |
141 * | 141 * |
146 * \param *argv: a pointer to NULL | 146 * \param *argv: a pointer to NULL |
147 * \param *result: a pointer to an array containing N-1 reflection coefficients and N-1 LPC coefficients. | 147 * \param *result: a pointer to an array containing N-1 reflection coefficients and N-1 LPC coefficients. |
148 * | 148 * |
149 * An array of size 2 * (N - 1) must be allocated, and *result must point to its first element. | 149 * An array of size 2 * (N - 1) must be allocated, and *result must point to its first element. |
150 */ | 150 */ |
151 int xtract_lpc(const float *data, const int N, const void *argv, float *result); | 151 int xtract_lpc(const double *data, const int N, const void *argv, double *result); |
152 | 152 |
153 /** \brief Extract Linear Predictive Coding Cepstral Coefficients | 153 /** \brief Extract Linear Predictive Coding Cepstral Coefficients |
154 * | 154 * |
155 * \param *data: a pointer to the first element in an array of LPC coeffiecients e.g. a pointer to the second half of the array pointed to by *result from xtract_lpc() | 155 * \param *data: a pointer to the first element in an array of LPC coeffiecients e.g. a pointer to the second half of the array pointed to by *result from xtract_lpc() |
156 * \param N: the number of LPC coefficients to be considered | 156 * \param N: the number of LPC coefficients to be considered |
157 * \param *argv: a pointer to a float representing the order of the result vector. This must be a whole number. According to Rabiner and Juang the ratio between the number (p) of LPC coefficients and the order (Q) of the LPC cepstrum is given by Q ~ (3/2)p where Q > p. | 157 * \param *argv: a pointer to a double representing the order of the result vector. This must be a whole number. According to Rabiner and Juang the ratio between the number (p) of LPC coefficients and the order (Q) of the LPC cepstrum is given by Q ~ (3/2)p where Q > p. |
158 * \param *result: a pointer to an array containing the resultant LPCC. | 158 * \param *result: a pointer to an array containing the resultant LPCC. |
159 * | 159 * |
160 * An array of size Q, where Q is given by argv[0] must be allocated, and *result must point to its first element. | 160 * An array of size Q, where Q is given by argv[0] must be allocated, and *result must point to its first element. |
161 * | 161 * |
162 */ | 162 */ |
163 int xtract_lpcc(const float *data, const int N, const void *argv, float *result); | 163 int xtract_lpcc(const double *data, const int N, const void *argv, double *result); |
164 | 164 |
165 /** \brief Extract subbands from a spectrum | 165 /** \brief Extract subbands from a spectrum |
166 * | 166 * |
167 * \param *data: a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum(). | 167 * \param *data: a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum(). |
168 * \param N: the number of elements from the array pointed to by *data to be considered | 168 * \param N: the number of elements from the array pointed to by *data to be considered |
169 * \param *argv: A pointer to an array containing four integers. The first represents the extraction function to applied to each subband e.g. XTRACT_SUM or XTRACT_MEAN, the second represents the number of subbands required, and the third represents the frequency scale to be used for the subband bounds as defined in the enumeration xtract_subband_scales_ (libxtract.h). The fourth integer represent the start point of the subbands as a location in the input array as pointed to by *data (e.g. a value of 5 would start the subband extraction at bin 5) | 169 * \param *argv: A pointer to an array containing four integers. The first represents the extraction function to applied to each subband e.g. XTRACT_SUM or XTRACT_MEAN, the second represents the number of subbands required, and the third represents the frequency scale to be used for the subband bounds as defined in the enumeration xtract_subband_scales_ (libxtract.h). The fourth integer represent the start point of the subbands as a location in the input array as pointed to by *data (e.g. a value of 5 would start the subband extraction at bin 5) |
170 * \param *result: A pointer to an array containing the resultant subband values. The calling function is responsible for allocating and freeing memory for *result. xtract_subbands() assumes that at least argv[1] * sizeof(float) bytes have been allocated. If the requested nbands extends the subband range beyond N, then the remaining bands will be set to 0. If the array pointed to by *result has more than argv[1] elements, the superfluous elements will be unchanged. | 170 * \param *result: A pointer to an array containing the resultant subband values. The calling function is responsible for allocating and freeing memory for *result. xtract_subbands() assumes that at least argv[1] * sizeof(double) bytes have been allocated. If the requested nbands extends the subband range beyond N, then the remaining bands will be set to 0. If the array pointed to by *result has more than argv[1] elements, the superfluous elements will be unchanged. |
171 * | 171 * |
172 * xtract_subbands() divides a spectrum into subbands and applies the function given by argv[0] to the values in each subband to give a 'reduced' representation of the spectrum as *result | 172 * xtract_subbands() divides a spectrum into subbands and applies the function given by argv[0] to the values in each subband to give a 'reduced' representation of the spectrum as *result |
173 * | 173 * |
174 * Specifying XTRACT_OCTAVE_SUBBANDS will extract subbands at each octave from the start bin until argv[1] is reached or N is reached | 174 * Specifying XTRACT_OCTAVE_SUBBANDS will extract subbands at each octave from the start bin until argv[1] is reached or N is reached |
175 * Specifying XTRACT_LINEAR_SUBBANDS will extract argv[1] equal sized subbands between the start bin and N | 175 * Specifying XTRACT_LINEAR_SUBBANDS will extract argv[1] equal sized subbands between the start bin and N |
176 * | 176 * |
177 * | 177 * |
178 * It is assumed that a sensible function will be given in argv[0], and for this function argv will always be NULL. Sensible values for argv[0] are XTRACT_MEAN and XTRACT_SUM, although something like XTRACT_IRREGULARITY_K might yield interesting results. | 178 * It is assumed that a sensible function will be given in argv[0], and for this function argv will always be NULL. Sensible values for argv[0] are XTRACT_MEAN and XTRACT_SUM, although something like XTRACT_IRREGULARITY_K might yield interesting results. |
179 * | 179 * |
180 */ | 180 */ |
181 int xtract_subbands(const float *data, const int N, const void *argv, float *result); | 181 int xtract_subbands(const double *data, const int N, const void *argv, double *result); |
182 /** @} */ | 182 /** @} */ |
183 | 183 |
184 #ifdef __cplusplus | 184 #ifdef __cplusplus |
185 } | 185 } |
186 #endif | 186 #endif |