aboutsummaryrefslogtreecommitdiff
path: root/xtract
diff options
context:
space:
mode:
Diffstat (limited to 'xtract')
-rw-r--r--xtract/libxtract.h13
-rw-r--r--xtract/xtract_scalar.h26
-rw-r--r--xtract/xtract_vector.h8
3 files changed, 32 insertions, 15 deletions
diff --git a/xtract/libxtract.h b/xtract/libxtract.h
index 7249a94..b4808ba 100644
--- a/xtract/libxtract.h
+++ b/xtract/libxtract.h
@@ -53,7 +53,7 @@ extern "C" {
* @{
*/
-#define XTRACT_FEATURES 53
+#define XTRACT_FEATURES 54
/** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */
enum xtract_features_ {
@@ -93,6 +93,7 @@ enum xtract_features_ {
XTRACT_LOWEST_VALUE,
XTRACT_HIGHEST_VALUE,
XTRACT_SUM,
+ XTRACT_NONZERO_COUNT,
XTRACT_HPS,
XTRACT_F0,
XTRACT_FAILSAFE_F0,
@@ -184,7 +185,9 @@ typedef enum xtract_vector_ {
* frequencies */
XTRACT_SPECTRAL_PEAKS,
/* N spectral peak amplitudes */
- XTRACT_SPECTRAL_PEAK_MAGNITUDES,
+ XTRACT_SPECTRAL_PEAKS_MAGNITUDES,
+ /* N spectral peak frequencies */
+ XTRACT_SPECTRAL_PEAKS_FREQUENCIES,
/* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2
* frequencies */
XTRACT_SPECTRAL_HARMONICS,
@@ -313,8 +316,12 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq
/** \brief A function to initialise bark filter bounds
*
* A pointer to an array of BARK_BANDS ints most be passed in, and is populated with BARK_BANDS fft bin numbers representing the limits of each band
+ *
+ * \param N: the audio block size
+ * \param sr: The sample audio sample rate
+ * \param *band_limits: a pointer to an array of BARK_BANDS ints
*/
-int xtract_init_bark(int N, float nyquist, int *band_limits);
+int xtract_init_bark(int N, float sr, int *band_limits);
/* \brief A function to build an array of function descriptors */
void *xtract_make_descriptors();
diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h
index ee4323b..dc2e4ac 100644
--- a/xtract/xtract_scalar.h
+++ b/xtract/xtract_scalar.h
@@ -102,7 +102,7 @@ int xtract_spectral_mean(const float *data, const int N, const void *argv, float
* \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 *argv: a pointer to a float representing the spectral 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);
@@ -111,7 +111,7 @@ int xtract_spectral_variance(const float *data, const int N, const void *argv, f
*
* \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 *argv: a pointer to a float representing the spectral 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);
@@ -120,7 +120,7 @@ int xtract_spectral_standard_deviation(const float *data, const int N, const voi
*
* \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 *argv: a pointer to a float representing the spectral 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);
@@ -129,7 +129,7 @@ int xtract_spectral_average_deviation(const float *data, const int N, const void
*
* \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 *argv: a pointer to an array of floats representing the spectral mean and spectral 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);
@@ -138,7 +138,7 @@ int xtract_spectral_skewness(const float *data, const int N, const void *argv,
*
* \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 *argv: a pointer to an array of values representing the spectral mean and spectral 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);
@@ -304,9 +304,9 @@ 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 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 a float representing the fundamental frequency of the input vector.
+ * \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().
+ * \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.
+ * \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(const float *data, const int N, const void *argv, float *result);
@@ -394,6 +394,16 @@ int xtract_f0(const float *data, const int N, const void *argv, float *result);
*/
int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result);
+/** \brief Extract the number of non-zero elements in an input 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: not used
+ * \param *result: the number of non-zero elements in the array pointed to by *data
+ *
+ */
+int xtract_nonzero_count(const float *data, const int N, const void *argv, float *result);
+
/** @} */
#ifdef __cplusplus
diff --git a/xtract/xtract_vector.h b/xtract/xtract_vector.h
index a66e840..d93f953 100644
--- a/xtract/xtract_vector.h
+++ b/xtract/xtract_vector.h
@@ -38,7 +38,7 @@ 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 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 *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. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_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_spectrum(const float *data, const int N, const void *argv, float *result);
@@ -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 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 *data: a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param N: the size of the input array (note: it is assumed that enough memory has been allocated for an output array twice the size)
* \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found
- * \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.
+ * \param *result: a pointer to an array of size N * 2 containing N magnitude/power/log magnitude/log power coefficients and N bin frequencies.
*
*/
int xtract_peak_spectrum(const float *data, const int N, const void *argv, float *result);