source: src/mfcc.h @ dcc649c

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretchpitchshiftsamplertimestretchyinfft+
Last change on this file since dcc649c was dcc649c, checked in by Amaury Hazan <mahmoudax@gmail.org>, 13 years ago

minor changes

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2   Copyright (C) 2006 Amaury Hazan
3   Ported to aubio from LibXtract
4   http://libxtract.sourceforge.net/
5   
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2 of the License, or
10   (at your option) any later version.
11
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with this program; if not, write to the Free Software
19   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23#ifndef MFCC_H
24#define MFCC_H
25
26
27//libXtract enums
28// TODO: remove them
29
30/** \brief Enumeration of feature initialisation functions */
31enum xtract_feature_init_ {
32    XTRACT_INIT_MFCC = 100,
33    XTRACT_INIT_BARK
34};
35
36/** \brief Enumeration of feature types */
37enum xtract_feature_types_ {
38    XTRACT_SCALAR,
39    XTRACT_VECTOR,
40    XTRACT_DELTA
41};
42
43/** \brief Enumeration of mfcc types */
44enum xtract_mfcc_types_ {
45    XTRACT_EQUAL_GAIN,
46    XTRACT_EQUAL_AREA
47};
48
49/** \brief Enumeration of return codes */
50enum xtract_return_codes_ {
51    XTRACT_SUCCESS,
52    XTRACT_MALLOC_FAILED,
53    XTRACT_BAD_ARGV,
54    XTRACT_BAD_VECTOR_SIZE,
55    XTRACT_NO_RESULT,
56    XTRACT_FEATURE_NOT_IMPLEMENTED
57};
58
59/** \brief Enumeration of spectrum types */
60enum xtract_spectrum_ {
61    XTRACT_MAGNITUDE_SPECTRUM,
62    XTRACT_LOG_MAGNITUDE_SPECTRUM,
63    XTRACT_POWER_SPECTRUM,
64    XTRACT_LOG_POWER_SPECTRUM
65};
66
67/** \brief Enumeration of data types*/
68typedef enum type_ {
69    XTRACT_FLOAT,
70    XTRACT_FLOATARRAY,
71    XTRACT_INT,
72    XTRACT_MEL_FILTER
73} xtract_type_t;
74
75/** \brief Enumeration of units*/
76typedef enum unit_ {
77    /* NONE, ANY */
78    XTRACT_HERTZ = 2,
79    XTRACT_ANY_AMPLITUDE_HERTZ,
80    XTRACT_DBFS,
81    XTRACT_DBFS_HERTZ,
82    XTRACT_PERCENT,
83    XTRACT_SONE
84} xtract_unit_t;
85
86/** \brief Boolean */
87typedef enum {
88    XTRACT_FALSE,
89    XTRACT_TRUE
90} xtract_bool_t;
91
92/** \brief Enumeration of vector format types*/
93typedef enum xtract_vector_ {
94    /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */
95    XTRACT_SPECTRAL,     
96    /* N spectral amplitudes */
97    XTRACT_SPECTRAL_MAGNITUDES, 
98    /* N/2 magnitude/log-magnitude/power/log-power peak coeffs and N/2
99     * frequencies */
100    XTRACT_SPECTRAL_PEAKS,
101    /* N spectral peak amplitudes */
102    XTRACT_SPECTRAL_PEAKS_MAGNITUDES,
103    /* N spectral peak frequencies */
104    XTRACT_SPECTRAL_PEAKS_FREQUENCIES,
105    /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2
106     * frequencies */
107    XTRACT_SPECTRAL_HARMONICS,
108    /* N spectral harmonic amplitudes */
109    XTRACT_SPECTRAL_HARMONICS_MAGNITUDES,
110    /* N spectral harmonic frequencies */
111    XTRACT_SPECTRAL_HARMONICS_FREQUENCIES,
112    XTRACT_ARBITRARY_SERIES,
113    XTRACT_AUDIO_SAMPLES,
114    XTRACT_MEL_COEFFS, 
115    XTRACT_BARK_COEFFS,
116    XTRACT_NO_DATA
117} xtract_vector_t;
118
119
120
121
122// Computation
123
124/** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner
125 *
126 * \param *data: a pointer to the first element in an array of spectral magnitudes, e.g. the first half of the array pointed to by *resul from xtract_spectrum()
127 * \param N: the number of array elements to be considered
128 * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank
129 * \param *result: a pointer to an array containing the resultant MFCC
130 *
131 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
132 */
133int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result);
134
135/** \brief Extract the Discrete Cosine transform of a time domain signal
136 * \param *data: a pointer to the first element in an array of floats representing an audio vector
137 * \param N: the number of array elements to be considered
138 * \param *argv: a pointer to NULL
139 * \param *result: a pointer to an array containing resultant dct coefficients
140 */
141int aubio_dct_do(const float *data, const int N, const void *argv, float *result);
142
143
144#endif
Note: See TracBrowser for help on using the repository browser.