diff options
Diffstat (limited to 'xtract')
-rw-r--r-- | xtract/libxtract.h | 7 | ||||
-rw-r--r-- | xtract/xtract_delta.h | 8 | ||||
-rw-r--r-- | xtract/xtract_scalar.h | 84 | ||||
-rw-r--r-- | xtract/xtract_vector.h | 20 |
4 files changed, 66 insertions, 53 deletions
diff --git a/xtract/libxtract.h b/xtract/libxtract.h index 489cddf..7670c83 100644 --- a/xtract/libxtract.h +++ b/xtract/libxtract.h @@ -53,7 +53,7 @@ extern "C" { * @{ */ -#define XTRACT_FEATURES 44 +#define XTRACT_FEATURES 45 #define LOG_LIMIT 10e-10 #define VERY_BIG_NUMBER 2e10 @@ -89,9 +89,10 @@ enum features_ { ODD_EVEN_RATIO, SHARPNESS, SLOPE, - LOWEST_MATCH, + LOWEST, HPS, F0, + FAILSAFE_F0, FLUX, ATTACK_TIME, DECAY_TIME, @@ -178,7 +179,7 @@ printf("Mean = %.2f\n", mean); * */ #ifdef XTRACT -extern int(*xtract[XTRACT_FEATURES])(float *data, int N, void *argv, float *result); +extern int(*xtract[XTRACT_FEATURES])(const float *data, const int N, const void *argv, float *result); /** \brief An array of pointers to function help strings * diff --git a/xtract/xtract_delta.h b/xtract/xtract_delta.h index bf6fa15..461ced6 100644 --- a/xtract/xtract_delta.h +++ b/xtract/xtract_delta.h @@ -30,20 +30,20 @@ extern "C" { #include "xtract_types.h" /* \brief Extract spectral flux as defined by Gaƫl Richard (2006)*/ -int xtract_flux(float *data, int N, void *argv , float *result); +int xtract_flux(const float *data, const int N, const void *argv , float *result); /*xtract_frame_tracker *xf */ /** \brief Extract attack Time */ -int xtract_attack_time(float *data, int N, void *argv , float *result); +int xtract_attack_time(const float *data, const int N, const void *argv , float *result); /* xtract_amp_tracker *xa */ /** Extract temporal decrease */ -int xtract_decay_time(float *data, int N, void *argv, float *result); +int xtract_decay_time(const float *data, const int N, const void *argv, float *result); /* xtract_amp_tracker *xa */ /** \brief A generic function to calculate the delta of a feature over a given period (in frames) */ -int xtract_delta_feature(float *data, int N, void *argv, float *result); +int xtract_delta_feature(const float *data, const int N, const void *argv, float *result); /*xtract_frame_tracker *xf */ /*float frames*/ diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h index 8beceec..c4618fa 100644 --- a/xtract/xtract_scalar.h +++ b/xtract/xtract_scalar.h @@ -41,7 +41,7 @@ extern "C" { * \param *argv: a pointer to NULL * \param *result: the mean of N values from the array pointed to by *data */ -int xtract_mean(float *data, int N, void *argv, float *result); +int xtract_mean(const float *data, const int N, const void *argv, float *result); /** \brief Extract the variance of an input vector * @@ -50,7 +50,7 @@ int xtract_mean(float *data, int N, void *argv, float *result); * \param *argv: a pointer to a float representing the mean of the input vector * \param *result: the variance of N values from the array pointed to by *data */ -int xtract_variance(float *data, int N, void *argv, float *result); +int xtract_variance(const float *data, const int N, const void *argv, float *result); /** \brief Extract the deviation of an input vector * @@ -59,7 +59,7 @@ int xtract_variance(float *data, int N, void *argv, float *result); * \param *argv: a pointer to a float representing the variance of the input vector * \param *result: the deviation of N values from the array pointed to by *data */ -int xtract_standard_deviation(float *data, int N, void *argv, float *result); +int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result); /** \brief Extract the average deviation of an input vector * @@ -68,7 +68,7 @@ int xtract_standard_deviation(float *data, int N, void *argv, float *result); * \param *argv: a pointer to a float representing the mean of the input vector * \param *result: the average deviation of N values from the array pointed to by *data */ -int xtract_average_deviation(float *data, int N, void *argv, float *result); +int xtract_average_deviation(const float *data, const int N, const void *argv, float *result); /** \brief Extract the skewness of an input vector * @@ -77,7 +77,7 @@ int xtract_average_deviation(float *data, int N, void *argv, float *result); * \param *argv: a pointer to an array of floats representing the mean and standard deviation of the input vector * \param *result: the skewness of N values from the array pointed to by *data */ -int xtract_skewness(float *data, int N, void *argv, float *result); +int xtract_skewness(const float *data, const int N, const void *argv, float *result); /** \brief Extract the kurtosis of an input vector * @@ -86,7 +86,7 @@ int xtract_skewness(float *data, int N, void *argv, float *result); * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector * \param *result: the kurtosis of N values from the array pointed to by *data */ -int xtract_kurtosis(float *data, int N, void *argv, float *result); +int xtract_kurtosis(const float *data, const int N, const void *argv, float *result); /** \brief Extract the centroid of an input vector * @@ -95,7 +95,7 @@ int xtract_kurtosis(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the centroid of the values pointed to by *data */ -int xtract_centroid(float *data, int N, void *argv, float *result); +int xtract_centroid(const float *data, const int N, const void *argv, float *result); /** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994) * @@ -104,7 +104,7 @@ int xtract_centroid(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the irregularity of N values from the array pointed to by *data */ -int xtract_irregularity_k(float *data, int N, void *argv, float *result); +int xtract_irregularity_k(const float *data, const int N, const void *argv, float *result); /** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999) * @@ -113,7 +113,7 @@ int xtract_irregularity_k(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the irregularity of N values from the array pointed to by *data */ -int xtract_irregularity_j(float *data, int N, void *argv, float *result); +int xtract_irregularity_j(const float *data, const int N, const void *argv, float *result); /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982) * @@ -125,18 +125,18 @@ int xtract_irregularity_j(float *data, int N, void *argv, float *result); * These three functions provide the first, second and third order tristimulus formulae * */ -int xtract_tristimulus_1(float *data, int N, void *argv, float *result); -int xtract_tristimulus_2(float *data, int N, void *argv, float *result); -int xtract_tristimulus_3(float *data, int N, void *argv, float *result); +int xtract_tristimulus_1(const float *data, const int N, const void *argv, float *result); +int xtract_tristimulus_2(const float *data, const int N, const void *argv, float *result); +int xtract_tristimulus_3(const float *data, const int N, const void *argv, float *result); /** \brief Extract the smoothness of an input vector using a method described by McAdams (1999) * * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector * \param N: the number of elements to be considered - * \param *argv: a pointer to NULL + * \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. * \param *result: the smoothness of N values from the array pointed to by *data */ -int xtract_smoothness(float *data, int N, void *argv, float *result); +int xtract_smoothness(const float *data, const int N, const void *argv, float *result); /** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005) * @@ -145,7 +145,7 @@ int xtract_smoothness(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the spectral spread of N values from the array pointed to by *data */ -int xtract_spread(float *data, int N, void *argv, float *result); +int xtract_spread(const float *data, const int N, const void *argv, float *result); /* Zero crossing rate */ @@ -156,7 +156,7 @@ int xtract_spread(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the zero crossing rate of N values from the array pointed to by *data */ -int xtract_zcr(float *data, int N, void *argv, float *result); +int xtract_zcr(const float *data, const int N, const void *argv, float *result); /** \brief Extract the spectral rolloff of an input vector using a method described by Bee Suan Ong (2005) * @@ -165,7 +165,7 @@ int xtract_zcr(float *data, int N, void *argv, float *result); * \param *argv: a pointer to an array containing a floating point value representing the threshold for rolloff, i.e. the percentile at which the rolloff is determined, expressed in the range 0-1.0, and a float representing the sample rate in Hz * \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. */ -int xtract_rolloff(float *data, int N, void *argv, float *result); +int xtract_rolloff(const float *data, const int N, const void *argv, float *result); /* Loudness */ /* A set of BARK_BANDS bark coefficients must be passed in, the loudness is calculated approximately according to Moore, Glasberg et al, 1997 */ @@ -177,7 +177,7 @@ int xtract_rolloff(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the loudness of N values from the array pointed to by *data */ -int xtract_loudness(float *data, int N, void *argv, float *result); +int xtract_loudness(const float *data, const int N, const void *argv, float *result); /** \brief Extract the spectral flatness measure of an input vector using a method described by Tristan Jehan (2005) * @@ -186,7 +186,7 @@ int xtract_loudness(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the spectral flatness of N values from the array pointed to by *data */ -int xtract_flatness(float *data, int N, void *argv, float *result); +int xtract_flatness(const float *data, const int N, const void *argv, float *result); /** \brief Extract the tonality factor of an input vector using a method described by Tristan Jehan (2005) @@ -196,7 +196,7 @@ int xtract_flatness(float *data, int N, void *argv, float *result); * \param *argv: a pointer to the spectral flatness measure of an audio vector (e.g. the output from xtract_flatness) * \param *result: the tonality factor of N values from the array pointed to by *data */ -int xtract_tonality(float *data, int N, void *argv, float *result); +int xtract_tonality(const float *data, const int N, const void *argv, float *result); /** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000) * @@ -205,7 +205,7 @@ int xtract_tonality(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the noisiness of N values from the array pointed to by *data */ -int xtract_noisiness(float *data, int N, void *argv, float *result); +int xtract_noisiness(const float *data, const int N, const void *argv, float *result); /** \brief Extract the RMS amplitude of an input vector using a method described by Tae Hong Park (2000) * @@ -214,7 +214,7 @@ int xtract_noisiness(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the RMS amplitude of N values from the array pointed to by *data */ -int xtract_rms_amplitude(float *data, int N, void *argv, float *result); +int xtract_rms_amplitude(const float *data, const int N, const void *argv, float *result); /** \brief Extract the Inharmonicity of an input vector * @@ -223,7 +223,7 @@ int xtract_rms_amplitude(float *data, int N, void *argv, float *result); * \param *argv: a pointer to a float representing the fundamental frequency of the input vector. * \param *result: the inharmonicity of N values from the array pointed to by *data */ -int xtract_inharmonicity(float *data, int N, void *argv, float *result); +int xtract_inharmonicity(const float *data, const int N, const void *argv, float *result); /** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003) * @@ -232,7 +232,7 @@ int xtract_inharmonicity(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the spectral crest of N values from the array pointed to by *data */ -int xtract_crest(float *data, int N, void *argv, float *result); +int xtract_crest(const float *data, const int N, const void *argv, float *result); /** \brief Extract the Spectral Power of an input vector using a method described by Bee Suan Ong (2005) * @@ -241,7 +241,7 @@ int xtract_crest(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the spectral power of N values from the array pointed to by *data */ -int xtract_power(float *data, int N, void *argv, float *result); +int xtract_power(const float *data, const int N, const void *argv, float *result); /* Odd to even harmonic ratio */ /** \brief Extract the Odd to even harmonic ratio of an input vector @@ -251,7 +251,7 @@ int xtract_power(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the odd/even harmonic ratio of N values from the array pointed to by *data */ -int xtract_odd_even_ratio(float *data, int N, void *argv, float *result); +int xtract_odd_even_ratio(const float *data, const int N, const void *argv, float *result); /** \brief Extract the Sharpness of an input vector * @@ -260,7 +260,7 @@ int xtract_odd_even_ratio(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the Sharpness of N values from the array pointed to by *data */ -int xtract_sharpness(float *data, int N, void *argv, float *result); +int xtract_sharpness(const float *data, const int N, const void *argv, float *result); /** \brief Extract the Slope of an input vector * @@ -269,17 +269,17 @@ int xtract_sharpness(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the Slope of N values from the array pointed to by *data */ -int xtract_slope(float *data, int N, void *argv, float *result); +int xtract_slope(const float *data, const int N, const void *argv, float *result); -/** \brief Extract the value of the first partial in an input vector that closely matches a certain 'guess' +/** \brief Extract the value of the lowest value in an input vector that between two bounds * - * \param *data: a pointer to the first element in an array of floats that represents the frequencies of the spectral peaks of an audio vector + * \param *data: a pointer to the first element in an array of floats * \param N: the number of elements to be considered - * \param *argv: a pointer to a float value representing the guess - * \param *result: the F0 of N values from the array pointed to by *data + * \param *argv: a pointer to an array containing a lower and upper bounds for search, where lower < n < upper. + * \param *result: a pointer to a value representing the lowest non-zero component in *data. If no match is found then -0 is returned. * - * This method takes a guess which can come from taking the ZCR of an autocorrelation function, and then finds the spectral peak that most closely matches the gess */ -int xtract_lowest_match(float *data, int N, void *argv, float *result); + */ +int xtract_lowest(const float *data, const int N, const void *argv, float *result); /** \brief Extract the Pitch of an input vector using Harmonic Product Spectrum (HPS) analysis * @@ -290,7 +290,7 @@ int xtract_lowest_match(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the pitch of N values from the array pointed to by *data */ -int xtract_hps(float *data, int N, void *argv, float *result); +int xtract_hps(const float *data, const int N, const void *argv, float *result); /** \brief Extract the fundamental frequency of an input vector * @@ -302,7 +302,19 @@ int xtract_hps(float *data, int N, void *argv, float *result); * 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 * */ -int xtract_f0(float *data, int N, void *argv, float *result); +int xtract_f0(const float *data, const int N, const void *argv, float *result); + +/** \brief Extract the fundamental frequency of an input vector + * + * \param *data: a pointer to the first element in an array of floats representing an audio vector + * \param N: the number of elements to be considered + * \param *argv: a pointer to a float representing the audio sample rate + * \param *result: the pitch of N values from the array pointed to by *data + * + * This function wraps xtract_f0, but provides the frequency of the lowest partial in the peak spectrum if f0 can't be found. + * + */ +int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result); /** @} */ diff --git a/xtract/xtract_vector.h b/xtract/xtract_vector.h index a8b0550..215c782 100644 --- a/xtract/xtract_vector.h +++ b/xtract/xtract_vector.h @@ -41,7 +41,7 @@ extern "C" { * \param *argv: a pointer to NULL * \param *result: the magnitude spectrum of N values from the array pointed to by *data */ -int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result); +int xtract_magnitude_spectrum(const float *data, const int N, const void *argv, float *result); /** \brief Extract autocorrelation from time domain signal using FFT based method * @@ -50,7 +50,7 @@ int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the autocorrelation of N values from the array pointed to by *data */ -int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result); +int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result); /** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner * @@ -61,7 +61,7 @@ int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result); * * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc */ -int xtract_mfcc(float *data, int N, void *argv, float *result); +int xtract_mfcc(const float *data, const int N, const void *argv, float *result); /** \brief Extract the Discrete Cosine transform of a time domain signal * \param *data: a pointer to the first element in an array of floats representing an audio vector @@ -69,7 +69,7 @@ int xtract_mfcc(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: a pointer to an array containing resultant dct coefficients */ -int xtract_dct(float *data, int N, void *argv, float *result); +int xtract_dct(const float *data, const int N, const void *argv, float *result); /** \brief Extract autocorrelation from time domain signal using time-domain autocorrelation technique * @@ -78,7 +78,7 @@ int xtract_dct(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the autocorrelation of N values from the array pointed to by *data */ -int xtract_autocorrelation(float *data, int N, void *argv, float *result); +int xtract_autocorrelation(const float *data, const int N, const void *argv, float *result); /** \brief Extract Average Magnitude Difference Function from time domain signal * @@ -87,7 +87,7 @@ int xtract_autocorrelation(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the AMDF of N values from the array pointed to by *data */ -int xtract_amdf(float *data, int N, void *argv, float *result); +int xtract_amdf(const float *data, const int N, const void *argv, float *result); /** \brief Extract Average Squared Difference Function from time domain signal * @@ -96,7 +96,7 @@ int xtract_amdf(float *data, int N, void *argv, float *result); * \param *argv: a pointer to NULL * \param *result: the ASDF of N values from the array pointed to by *data */ -int xtract_asdf(float *data, int N, void *argv, float *result); +int xtract_asdf(const float *data, const int N, const void *argv, float *result); /** \brief Extract Bark band coefficients based on a method * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector @@ -107,7 +107,7 @@ int xtract_asdf(float *data, int N, void *argv, float *result); * The limits array pointed to by *argv must be obtained by first calling xtract_init_bark * */ -int xtract_bark_coefficients(float *data, int N, void *argv, float *result); +int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result); /** \brief Extract the frequency and amplitude of spectral peaks from a magnitude spectrum * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector @@ -115,7 +115,7 @@ int xtract_bark_coefficients(float *data, int N, void *argv, float *result); * \param *argv: a pointer to an array containing peak threshold as percentage below max peak, and sample rate * \param *result: a pointer to an array of size N, containing N/2 freqs and N/2 amplitudes, amplitudes are on a decibel scale with dbFS = 0 */ -int xtract_peaks(float *data, int N, void *argv, float *result); +int xtract_peaks(const float *data, const int N, const void *argv, float *result); /** \brief Extract the harmonic spectrum of from a of a peak spectrum * \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 frequencies for each peak considered, and the the second half will contain the respective amplitudes @@ -123,7 +123,7 @@ int xtract_peaks(float *data, int N, void *argv, float *result); * \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. * \param *result: a pointer to an array of size N containing N/2 freqs and N/2 amplitudes, amplitudes are on a decibel scale with dbFS = 0 */ -int xtract_harmonics(float *data, int N, void *argv, float *result); +int xtract_harmonics(const float *data, const int N, const void *argv, float *result); /** @} */ |