source: src/mfcc.h @ 71d3bf0

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 71d3bf0 was 71d3bf0, checked in by Amaury Hazan <mahmoudax@gmail.com>, 17 years ago

small adds

  • 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#include "filterbank.h"
27
28//libXtract enums
29// TODO: remove them
30
31/** \brief Enumeration of feature initialisation functions */
32enum xtract_feature_init_ {
33    XTRACT_INIT_MFCC = 100,
34    XTRACT_INIT_BARK
35};
36
37/** \brief Enumeration of feature types */
38enum xtract_feature_types_ {
39    XTRACT_SCALAR,
40    XTRACT_VECTOR,
41    XTRACT_DELTA
42};
43
44/** \brief Enumeration of mfcc types */
45enum xtract_mfcc_types_ {
46    XTRACT_EQUAL_GAIN,
47    XTRACT_EQUAL_AREA
48};
49
50/** \brief Enumeration of return codes */
51enum xtract_return_codes_ {
52    XTRACT_SUCCESS,
53    XTRACT_MALLOC_FAILED,
54    XTRACT_BAD_ARGV,
55    XTRACT_BAD_VECTOR_SIZE,
56    XTRACT_NO_RESULT,
57    XTRACT_FEATURE_NOT_IMPLEMENTED
58};
59
60/** \brief Enumeration of spectrum types */
61enum xtract_spectrum_ {
62    XTRACT_MAGNITUDE_SPECTRUM,
63    XTRACT_LOG_MAGNITUDE_SPECTRUM,
64    XTRACT_POWER_SPECTRUM,
65    XTRACT_LOG_POWER_SPECTRUM
66};
67
68/** \brief Enumeration of data types*/
69typedef enum type_ {
70    XTRACT_FLOAT,
71    XTRACT_FLOATARRAY,
72    XTRACT_INT,
73    XTRACT_MEL_FILTER
74} xtract_type_t;
75
76/** \brief Enumeration of units*/
77typedef enum unit_ {
78    /* NONE, ANY */
79    XTRACT_HERTZ = 2,
80    XTRACT_ANY_AMPLITUDE_HERTZ,
81    XTRACT_DBFS,
82    XTRACT_DBFS_HERTZ,
83    XTRACT_PERCENT,
84    XTRACT_SONE
85} xtract_unit_t;
86
87/** \brief Boolean */
88typedef enum {
89    XTRACT_FALSE,
90    XTRACT_TRUE
91} xtract_bool_t;
92
93/** \brief Enumeration of vector format types*/
94typedef enum xtract_vector_ {
95    /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */
96    XTRACT_SPECTRAL,     
97    /* N spectral amplitudes */
98    XTRACT_SPECTRAL_MAGNITUDES, 
99    /* N/2 magnitude/log-magnitude/power/log-power peak coeffs and N/2
100     * frequencies */
101    XTRACT_SPECTRAL_PEAKS,
102    /* N spectral peak amplitudes */
103    XTRACT_SPECTRAL_PEAKS_MAGNITUDES,
104    /* N spectral peak frequencies */
105    XTRACT_SPECTRAL_PEAKS_FREQUENCIES,
106    /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2
107     * frequencies */
108    XTRACT_SPECTRAL_HARMONICS,
109    /* N spectral harmonic amplitudes */
110    XTRACT_SPECTRAL_HARMONICS_MAGNITUDES,
111    /* N spectral harmonic frequencies */
112    XTRACT_SPECTRAL_HARMONICS_FREQUENCIES,
113    XTRACT_ARBITRARY_SERIES,
114    XTRACT_AUDIO_SAMPLES,
115    XTRACT_MEL_COEFFS, 
116    XTRACT_BARK_COEFFS,
117    XTRACT_NO_DATA
118} xtract_vector_t;
119
120
121
122
123// Computation
124
125/** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner
126 *
127 * \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()
128 * \param N: the number of array elements to be considered
129 * \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
130 * \param *result: a pointer to an array containing the resultant MFCC
131 *
132 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
133 */
134int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result);
135
136/** \brief Extract the Discrete Cosine transform of a time domain signal
137 * \param *data: a pointer to the first element in an array of floats representing an audio vector
138 * \param N: the number of array elements to be considered
139 * \param *argv: a pointer to NULL
140 * \param *result: a pointer to an array containing resultant dct coefficients
141 */
142int aubio_dct_do(const float *data, const int N, const void *argv, float *result);
143
144
145#endif
Note: See TracBrowser for help on using the repository browser.