comparison xtract/xtract_scalar.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 9283aaf1ffb8
comparison
equal deleted inserted replaced
145:2663eac093a5 146:baaa9d8b4d10
45 * \param *data: a pointer to the first element 45 * \param *data: a pointer to the first element
46 * \param N: the number of array elements to be considered 46 * \param N: the number of array elements to be considered
47 * \param *argv: a pointer to NULL 47 * \param *argv: a pointer to NULL
48 * \param *result: the mean of N values from the array pointed to by *data 48 * \param *result: the mean of N values from the array pointed to by *data
49 */ 49 */
50 int xtract_mean(const float *data, const int N, const void *argv, float *result); 50 int xtract_mean(const double *data, const int N, const void *argv, double *result);
51 51
52 /** \brief Extract the variance of an input vector 52 /** \brief Extract the variance of an input vector
53 * 53 *
54 * \param *data: a pointer to the first element in an array of floats 54 * \param *data: a pointer to the first element in an array of doubles
55 * \param N: the number of elements to be considered 55 * \param N: the number of elements to be considered
56 * \param *argv: a pointer to a float representing the mean of the input vector 56 * \param *argv: a pointer to a double representing the mean of the input vector
57 * \param *result: the variance of N values from the array pointed to by *data 57 * \param *result: the variance of N values from the array pointed to by *data
58 */ 58 */
59 int xtract_variance(const float *data, const int N, const void *argv, float *result); 59 int xtract_variance(const double *data, const int N, const void *argv, double *result);
60 60
61 /** \brief Extract the deviation of an input vector 61 /** \brief Extract the deviation of an input vector
62 * 62 *
63 * \param *data: a pointer to the first element in an array of floats 63 * \param *data: a pointer to the first element in an array of doubles
64 * \param N: the number of elements to be considered 64 * \param N: the number of elements to be considered
65 * \param *argv: a pointer to a float representing the variance of the input vector 65 * \param *argv: a pointer to a double representing the variance of the input vector
66 * \param *result: the deviation of N values from the array pointed to by *data 66 * \param *result: the deviation of N values from the array pointed to by *data
67 */ 67 */
68 int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result); 68 int xtract_standard_deviation(const double *data, const int N, const void *argv, double *result);
69 69
70 /** \brief Extract the average deviation of an input vector 70 /** \brief Extract the average deviation of an input vector
71 * 71 *
72 * \param *data: a pointer to the first element in an array of floats 72 * \param *data: a pointer to the first element in an array of doubles
73 * \param N: the number of elements to be considered 73 * \param N: the number of elements to be considered
74 * \param *argv: a pointer to a float representing the mean of the input vector 74 * \param *argv: a pointer to a double representing the mean of the input vector
75 * \param *result: the average deviation of N values from the array pointed to by *data 75 * \param *result: the average deviation of N values from the array pointed to by *data
76 */ 76 */
77 int xtract_average_deviation(const float *data, const int N, const void *argv, float *result); 77 int xtract_average_deviation(const double *data, const int N, const void *argv, double *result);
78 78
79 79
80 /** \brief Extract the skewness of an input vector 80 /** \brief Extract the skewness of an input vector
81 * 81 *
82 * \param *data: a pointer to the first element in an array of floats 82 * \param *data: a pointer to the first element in an array of doubles
83 * \param N: the number of elements to be considered 83 * \param N: the number of elements to be considered
84 * \param *argv: a pointer to an array of floats representing the mean and standard deviation of the input vector 84 * \param *argv: a pointer to an array of doubles representing the mean and standard deviation of the input vector
85 * \param *result: the skewness of N values from the array pointed to by *data 85 * \param *result: the skewness of N values from the array pointed to by *data
86 */ 86 */
87 int xtract_skewness(const float *data, const int N, const void *argv, float *result); 87 int xtract_skewness(const double *data, const int N, const void *argv, double *result);
88 88
89 /** \brief Extract the kurtosis of an input vector 89 /** \brief Extract the kurtosis of an input vector
90 * 90 *
91 * \param *data: a pointer to the first element in an array of floats 91 * \param *data: a pointer to the first element in an array of doubles
92 * \param N: the number of elements to be considered 92 * \param N: the number of elements to be considered
93 * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector 93 * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector
94 * \param *result: the kurtosis of N values from the array pointed to by *data 94 * \param *result: the kurtosis of N values from the array pointed to by *data
95 */ 95 */
96 int xtract_kurtosis(const float *data, const int N, const void *argv, float *result); 96 int xtract_kurtosis(const double *data, const int N, const void *argv, double *result);
97 97
98 /** \brief Extract the mean of an input spectrum 98 /** \brief Extract the mean of an input spectrum
99 * 99 *
100 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 100 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
101 * \param N: the size of the array pointed to by *data 101 * \param N: the size of the array pointed to by *data
102 * \param *argv: a pointer to NULL 102 * \param *argv: a pointer to NULL
103 * \param *result: the mean of the spectrum pointed to by *data 103 * \param *result: the mean of the spectrum pointed to by *data
104 */ 104 */
105 int xtract_spectral_mean(const float *data, const int N, const void *argv, float *result); 105 int xtract_spectral_mean(const double *data, const int N, const void *argv, double *result);
106 106
107 /** \brief Extract the variance of an input spectrum 107 /** \brief Extract the variance of an input spectrum
108 * 108 *
109 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 109 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
110 * \param N: the number of elements to be considered 110 * \param N: the number of elements to be considered
111 * \param N: the size of the array pointed to by *data 111 * \param N: the size of the array pointed to by *data
112 * \param *argv: a pointer to a float representing the spectral mean of the input spectrum 112 * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
113 * \param *result: the variance of the spectrum pointed to by *data 113 * \param *result: the variance of the spectrum pointed to by *data
114 */ 114 */
115 int xtract_spectral_variance(const float *data, const int N, const void *argv, float *result); 115 int xtract_spectral_variance(const double *data, const int N, const void *argv, double *result);
116 116
117 /** \brief Extract the deviation of an input spectrum 117 /** \brief Extract the deviation of an input spectrum
118 * 118 *
119 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 119 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
120 * \param N: the size of the array pointed to by *data 120 * \param N: the size of the array pointed to by *data
121 * \param *argv: a pointer to a float representing the spectral variance of the input spectrum 121 * \param *argv: a pointer to a double representing the spectral variance of the input spectrum
122 * \param *result: the deviation of the spectrum pointed to by *data 122 * \param *result: the deviation of the spectrum pointed to by *data
123 */ 123 */
124 int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result); 124 int xtract_spectral_standard_deviation(const double *data, const int N, const void *argv, double *result);
125 125
126 /** \brief Extract the average deviation of an input spectrum 126 /** \brief Extract the average deviation of an input spectrum
127 * 127 *
128 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 128 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
129 * \param N: the size of the array pointed to by *data 129 * \param N: the size of the array pointed to by *data
130 * \param *argv: a pointer to a float representing the spectral mean of the input spectrum 130 * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
131 * \param *result: the average deviation of the spectrum pointed to by *data 131 * \param *result: the average deviation of the spectrum pointed to by *data
132 */ 132 */
133 /* 133 /*
134 int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result); 134 int xtract_spectral_average_deviation(const double *data, const int N, const void *argv, double *result);
135 */ 135 */
136 136
137 /** \brief Extract the skewness of an input spectrum 137 /** \brief Extract the skewness of an input spectrum
138 * 138 *
139 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 139 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
140 * \param N: the size of the array pointed to by *data 140 * \param N: the size of the array pointed to by *data
141 * \param *argv: a pointer to an array of floats representing the spectral mean and spectral standard deviation of the input spectrum 141 * \param *argv: a pointer to an array of doubles representing the spectral mean and spectral standard deviation of the input spectrum
142 * \param *result: the skewness of the spectrum pointed to by *data 142 * \param *result: the skewness of the spectrum pointed to by *data
143 */ 143 */
144 int xtract_spectral_skewness(const float *data, const int N, const void *argv, float *result); 144 int xtract_spectral_skewness(const double *data, const int N, const void *argv, double *result);
145 145
146 /** \brief Extract the kurtosis of an input spectrum 146 /** \brief Extract the kurtosis of an input spectrum
147 * 147 *
148 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 148 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
149 * \param N: the size of the array pointed to by *data 149 * \param N: the size of the array pointed to by *data
150 * \param *argv: a pointer to an array of values representing the spectral mean and spectral standard deviation of the input spectrum 150 * \param *argv: a pointer to an array of values representing the spectral mean and spectral standard deviation of the input spectrum
151 * \param *result: the kurtosis of the spectrum pointed to by *data 151 * \param *result: the kurtosis of the spectrum pointed to by *data
152 */ 152 */
153 int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, float *result); 153 int xtract_spectral_kurtosis(const double *data, const int N, const void *argv, double *result);
154 154
155 /** \brief Extract the centroid of an input vector 155 /** \brief Extract the centroid of an input vector
156 * 156 *
157 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 157 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
158 * \param N: the number of elements to be considered 158 * \param N: the number of elements to be considered
159 * \param *argv: a pointer to NULL 159 * \param *argv: a pointer to NULL
160 * \param *result: the centroid of the values pointed to by *data 160 * \param *result: the centroid of the values pointed to by *data
161 * 161 *
162 * Note: for a more 'accurate' result *result from xtract_peak_spectrum() can be passed in. This gives the interpolated peak frequency locations. 162 * Note: for a more 'accurate' result *result from xtract_peak_spectrum() can be passed in. This gives the interpolated peak frequency locations.
163 * 163 *
164 */ 164 */
165 int xtract_spectral_centroid(const float *data, const int N, const void *argv, float *result); 165 int xtract_spectral_centroid(const double *data, const int N, const void *argv, double *result);
166 166
167 /** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994) 167 /** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994)
168 * 168 *
169 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 169 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
170 * \param N: the number of elements to be considered 170 * \param N: the number of elements to be considered
171 * \param *argv: a pointer to NULL 171 * \param *argv: a pointer to NULL
172 * \param *result: the irregularity of N values from the array pointed to by *data 172 * \param *result: the irregularity of N values from the array pointed to by *data
173 */ 173 */
174 int xtract_irregularity_k(const float *data, const int N, const void *argv, float *result); 174 int xtract_irregularity_k(const double *data, const int N, const void *argv, double *result);
175 175
176 /** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999) 176 /** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999)
177 * 177 *
178 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 178 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
179 * \param N: the number of elements to be considered 179 * \param N: the number of elements to be considered
180 * \param *argv: a pointer to NULL 180 * \param *argv: a pointer to NULL
181 * \param *result: the irregularity of N values from the array pointed to by *data 181 * \param *result: the irregularity of N values from the array pointed to by *data
182 */ 182 */
183 int xtract_irregularity_j(const float *data, const int N, const void *argv, float *result); 183 int xtract_irregularity_j(const double *data, const int N, const void *argv, double *result);
184 184
185 /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982) 185 /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982)
186 * 186 *
187 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients of the harmonic spectrum of an audio vector e.g. a pointer to the first half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_peak_spectrum()) can be used if one wishes to consider all partials not just harmonics. 187 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients of the harmonic spectrum of an audio vector e.g. a pointer to the first half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_peak_spectrum()) can be used if one wishes to consider all partials not just harmonics.
188 * \param N: the number of elements to be considered 188 * \param N: the number of elements to be considered
189 * \param *argv: a pointer to NULL 189 * \param *argv: a pointer to NULL
190 * \param *result: the tristimulus of N values from the array pointed to by *data 190 * \param *result: the tristimulus of N values from the array pointed to by *data
191 * 191 *
192 * These three functions provide the first, second and third order tristimulus formulae 192 * These three functions provide the first, second and third order tristimulus formulae
193 * 193 *
194 */ 194 */
195 int xtract_tristimulus_1(const float *data, const int N, const void *argv, float *result); 195 int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result);
196 int xtract_tristimulus_2(const float *data, const int N, const void *argv, float *result); 196 int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result);
197 int xtract_tristimulus_3(const float *data, const int N, const void *argv, float *result); 197 int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result);
198 198
199 /** \brief Extract the smoothness of an input vector using a method described by McAdams (1999) 199 /** \brief Extract the smoothness of an input vector using a method described by McAdams (1999)
200 * 200 *
201 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 201 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
202 * \param N: the number of elements to be considered 202 * \param N: the number of elements to be considered
203 * \param *argv: a pointer to the first element of an array of integers containing the lower bound, upper bound, and pre-scaling factor, whereby array data in the range lower < n < upper will be pre-scaled by p before processing. 203 * \param *argv: a pointer to the first element of an array of integers containing the lower bound, upper bound, and pre-scaling factor, whereby array data in the range lower < n < upper will be pre-scaled by p before processing.
204 * \param *result: the smoothness of N values from the array pointed to by *data 204 * \param *result: the smoothness of N values from the array pointed to by *data
205 */ 205 */
206 int xtract_smoothness(const float *data, const int N, const void *argv, float *result); 206 int xtract_smoothness(const double *data, const int N, const void *argv, double *result);
207 207
208 /** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005) 208 /** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005)
209 * 209 *
210 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 210 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
211 * \param N: the number of elements to be considered 211 * \param N: the number of elements to be considered
212 * \param *argv: a pointer to a float corresponding to the spectral centroid 212 * \param *argv: a pointer to a double corresponding to the spectral centroid
213 * \param *result: the spectral spread of N values from the array pointed to by *data 213 * \param *result: the spectral spread of N values from the array pointed to by *data
214 */ 214 */
215 int xtract_spread(const float *data, const int N, const void *argv, float *result); 215 int xtract_spread(const double *data, const int N, const void *argv, double *result);
216 216
217 /* Zero crossing rate */ 217 /* Zero crossing rate */
218 218
219 /** \brief Extract the zero crossing rate of an input vector 219 /** \brief Extract the zero crossing rate of an input vector
220 * 220 *
221 * \param *data: a pointer to the first element in an array of floats 221 * \param *data: a pointer to the first element in an array of doubles
222 * \param N: the number of elements to be considered 222 * \param N: the number of elements to be considered
223 * \param *argv: a pointer to NULL 223 * \param *argv: a pointer to NULL
224 * \param *result: the zero crossing rate of N values from the array pointed to by *data 224 * \param *result: the zero crossing rate of N values from the array pointed to by *data
225 */ 225 */
226 int xtract_zcr(const float *data, const int N, const void *argv, float *result); 226 int xtract_zcr(const double *data, const int N, const void *argv, double *result);
227 227
228 /** \brief Extract the spectral rolloff of an input vector using a method described by Bee Suan Ong (2005) 228 /** \brief Extract the spectral rolloff of an input vector using a method described by Bee Suan Ong (2005)
229 * 229 *
230 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 230 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
231 * \param N: the number of elements to be considered 231 * \param N: the number of elements to be considered
232 * \param *argv: a pointer to an array containing a float representing (samplerate / N ) and a float representing the threshold for rolloff, i.e. the percentile at which the rolloff is determined, expressed as a percentage, and 232 * \param *argv: a pointer to an array containing a double representing (samplerate / N ) and a double representing the threshold for rolloff, i.e. the percentile at which the rolloff is determined, expressed as a percentage, and
233 * \param *result: the spectral rolloff in Hz of N values from the array pointed to by *data. This is the point in the spectrum below which argv[0] of the energy is distributed. 233 * \param *result: the spectral rolloff in Hz of N values from the array pointed to by *data. This is the point in the spectrum below which argv[0] of the energy is distributed.
234 */ 234 */
235 int xtract_rolloff(const float *data, const int N, const void *argv, float *result); 235 int xtract_rolloff(const double *data, const int N, const void *argv, double *result);
236 236
237 /** \brief Extract the 'total loudness' of an input vector using a method described by Moore, Glasberg et al (2005) 237 /** \brief Extract the 'total loudness' of an input vector using a method described by Moore, Glasberg et al (2005)
238 * 238 *
239 * \param *data: a pointer to the first element in an array of floats representing a set of BARK_BANDS bark coefficients 239 * \param *data: a pointer to the first element in an array of doubles representing a set of BARK_BANDS bark coefficients
240 * \param N: the number of coefficients to be considered 240 * \param N: the number of coefficients to be considered
241 * \param *argv: a pointer to NULL 241 * \param *argv: a pointer to NULL
242 * \param *result: the total loudness of N values from the array pointed to by *data 242 * \param *result: the total loudness of N values from the array pointed to by *data
243 * 243 *
244 * Note: if N = 1, the 'specific loudness' of the bark band pointed to by *data will be given by *result 244 * Note: if N = 1, the 'specific loudness' of the bark band pointed to by *data will be given by *result
245 * 245 *
246 */ 246 */
247 int xtract_loudness(const float *data, const int N, const void *argv, float *result); 247 int xtract_loudness(const double *data, const int N, const void *argv, double *result);
248 248
249 /** \brief Extract the spectral flatness measure of an input vector, where the flatness measure (SFM) is defined as the ratio of the geometric mean to the arithmetic mean of a magnitude spectrum. 249 /** \brief Extract the spectral flatness measure of an input vector, where the flatness measure (SFM) is defined as the ratio of the geometric mean to the arithmetic mean of a magnitude spectrum.
250 * 250 *
251 * \note The computation method used here is the most efficient by a significant margin, but suffers from precision problems due to the multiplication operationin the geometric mean calculation. This is particularly accute for larger values of N (>=256). However, as noted by Peeters (2003), the SFM should generally be computed on a small number of 'bands' rather than on the complete magnitude spectrum. It is therefore highly recommended that xtract_bands() is used prior to calling xtract_flatness(). 251 * \note The computation method used here is the most efficient by a significant margin, but suffers from precision problems due to the multiplication operationin the geometric mean calculation. This is particularly accute for larger values of N (>=256). However, as noted by Peeters (2003), the SFM should generally be computed on a small number of 'bands' rather than on the complete magnitude spectrum. It is therefore highly recommended that xtract_bands() is used prior to calling xtract_flatness().
252 * 252 *
253 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). Alternatively the magnitudes from a number of 'subbands' can be used by using *result from xtract_bands(). 253 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). Alternatively the magnitudes from a number of 'subbands' can be used by using *result from xtract_bands().
254 * \param N: the number of *data array elements to be considered 254 * \param N: the number of *data array elements to be considered
255 * \param *argv: a pointer to NULL 255 * \param *argv: a pointer to NULL
256 * \param *result: the flatness of N values from the array pointed to by *data 256 * \param *result: the flatness of N values from the array pointed to by *data
257 */ 257 */
258 int xtract_flatness(const float *data, const int N, const void *argv, float *result); 258 int xtract_flatness(const double *data, const int N, const void *argv, double *result);
259 259
260 /** \brief Extract the LOG spectral flatness measure of an input vector 260 /** \brief Extract the LOG spectral flatness measure of an input vector
261 * 261 *
262 * \param *data: a pointer to NULL. 262 * \param *data: a pointer to NULL.
263 * \param N: not used - can safely be set to 0. 263 * \param N: not used - can safely be set to 0.
264 * \param *argv: a pointer to a float represnting spectral flatness. 264 * \param *argv: a pointer to a double represnting spectral flatness.
265 * \param *result: the LOG spectral flatness of N values from the array pointed to by *data 265 * \param *result: the LOG spectral flatness of N values from the array pointed to by *data
266 * 266 *
267 * flatness_db = 10 * log10(flatness) 267 * flatness_db = 10 * log10(flatness)
268 * 268 *
269 */ 269 */
270 int xtract_flatness_db(const float *data, const int N, const void *argv, float *result); 270 int xtract_flatness_db(const double *data, const int N, const void *argv, double *result);
271 271
272 /** \brief Extract the tonality factor of an input vector using a method described by Peeters 2003 272 /** \brief Extract the tonality factor of an input vector using a method described by Peeters 2003
273 * 273 *
274 * \param *data: a pointer to NULL. 274 * \param *data: a pointer to NULL.
275 * \param N: not used - can safely be set to 0. 275 * \param N: not used - can safely be set to 0.
276 * \param *argv: a pointer to the LOG spectral flatness measure of an audio vector (e.g. the output from xtract_flatness_db) 276 * \param *argv: a pointer to the LOG spectral flatness measure of an audio vector (e.g. the output from xtract_flatness_db)
277 * \param *result: the tonality factor of N values from the array pointed to by *data 277 * \param *result: the tonality factor of N values from the array pointed to by *data
278 */ 278 */
279 int xtract_tonality(const float *data, const int N, const void *argv, float *result); 279 int xtract_tonality(const double *data, const int N, const void *argv, double *result);
280 280
281 /** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000) 281 /** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000)
282 * 282 *
283 * \param *data: a pointer to NULL 283 * \param *data: a pointer to NULL
284 * \param N: 284 * \param N:
285 * \param *argv: a pointer to an array containing a float represnting the number of harmonic partials in a spectrum, and a float representing the number of partials in a spectrum 285 * \param *argv: a pointer to an array containing a double represnting the number of harmonic partials in a spectrum, and a double representing the number of partials in a spectrum
286 * \param *result: the noisiness coefficient as calculated from argv 286 * \param *result: the noisiness coefficient as calculated from argv
287 */ 287 */
288 int xtract_noisiness(const float *data, const int N, const void *argv, float *result); 288 int xtract_noisiness(const double *data, const int N, const void *argv, double *result);
289 289
290 /** \brief Extract the RMS amplitude of an input vector using a method described by Tae Hong Park (2000) 290 /** \brief Extract the RMS amplitude of an input vector using a method described by Tae Hong Park (2000)
291 * 291 *
292 * \param *data: a pointer to the first element in an array of floats 292 * \param *data: a pointer to the first element in an array of doubles
293 * \param N: the number of elements to be considered 293 * \param N: the number of elements to be considered
294 * \param *argv: a pointer to NULL 294 * \param *argv: a pointer to NULL
295 * \param *result: the RMS amplitude of N values from the array pointed to by *data 295 * \param *result: the RMS amplitude of N values from the array pointed to by *data
296 */ 296 */
297 int xtract_rms_amplitude(const float *data, const int N, const void *argv, float *result); 297 int xtract_rms_amplitude(const double *data, const int N, const void *argv, double *result);
298 298
299 /** \brief Extract the Inharmonicity of an input vector 299 /** \brief Extract the Inharmonicity of an input vector
300 * 300 *
301 * \param *data: a pointer to the first element in an array of floats represeting a magnitude peak spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_peak_spectrum()) 301 * \param *data: a pointer to the first element in an array of doubles represeting a magnitude peak spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_peak_spectrum())
302 * \param N: the number of elements to be considered 302 * \param N: the number of elements to be considered
303 * \param *argv: a pointer to a float representing the fundamental frequency of the input vector. 303 * \param *argv: a pointer to a double representing the fundamental frequency of the input vector.
304 * \param *result: the inharmonicity of N values from the array pointed to by *data 304 * \param *result: the inharmonicity of N values from the array pointed to by *data
305 */ 305 */
306 int xtract_spectral_inharmonicity(const float *data, const int N, const void *argv, float *result); 306 int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result);
307 307
308 /** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003) 308 /** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003)
309 * 309 *
310 * \param *data: a pointer to NULL 310 * \param *data: a pointer to NULL
311 * \param N: not used 311 * \param N: not used
312 * \param *argv: a pointer to an array containing a float representing the maximum value in a spectrum, and a float representing the mean value of a spectrum 312 * \param *argv: a pointer to an array containing a double representing the maximum value in a spectrum, and a double representing the mean value of a spectrum
313 * \param *result: the spectral crest of N values from the array pointed to by *data 313 * \param *result: the spectral crest of N values from the array pointed to by *data
314 */ 314 */
315 int xtract_crest(const float *data, const int N, const void *argv, float *result); 315 int xtract_crest(const double *data, const int N, const void *argv, double *result);
316 316
317 /** \brief Extract the Spectral Power of an input vector using a method described by Bee Suan Ong (2005) 317 /** \brief Extract the Spectral Power of an input vector using a method described by Bee Suan Ong (2005)
318 * 318 *
319 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 319 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
320 * \param N: the number of elements to be considered 320 * \param N: the number of elements to be considered
321 * \param *argv: a pointer to NULL 321 * \param *argv: a pointer to NULL
322 * \param *result: the spectral power of N values from the array pointed to by *data 322 * \param *result: the spectral power of N values from the array pointed to by *data
323 */ 323 */
324 int xtract_power(const float *data, const int N, const void *argv, float *result); 324 int xtract_power(const double *data, const int N, const void *argv, double *result);
325 325
326 /* Odd to even harmonic ratio */ 326 /* Odd to even harmonic ratio */
327 /** \brief Extract the Odd to even harmonic ratio of an input vector 327 /** \brief Extract the Odd to even harmonic ratio of an input vector
328 * 328 *
329 * \param *data: a pointer to the first element in an array of floats representing the amplitudes of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to the first half of the array pointed to by *result from xtract_harmonic_spectrum(). 329 * \param *data: a pointer to the first element in an array of doubles representing the amplitudes of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to the first half of the array pointed to by *result from xtract_harmonic_spectrum().
330 * \param N: the number of elements to be considered. If using the array pointed to by *result from xtract_harmonics, N should equal half the total array size i.e., just the amplitudes of the peaks. 330 * \param N: the number of elements to be considered. If using the array pointed to by *result from xtract_harmonics, N should equal half the total array size i.e., just the amplitudes of the peaks.
331 * \param *argv: a pointer to NULL 331 * \param *argv: a pointer to NULL
332 * \param *result: the even/odd harmonic ratio of N values from the array pointed to by *data 332 * \param *result: the even/odd harmonic ratio of N values from the array pointed to by *data
333 */ 333 */
334 int xtract_odd_even_ratio(const float *data, const int N, const void *argv, float *result); 334 int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result);
335 335
336 /** \brief Extract the Sharpness of an input vector 336 /** \brief Extract the Sharpness of an input vector
337 * 337 *
338 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 338 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
339 * \param N: the number of elements to be considered 339 * \param N: the number of elements to be considered
340 * \param *argv: a pointer to NULL 340 * \param *argv: a pointer to NULL
341 * \param *result: the Sharpness of N values from the array pointed to by *data 341 * \param *result: the Sharpness of N values from the array pointed to by *data
342 */ 342 */
343 int xtract_sharpness(const float *data, const int N, const void *argv, float *result); 343 int xtract_sharpness(const double *data, const int N, const void *argv, double *result);
344 344
345 /** \brief Extract the Slope of an input vector using a method described by Peeters(2003) 345 /** \brief Extract the Slope of an input vector using a method described by Peeters(2003)
346 * 346 *
347 * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). 347 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
348 * \param N: the number of elements to be considered 348 * \param N: the number of elements to be considered
349 * \param *argv: a pointer to NULL 349 * \param *argv: a pointer to NULL
350 * \param *result: the Slope of N values from the array pointed to by *data 350 * \param *result: the Slope of N values from the array pointed to by *data
351 */ 351 */
352 int xtract_spectral_slope(const float *data, const int N, const void *argv, float *result); 352 int xtract_spectral_slope(const double *data, const int N, const void *argv, double *result);
353 353
354 /** \brief Extract the value of the lowest value in an input vector 354 /** \brief Extract the value of the lowest value in an input vector
355 * 355 *
356 * \param *data: a pointer to the first element in an array of floats 356 * \param *data: a pointer to the first element in an array of doubles
357 * \param N: the number of elements to be considered 357 * \param N: the number of elements to be considered
358 * \param *argv: a pointer to a float representing the lower limit for the search. i.e. (*result > *argv) returns 1. 358 * \param *argv: a pointer to a double representing the lower limit for the search. i.e. (*result > *argv) returns 1.
359 * \param *result: a pointer to a value representing the lowest component in *data that falls above a given threshold. 359 * \param *result: a pointer to a value representing the lowest component in *data that falls above a given threshold.
360 * 360 *
361 */ 361 */
362 int xtract_lowest_value(const float *data, const int N, const void *argv, float *result); 362 int xtract_lowest_value(const double *data, const int N, const void *argv, double *result);
363 363
364 /** \brief Extract the value of the highest value in an input vector 364 /** \brief Extract the value of the highest value in an input vector
365 * 365 *
366 * \param *data: a pointer to the first element in an array of floats 366 * \param *data: a pointer to the first element in an array of doubles
367 * \param N: the number of elements to be considered 367 * \param N: the number of elements to be considered
368 * \param *argv: a pointer to NULL. 368 * \param *argv: a pointer to NULL.
369 * \param *result: a pointer to a value representing the highest component in *data. 369 * \param *result: a pointer to a value representing the highest component in *data.
370 * 370 *
371 */ 371 */
372 int xtract_highest_value(const float *data, const int N, const void *argv, float *result); 372 int xtract_highest_value(const double *data, const int N, const void *argv, double *result);
373 373
374 /** \brief Extract the sum of the values in an input vector 374 /** \brief Extract the sum of the values in an input vector
375 * 375 *
376 * \param *data: a pointer to the first element in an array of floats 376 * \param *data: a pointer to the first element in an array of doubles
377 * \param N: the number of elements to be considered 377 * \param N: the number of elements to be considered
378 * \param *argv: a pointer to NULL. 378 * \param *argv: a pointer to NULL.
379 * \param *result: a pointer to a value representing the sum of all of the values pointed to by *data. 379 * \param *result: a pointer to a value representing the sum of all of the values pointed to by *data.
380 * 380 *
381 */ 381 */
382 int xtract_sum(const float *data, const int N, const void *argv, float *result); 382 int xtract_sum(const double *data, const int N, const void *argv, double *result);
383 383
384 /** \brief Extract the Pitch of an input vector using Harmonic Product Spectrum (HPS) analysis 384 /** \brief Extract the Pitch of an input vector using Harmonic Product Spectrum (HPS) analysis
385 * 385 *
386 * \warning {This function doesn't work properly} 386 * \warning {This function doesn't work properly}
387 * 387 *
388 * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). 388 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
389 * \param N: the number of elements to be considered 389 * \param N: the number of elements to be considered
390 * \param *argv: a pointer to NULL 390 * \param *argv: a pointer to NULL
391 * \param *result: the pitch of N values from the array pointed to by *data 391 * \param *result: the pitch of N values from the array pointed to by *data
392 */ 392 */
393 int xtract_hps(const float *data, const int N, const void *argv, float *result); 393 int xtract_hps(const double *data, const int N, const void *argv, double *result);
394 394
395 /** \brief Extract the fundamental frequency of an input vector 395 /** \brief Extract the fundamental frequency of an input vector
396 * 396 *
397 * \param *data: a pointer to the first element in an array of floats representing an audio vector 397 * \param *data: a pointer to the first element in an array of doubles representing an audio vector
398 * \param N: the number of elements to be considered 398 * \param N: the number of elements to be considered
399 * \param *argv: a pointer to a float representing the audio sample rate 399 * \param *argv: a pointer to a double representing the audio sample rate
400 * \param *result: the pitch of N values from the array pointed to by *data 400 * \param *result: the pitch of N values from the array pointed to by *data
401 * 401 *
402 * This algorithm is based on the AMDF, with peak and centre clipping. It would benefit from further improvements to improve noise robustness and overall efficiency 402 * This algorithm is based on the AMDF, with peak and centre clipping. It would benefit from further improvements to improve noise robustness and overall efficiency
403 * 403 *
404 * It is based on suggestion by Robert Bristow-Johnson in a discussion on the comp.dsp mailing list, subject "Reference implementation of pitch detection" 404 * It is based on suggestion by Robert Bristow-Johnson in a discussion on the comp.dsp mailing list, subject "Reference implementation of pitch detection"
405 * 405 *
406 */ 406 */
407 int xtract_f0(const float *data, const int N, const void *argv, float *result); 407 int xtract_f0(const double *data, const int N, const void *argv, double *result);
408 408
409 /** \brief Extract the fundamental frequency of an input vector 409 /** \brief Extract the fundamental frequency of an input vector
410 * 410 *
411 * \param *data: a pointer to the first element in an array of floats representing an audio vector 411 * \param *data: a pointer to the first element in an array of doubles representing an audio vector
412 * \param N: the number of elements to be considered 412 * \param N: the number of elements to be considered
413 * \param *argv: a pointer to a float representing the audio sample rate 413 * \param *argv: a pointer to a double representing the audio sample rate
414 * \param *result: the pitch of N values from the array pointed to by *data 414 * \param *result: the pitch of N values from the array pointed to by *data
415 * 415 *
416 * This function wraps xtract_f0, but provides the frequency of the lowest partial in the peak spectrum if f0 can't be found. 416 * This function wraps xtract_f0, but provides the frequency of the lowest partial in the peak spectrum if f0 can't be found.
417 * 417 *
418 */ 418 */
419 int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result); 419 int xtract_failsafe_f0(const double *data, const int N, const void *argv, double *result);
420 420
421 /** \brief Extract the number of non-zero elements in an input vector 421 /** \brief Extract the number of non-zero elements in an input vector
422 * 422 *
423 * \param *data: a pointer to the first element in an array of floats 423 * \param *data: a pointer to the first element in an array of doubles
424 * \param N: the number of elements to be considered 424 * \param N: the number of elements to be considered
425 * \param *argv: not used 425 * \param *argv: not used
426 * \param *result: the number of non-zero elements in the array pointed to by *data 426 * \param *result: the number of non-zero elements in the array pointed to by *data
427 * 427 *
428 */ 428 */
429 int xtract_nonzero_count(const float *data, const int N, const void *argv, float *result); 429 int xtract_nonzero_count(const double *data, const int N, const void *argv, double *result);
430 430
431 /** @} */ 431 /** @} */
432 432
433 #ifdef __cplusplus 433 #ifdef __cplusplus
434 } 434 }