diff options
-rw-r--r-- | configure.in | 6 | ||||
-rw-r--r-- | examples/puredata/xtract~.c | 2 | ||||
-rw-r--r-- | src/descriptors.c | 94 | ||||
-rw-r--r-- | src/libxtract.c | 2 | ||||
-rw-r--r-- | src/scalar.c | 2 | ||||
-rw-r--r-- | src/vector.c | 64 | ||||
-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 |
10 files changed, 203 insertions, 54 deletions
diff --git a/configure.in b/configure.in index d999d8d..2e8ef17 100644 --- a/configure.in +++ b/configure.in @@ -64,7 +64,7 @@ AC_ARG_ENABLE(simpletest, # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -std=c99" +CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, @@ -132,7 +132,7 @@ AC_ARG_ENABLE(debug, if test "$with_debug" = "yes" then AC_DEFINE(DEBUG,1,[Define to enable debug]) - CFLAGS="-O0 -ggdb -g -pedantic -ansi -Wall" + CFLAGS="$CFLAGS -O0 -ggdb -g" fi dnl ------------------------------------------ @@ -164,7 +164,7 @@ else case $host in *86-*-linux*) - PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes" + PD_CFLAGS="$PD_CFLAGS -DUNIX -Wall -Wimplicit -Wunused" PD_LDFLAGS="$PD_LDFLAGS -shared -export_dynamic" dnl we could test for bad glibc here, but don't PD_SUFFIX=pd_linux diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c index 54b0bf8..a1fdb76 100644 --- a/examples/puredata/xtract~.c +++ b/examples/puredata/xtract~.c @@ -194,7 +194,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { if(x->feature == AUTOCORRELATION || x->feature == AUTOCORRELATION_FFT || x->feature == MFCC || x->feature == AMDF || x->feature == ASDF|| x->feature == DCT || x->feature == BARK_COEFFICIENTS || - x->feature == MAGNITUDE_SPECTRUM || x->feature == PEAK_SPECTRUM || + x->feature == SPECTRUM || x->feature == PEAK_SPECTRUM || x->feature == HARMONIC_SPECTRUM) x->feature_type = VECTOR; diff --git a/src/descriptors.c b/src/descriptors.c index abd5d15..e47ccdf 100644 --- a/src/descriptors.c +++ b/src/descriptors.c @@ -30,6 +30,8 @@ void *xtract_make_descriptors(){ int f , F; char *name, *p_name, *desc, *p_desc, *author; int *argc, *year; + t_vector *data_format; + /* *result_format; */ f = F = XTRACT_FEATURES; @@ -54,7 +56,6 @@ void *xtract_make_descriptors(){ case SPECTRAL_AVERAGE_DEVIATION: case ROLLOFF: case SPECTRAL_INHARMONICITY: - case MAGNITUDE_SPECTRUM: case ODD_EVEN_RATIO: case LOWEST_VALUE: case F0: @@ -67,6 +68,7 @@ void *xtract_make_descriptors(){ case KURTOSIS: case SPECTRAL_SKEWNESS: case SPECTRAL_KURTOSIS: + case SPECTRUM: case PEAK_SPECTRUM: case HARMONIC_SPECTRUM: case NOISINESS: @@ -116,6 +118,86 @@ void *xtract_make_descriptors(){ break; } + data_format = &d->data.format; + + switch(f){ + + case MEAN: + case VARIANCE: + case STANDARD_DEVIATION: + case AVERAGE_DEVIATION: + case SKEWNESS: + case KURTOSIS: + case LOWEST_VALUE: + case HIGHEST_VALUE: + case SUM: + case ZCR: + *data_format = ARBITRARY_SERIES; + break; + case SPECTRAL_MEAN: + case SPECTRAL_VARIANCE: + case SPECTRAL_STANDARD_DEVIATION: + case SPECTRAL_AVERAGE_DEVIATION: + case SPECTRAL_SKEWNESS: + case SPECTRAL_KURTOSIS: + case SPECTRAL_CENTROID: + case SPECTRAL_SLOPE: + case PEAK_SPECTRUM: + case HARMONIC_SPECTRUM: + *data_format = SPECTRAL; + break; + case ROLLOFF: + case NOISINESS: + case BARK_COEFFICIENTS: + case CREST: + case IRREGULARITY_K: + case IRREGULARITY_J: + case SMOOTHNESS: + case FLATNESS: + case SPREAD: + case RMS_AMPLITUDE: + case POWER: + case SHARPNESS: + case HPS: + *data_format = SPECTRAL_MAGNITUDES; + break; + case SPECTRAL_INHARMONICITY: + *data_format = SPECTRAL_PEAKS; + break; + case ODD_EVEN_RATIO: + *data_format = SPECTRAL_HARMONICS_FREQUENCIES; + break; + case F0: + case FAILSAFE_F0: + case SPECTRUM: + case MFCC: + case AUTOCORRELATION: + case AUTOCORRELATION_FFT: + case DCT: + case AMDF: + case ASDF: + *data_format = AUDIO_SAMPLES; + break; + case TONALITY: + *data_format = NO_DATA; + break; + case TRISTIMULUS_1: + case TRISTIMULUS_2: + case TRISTIMULUS_3: + *data_format = SPECTRAL_HARMONICS_MAGNITUDES; + break; + case LOUDNESS: + *data_format = BARK_COEFFS; + break; + case FLUX: + case ATTACK_TIME: + case DECAY_TIME: + case DELTA_FEATURE: + default: + *data_format = NO_DATA; + break; + } + name = d->algo.name; p_name = d->algo.p_name; desc = d->algo.desc; @@ -207,13 +289,13 @@ void *xtract_make_descriptors(){ strcpy(p_desc, "Extract the inharmonicity of an audio spectrum"); break; - case MAGNITUDE_SPECTRUM: - strcpy(name, "magnitude_spectrum"); - strcpy(p_name, "Magnitude Spectrum"); + case SPECTRUM: + strcpy(name, "spectrum"); + strcpy(p_name, "Spectrum"); strcpy(desc, - "Extract the magnitude spectrum of an input vector"); + "Extract the spectrum of an input vector"); strcpy(p_desc, - "Extract the magnitude spectrum of an audio signal"); + "Extract the spectrum of an audio signal"); strcpy(author, ""); break; case ODD_EVEN_RATIO: diff --git a/src/libxtract.c b/src/libxtract.c index b39f018..48fc2ab 100644 --- a/src/libxtract.c +++ b/src/libxtract.c @@ -74,7 +74,7 @@ int(*xtract[])(const float *, const int, const void *, float *) = { xtract_asdf, xtract_bark_coefficients, xtract_peak_spectrum, - xtract_magnitude_spectrum, + xtract_spectrum, xtract_autocorrelation_fft, xtract_mfcc, xtract_dct, diff --git a/src/scalar.c b/src/scalar.c index 9b6d9f3..6e7faeb 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -778,7 +778,7 @@ int xtract_failsafe_f0(const float *data, const int N, const void *argv, float * magnitudes = (float *)malloc(N * sizeof(float)); peaks = (float *)malloc(N * sizeof(float)); - xtract_magnitude_spectrum(data, N, argv, magnitudes); + xtract_spectrum(data, N, argv, magnitudes); argf[0] = 10.f; argf[1] = *(float *)argv; xtract_peak_spectrum(magnitudes, N, argf, peaks); diff --git a/src/vector.c b/src/vector.c index c19046e..c4135cb 100644 --- a/src/vector.c +++ b/src/vector.c @@ -30,35 +30,77 @@ #include <fftw3.h> -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){ - float *temp, *input, q; + float *input, *rfft, q, temp; size_t bytes; - int n , M = N >> 1; + int n , NxN, M, vector; fftwf_plan plan; - temp = (float *)fftwf_malloc(N * sizeof(float)); + M = N >> 1; + NxN = SQ(N); + + rfft = (float *)fftwf_malloc(N * sizeof(float)); input = (float *)malloc(bytes = N * sizeof(float)); input = memcpy(input, data, bytes); q = *(float *)argv; + vector = (int)*((float *)argv+1); CHECK_q; - plan = fftwf_plan_r2r_1d(N, input, temp, FFTW_R2HC, FFTW_ESTIMATE); + plan = fftwf_plan_r2r_1d(N, input, rfft, FFTW_R2HC, FFTW_ESTIMATE); fftwf_execute(plan); - - for(n = 1; n < M; n++){ - result[n] = sqrt(SQ(temp[n]) + SQ(temp[N - n])) / N; - result[M + n] = n * q; + + switch(vector){ + case MAGNITUDE_SPECTRUM: + for(n = 0; n < M; n++){ + result[n] = sqrt(SQ(rfft[n]) + SQ(rfft[N - n])) / N; + result[M + n] = n * q; + } + break; + case LOG_MAGNITUDE_SPECTRUM: + for(n = 0; n < M; n++){ + if ((temp = SQ(rfft[n]) + SQ(rfft[N - n])) > LOG_LIMIT) + temp = log(sqrt(temp) / N); + else + temp = LOG_LIMIT_DB; + /*Normalise*/ + result[n] = (temp + DB_SCALE_OFFSET) / DB_SCALE_OFFSET; + result[M + n] = n * q; + } + break; + case POWER_SPECTRUM: + for(n = 0; n < M; n++){ + result[n] = (SQ(rfft[n]) + SQ(rfft[N - n])) / NxN; + result[M + n] = n * q; + } + break; + case LOG_POWER_SPECTRUM: + for(n = 0; n < M; n++){ + if ((temp = SQ(rfft[n]) + SQ(rfft[N - n])) > LOG_LIMIT) + temp = log(temp / NxN); + else + temp = LOG_LIMIT_DB; + result[n] = (temp + DB_SCALE_OFFSET) / DB_SCALE_OFFSET; + result[M + n] = n * q; + } + break; + default: + /* MAGNITUDE_SPECTRUM */ + for(n = 0; n < M; n++){ + result[n] = sqrt(SQ(rfft[n]) + SQ(rfft[N - n])) / N; + result[M + n] = n * q; + } + break; } - result[0] = fabs(temp[0]) / N; + /* result[0] = fabs(temp[0]) / N */ result[M] = q * .5; fftwf_destroy_plan(plan); - fftwf_free(temp); + fftwf_free(rfft); free(input); return SUCCESS; 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. * */ |