diff options
Diffstat (limited to 'xtract')
-rw-r--r-- | xtract/libxtract.h | 35 | ||||
-rw-r--r-- | xtract/xtract_macros.h | 6 | ||||
-rw-r--r-- | xtract/xtract_scalar.h | 30 | ||||
-rw-r--r-- | xtract/xtract_vector.h | 16 |
4 files changed, 56 insertions, 31 deletions
diff --git a/xtract/libxtract.h b/xtract/libxtract.h index 43ccdac..51561cd 100644 --- a/xtract/libxtract.h +++ b/xtract/libxtract.h @@ -105,7 +105,7 @@ enum features_ { ASDF, BARK_COEFFICIENTS, PEAK_SPECTRUM, - MAGNITUDE_SPECTRUM, + SPECTRUM, AUTOCORRELATION_FFT, MFCC, DCT, @@ -135,6 +135,14 @@ enum return_codes_ { FEATURE_NOT_IMPLEMENTED }; +/** \brief Enumeration of spectrum types */ +enum spectrum_ { + MAGNITUDE_SPECTRUM, + LOG_MAGNITUDE_SPECTRUM, + POWER_SPECTRUM, + LOG_POWER_SPECTRUM +}; + /** \brief Enumeration of data types*/ typedef enum type_ { FLOAT, @@ -156,12 +164,27 @@ typedef enum { /** \brief Enumeration of vector format types*/ typedef enum vector_ { - MAGNITUDES, - FREQUENCIES, - FREQUENCIES_AND_MAGNITUDES, + /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */ + SPECTRAL, + /* N spectral amplitudes */ + SPECTRAL_MAGNITUDES, + /* N/2 magnitude/log-magnitude/power/log-power peak coeffs and N/2 + * frequencies */ + SPECTRAL_PEAKS, + /* N spectral peak amplitudes */ + SPECTRAL_PEAK_MAGNITUDES, + /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2 + * frequencies */ + SPECTRAL_HARMONICS, + /* N spectral harmonic amplitudes */ + SPECTRAL_HARMONICS_MAGNITUDES, + /* N spectral harmonic frequencies */ + SPECTRAL_HARMONICS_FREQUENCIES, + ARBITRARY_SERIES, + AUDIO_SAMPLES, + MEL_COEFFS, BARK_COEFFS, - MEL_COEFFS, - SAMPLES, + NO_DATA } t_vector; /** \brief Data structure containing useful information about functions provided by LibXtract. */ diff --git a/xtract/xtract_macros.h b/xtract/xtract_macros.h index 9e72a41..f3b85f2 100644 --- a/xtract/xtract_macros.h +++ b/xtract/xtract_macros.h @@ -37,9 +37,11 @@ extern "C" { #define NEEDS_FFTW printf("LibXtract must be compiled with fftw support to use this function.\n") #define CHECK_q if(!q) q = 44100.f / N -#define VERY_SMALL_NUMBER 1e-20 +#define VERY_SMALL_NUMBER 2e-42 #define LOG_LIMIT VERY_SMALL_NUMBER -#define VERY_BIG_NUMBER 1e20 +#define LOG_LIMIT_DB -96 +#define DB_SCALE_OFFSET 96 +#define VERY_BIG_NUMBER 2e42 #define SR_LIMIT 192000 #define BARK_BANDS 26 #define NONE 0 diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h index fd01ada..63aa6cd 100644 --- a/xtract/xtract_scalar.h +++ b/xtract/xtract_scalar.h @@ -157,7 +157,7 @@ int xtract_spectral_centroid(const float *data, const int N, const void *argv, /** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the irregularity of N values from the array pointed to by *data @@ -166,7 +166,7 @@ int xtract_irregularity_k(const float *data, const int N, const void *argv, floa /** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the irregularity of N values from the array pointed to by *data @@ -175,7 +175,7 @@ int xtract_irregularity_j(const float *data, const int N, const void *argv, floa /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982) * - * \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 second half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_peaks()) can be used if one wishes to consider all partials not just harmonics. + * \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_spectral_peaks()) can be used if one wishes to consider all partials not just harmonics. * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the tristimulus of N values from the array pointed to by *data @@ -189,7 +189,7 @@ int xtract_tristimulus_3(const float *data, const int N, const void *argv, float /** \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 coefficients from the magnitude spectrum of an audio vector, (e.g. the second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \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 @@ -198,7 +198,7 @@ int xtract_smoothness(const float *data, const int N, const void *argv, float *r /** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the spectral spread of N values from the array pointed to by *data @@ -218,7 +218,7 @@ 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) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \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. @@ -239,7 +239,7 @@ int xtract_loudness(const float *data, const int N, const void *argv, float *res /** \brief Extract the spectral flatness measure of an input vector using a method described by Tristan Jehan (2005) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the spectral flatness of N values from the array pointed to by *data @@ -258,7 +258,7 @@ int xtract_tonality(const float *data, const int N, const void *argv, float *res /** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the noisiness of N values from the array pointed to by *data @@ -276,7 +276,7 @@ int xtract_rms_amplitude(const float *data, const int N, const void *argv, float /** \brief Extract the Inharmonicity of an input vector * - * \param *data: a pointer to the first element in an array of floats represeting a frequency spectrum of size N/2 and a magnitude peak spectrum of size N/2 (This is the output format of xtract_peaks) + * \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_spectral_peaks()) * \param N: the number of elements to be considered * \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 @@ -285,7 +285,7 @@ int xtract_spectral_inharmonicity(const float *data, const int N, const void *ar /** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the spectral crest of N values from the array pointed to by *data @@ -294,7 +294,7 @@ 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) * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the spectral power of N values from the array pointed to by *data @@ -304,7 +304,7 @@ 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 * - * \param *data: a pointer to the first element in an array of floats representing the frequencies of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to the array pointed to by *result from xtract_harmonics. + * \param *data: a pointer to the first element in an array of floats representing the frequencies of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to the second half of the array pointed to by *result from xtract_harmonic_spectrum(). * \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 frequencies of the peaks. * \param *argv: a pointer to NULL * \param *result: the odd/even harmonic ratio of N values from the array pointed to by *data @@ -313,7 +313,7 @@ int xtract_odd_even_ratio(const float *data, const int N, const void *argv, floa /** \brief Extract the Sharpness of an input vector * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the Sharpness of N values from the array pointed to by *data @@ -322,7 +322,7 @@ int xtract_sharpness(const float *data, const int N, const void *argv, float *re /** \brief Extract the Slope of an input vector using a method described by Peeters(2003) * - * \param *data: a pointer to the first element in an array of floats representing a set of BARK_BANDS bark coefficients + * \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_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the Slope of N values from the array pointed to by *data @@ -363,7 +363,7 @@ int xtract_sum(const float *data, const int N, const void *argv, float *result); * * \warning {This function doesn't work properly} * - * \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 second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the pitch of N values from the array pointed to by *data diff --git a/xtract/xtract_vector.h b/xtract/xtract_vector.h index 388a0f2..26a7ff4 100644 --- a/xtract/xtract_vector.h +++ b/xtract/xtract_vector.h @@ -34,14 +34,14 @@ extern "C" { * @{ */ -/** \brief Extract normalized (0-1) frequency domain magnitude spectrum from time domain signal +/** \brief Extract normalized (0-1) frequency domain spectrum from time domain signal * * \param *data: a pointer to the first element in an array of floats representing an audio vector * \param N: the number of array elements to be considered - * \param *argv: a pointer to a float representing (samplerate / N) - * \param *result: a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies. + * \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. MAGNITUDE_SPECTRUM, LOG_POWER_SPECTRUM) + * \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. */ -int xtract_magnitude_spectrum(const float *data, const int N, const void *argv, float *result); +int xtract_spectrum(const float *data, const int N, const void *argv, float *result); /** \brief Extract autocorrelation from time domain signal using FFT based method * @@ -99,7 +99,7 @@ int xtract_amdf(const float *data, const int N, const 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 coefficients from the magnitude spectrum of an audio vector, (e.g. the second half of the array pointed to by *result from xtract_magnitude_spectrum(). + * \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(). * \param N: the number of array elements to be considered * \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. * \param *result: a pointer to an array containing resultant bark coefficients @@ -110,10 +110,10 @@ int xtract_asdf(const float *data, const int N, const void *argv, float *result) int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result); /** \brief Extract the amplitude and frequency of spectral peaks from a magnitude spectrum - * \param *data: a pointer to the first element in an array of floats representing N/2 magnitude coefficients from the magnitude spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_magnitude_spectrum(), or xtract_magnitudes(). - * \param N: the size of the output array (note: the input array can be of size N/2) + * \param *data: a pointer to an array of size N containing N/2 magnitude/power/log magnitude/log power coefficients and N/2 bin frequencies. (e.g. the first half of the array pointed to by *result from xtract_spectrum(). + * \param N: the size of the output array (note: the input array can be of size N/2, i.e. just the magnitudes) * \param *argv: a pointer to an array containing the peak threshold as percentage of the magnitude of the maximum peak found, and a float representing (samplerate / N) - * \param *result: a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies. + * \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. * */ |