diff options
Diffstat (limited to 'xtract')
-rw-r--r-- | xtract/Makefile.am | 2 | ||||
-rw-r--r-- | xtract/libxtract.h | 35 | ||||
-rw-r--r-- | xtract/xtract_helper.h | 72 |
3 files changed, 106 insertions, 3 deletions
diff --git a/xtract/Makefile.am b/xtract/Makefile.am index eca7030..ad79356 100644 --- a/xtract/Makefile.am +++ b/xtract/Makefile.am @@ -3,5 +3,5 @@ MAINTAINERCLEANFILES = Makefile.in libxtractdir = $(includedir)/xtract libxtract_HEADERS = libxtract.h xtract_macros.h xtract_types.h xtract_delta.h \ - xtract_scalar.h xtract_vector.h + xtract_scalar.h xtract_vector.h xtract_helper.h diff --git a/xtract/libxtract.h b/xtract/libxtract.h index b540c6a..1b787b0 100644 --- a/xtract/libxtract.h +++ b/xtract/libxtract.h @@ -60,6 +60,7 @@ extern "C" { #include "xtract_delta.h" #include "xtract_types.h" #include "xtract_macros.h" +#include "xtract_helper.h" /** \defgroup libxtract API * @@ -67,7 +68,7 @@ extern "C" { * @{ */ -#define XTRACT_FEATURES 57 +#define XTRACT_FEATURES 58 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ enum xtract_features_ { @@ -127,7 +128,9 @@ enum xtract_features_ { XTRACT_DCT, XTRACT_HARMONIC_SPECTRUM, XTRACT_LPC, - XTRACT_LPCC + XTRACT_LPCC, + /* Helper functions */ + XTRACT_WINDOWED }; /** \brief Enumeration of feature initialisation functions */ @@ -197,6 +200,19 @@ typedef enum { XTRACT_TRUE } xtract_bool_t; +/** \brief Window types */ +enum xtract_window_types_ { + XTRACT_GAUSS, + XTRACT_HAMMING, + XTRACT_HANN, + XTRACT_BARTLETT, + XTRACT_TRIANGULAR, + XTRACT_BARTLETT_HANN, + XTRACT_BLACKMAN, + XTRACT_KAISER, + XTRACT_BLACKMAN_HARRIS +}; + /** \brief Enumeration of vector format types*/ typedef enum xtract_vector_ { /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */ @@ -359,6 +375,21 @@ int xtract_init_bark(int N, float sr, int *band_limits); */ int xtract_init_fft(int N, int feature_name); +/** \brief Make a window of a given type and return a pointer to it + * + * \param N: the size of the window + * \param type: the type of the window as given in the enumeration window_types_ + * + */ +float *xtract_init_window(const int N, const int type); + +/** \brief Free a window as allocated by xtract_make_window() + * + * \param *window: a pointer to an array of floats as allocated by xtract_make_window() + * + */ +void xtract_free_window(float *window); + /* \brief A function to build an array of function descriptors */ void *xtract_make_descriptors(); diff --git a/xtract/xtract_helper.h b/xtract/xtract_helper.h new file mode 100644 index 0000000..31a2183 --- /dev/null +++ b/xtract/xtract_helper.h @@ -0,0 +1,72 @@ +/* libxtract feature extraction library + * + * Copyright (C) 2006 Jamie Bullock + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +/** \file xtract_helper.h: helper functions for making life with libxtract a bit more bearable */ + +#ifndef XTRACT_HELPER_H +#define XTRACT_HELPER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \defgroup helper helper functions + * + * Declares helper functions, and their parameters. + * + * \note These functions don't necessarily conform to the prototype used in xtract_scalar.h and xtract_vector.h etc, and as such are intended to be called 'directly' rather than via the xtract[] function pointer array (libxtract.h) + * + * @{ + */ + +/** \brief Apply a window function to an array of length N + * + * \param *data a pointer to an array of floats + * \param N the number of elements in the array pointed to by *data + * \param *argv a pointer to a window function as returned by xtract_make_window() + * \param *result a pointer to the first element an array containing the windowed data + * + * It is up to the caller to generate and free the array containing the window, and to allocate and free memory of size N to hold the data pointed to by *result + * + */ +int xtract_windowed(const float *data, const int N, const void *argv, float *result); + +/** \brief Divides the array pointed to by *data into two subframes, and applies a given feature to each subframe, returning them in a single array pointed to by result + * + * \param *data an array of floats + * \param N the number of elements in the array pointed by *data + * \param feature an integer representing the feature to be applied to each subframe in data. This will be a value as given in the enumeration xtract_features_ (libxtract.h) + * \param *argv a pointer to the argument vector to be passed to the feature extraction function as determined by feature + * \param *result a pointer to the 'packed' results of the feature calculation. This may be passed in as *data to xtract_features_from_subframes() to calculate further features on the subframes, or xtract_difference_vector(), to get the difference between the subframes. + * + */ +int xtract_features_from_subframes(const float *data, const int N, const int feature, const void *argv, float *result); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif + + + |