aboutsummaryrefslogtreecommitdiff
path: root/xtract
diff options
context:
space:
mode:
Diffstat (limited to 'xtract')
-rw-r--r--xtract/libxtract.h18
-rw-r--r--xtract/xtract_macros.h2
-rw-r--r--xtract/xtract_scalar.h67
-rw-r--r--xtract/xtract_vector.h23
4 files changed, 85 insertions, 25 deletions
diff --git a/xtract/libxtract.h b/xtract/libxtract.h
index c1bead7..43ccdac 100644
--- a/xtract/libxtract.h
+++ b/xtract/libxtract.h
@@ -53,7 +53,7 @@ extern "C" {
* @{
*/
-#define XTRACT_FEATURES 47
+#define XTRACT_FEATURES 53
/** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */
enum features_ {
@@ -63,7 +63,13 @@ enum features_ {
AVERAGE_DEVIATION,
SKEWNESS,
KURTOSIS,
- CENTROID,
+ SPECTRAL_MEAN,
+ SPECTRAL_VARIANCE,
+ SPECTRAL_STANDARD_DEVIATION,
+ SPECTRAL_AVERAGE_DEVIATION,
+ SPECTRAL_SKEWNESS,
+ SPECTRAL_KURTOSIS,
+ SPECTRAL_CENTROID,
IRREGULARITY_K,
IRREGULARITY_J,
TRISTIMULUS_1,
@@ -79,11 +85,11 @@ enum features_ {
CREST,
NOISINESS,
RMS_AMPLITUDE,
- INHARMONICITY,
+ SPECTRAL_INHARMONICITY,
POWER,
ODD_EVEN_RATIO,
SHARPNESS,
- SLOPE,
+ SPECTRAL_SLOPE,
LOWEST_VALUE,
HIGHEST_VALUE,
SUM,
@@ -98,12 +104,12 @@ enum features_ {
AMDF,
ASDF,
BARK_COEFFICIENTS,
- PEAKS,
+ PEAK_SPECTRUM,
MAGNITUDE_SPECTRUM,
AUTOCORRELATION_FFT,
MFCC,
DCT,
- HARMONICS
+ HARMONIC_SPECTRUM
};
/** \brief Enumeration of feature types */
diff --git a/xtract/xtract_macros.h b/xtract/xtract_macros.h
index ca8d924..9e72a41 100644
--- a/xtract/xtract_macros.h
+++ b/xtract/xtract_macros.h
@@ -35,7 +35,7 @@ extern "C" {
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define NEEDS_FFTW printf("LibXtract must be compiled with fftw support to use this function.\n")
-#define CHECK_SR if(!sr) sr = 44100.f
+#define CHECK_q if(!q) q = 44100.f / N
#define VERY_SMALL_NUMBER 1e-20
#define LOG_LIMIT VERY_SMALL_NUMBER
diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h
index 959d06a..fd01ada 100644
--- a/xtract/xtract_scalar.h
+++ b/xtract/xtract_scalar.h
@@ -36,7 +36,7 @@ extern "C" {
/** \brief Extract the mean of an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element
* \param N: the number of array elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the mean of N values from the array pointed to by *data
@@ -88,17 +88,72 @@ int xtract_skewness(const float *data, const int N, const void *argv, float *re
*/
int xtract_kurtosis(const float *data, const int N, const void *argv, float *result);
+/** \brief Extract the mean of an input spectrum
+ *
+ * \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 size of the array pointed to by *data
+ * \param *argv: a pointer to NULL
+ * \param *result: the mean of the spectrum pointed to by *data
+ */
+int xtract_spectral_mean(const float *data, const int N, const void *argv, float *result);
+
+/** \brief Extract the variance of an input spectrum
+ *
+ * \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 N: the size of the array pointed to by *data
+ * \param *argv: a pointer to a float representing the mean of the input spectrum
+ * \param *result: the variance of the spectrum pointed to by *data
+ */
+int xtract_spectral_variance(const float *data, const int N, const void *argv, float *result);
+
+/** \brief Extract the deviation of an input spectrum
+ *
+ * \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 size of the array pointed to by *data
+ * \param *argv: a pointer to a float representing the variance of the input spectrum
+ * \param *result: the deviation of the spectrum pointed to by *data
+ */
+int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result);
+
+/** \brief Extract the average deviation of an input spectrum
+ *
+ * \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 size of the array pointed to by *data
+ * \param *argv: a pointer to a float representing the mean of the input spectrum
+ * \param *result: the average deviation of the spectrum pointed to by *data
+ */
+int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result);
+
+/** \brief Extract the skewness of an input spectrum
+ *
+ * \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 size of the array pointed to by *data
+ * \param *argv: a pointer to an array of floats representing the mean and standard deviation of the input spectrum
+ * \param *result: the skewness of the spectrum pointed to by *data
+ */
+int xtract_spectral_skewness(const float *data, const int N, const void *argv, float *result);
+
+/** \brief Extract the kurtosis of an input spectrum
+ *
+ * \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 size of the array pointed to by *data
+ * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input spectrum
+ * \param *result: the kurtosis of the spectrum pointed to by *data
+ */
+int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, float *result);
+
/** \brief Extract the centroid of an input vector
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector, (e.g. 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 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 centroid of the values pointed to by *data
*
- * Note: for a more 'accurate' result *result from xtract_peaks() can be passed in. This gives the interpolated peak frequency locations.
+ * Note: for a more 'accurate' result *result from xtract_spectral_peaks() can be passed in. This gives the interpolated peak frequency locations.
*
*/
-int xtract_centroid(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_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)
*
@@ -226,7 +281,7 @@ int xtract_rms_amplitude(const float *data, const int N, const void *argv, float
* \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(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_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)
*
@@ -272,7 +327,7 @@ int xtract_sharpness(const float *data, const int N, const void *argv, float *re
* \param *argv: a pointer to NULL
* \param *result: the Slope of N values from the array pointed to by *data
*/
-int xtract_slope(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_slope(const float *data, const int N, const void *argv, float *result);
/** \brief Extract the value of the lowest value in an input vector
*
diff --git a/xtract/xtract_vector.h b/xtract/xtract_vector.h
index 21947c5..388a0f2 100644
--- a/xtract/xtract_vector.h
+++ b/xtract/xtract_vector.h
@@ -38,9 +38,8 @@ extern "C" {
*
* \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 the sample rate of the audio
- * \param *result: a pointer to an array containing N/2 bin frequencies, and N/2
- * magnitude coefficients.
+ * \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.
*/
int xtract_magnitude_spectrum(const float *data, const int N, const void *argv, float *result);
@@ -110,23 +109,23 @@ 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 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 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 N: the number of array elements to be considered
- * \param *argv: a pointer to an array containing the peak threshold as percentage of the magnitude of the maximum peak found, and the sample rate in Hz.
- * \param *result: a pointer to an array of size N, containing N/2 freqs and N/2 amplitudes
+/** \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 *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.
*
*/
-int xtract_peaks(const float *data, const int N, const void *argv, float *result);
+int xtract_peak_spectrum(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
+ * \param *data: a pointer to the first element in an array of floats representing the peak spectrum of an audio vector (e.g. *result from xtract_peaks). It is expected that the first half of the array pointed to by *data will contain amplitudes for each peak considered, and the the second half will contain the respective frequencies
* \param N: the size of the array pointed to by *data
* \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.
+ * \param *result: a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies.
*/
-int xtract_harmonics(const float *data, const int N, const void *argv, float *result);
+int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, float *result);
/** @} */