[88199ce] | 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 | #define XTRACT_BARK_BANDS 26 |
---|
| 24 | #include "bark.c" |
---|
| 25 | |
---|
| 26 | int xtract_init_bark(int N, float sr, int *band_limits){ |
---|
| 27 | |
---|
| 28 | float edges[] = {0, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, 20500, 27000}; /* Takes us up to sr = 54kHz (CCRMA: JOS)*/ |
---|
| 29 | |
---|
| 30 | int bands = XTRACT_BARK_BANDS; |
---|
| 31 | |
---|
| 32 | while(bands--) |
---|
| 33 | band_limits[bands] = edges[bands] / sr * N; |
---|
| 34 | /*FIX shohuld use rounding, but couldn't get it to work */ |
---|
| 35 | |
---|
| 36 | return XTRACT_SUCCESS; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result){ |
---|
| 43 | |
---|
| 44 | int *limits, band, n; |
---|
| 45 | |
---|
| 46 | limits = (int *)argv; |
---|
| 47 | |
---|
| 48 | for(band = 0; band < XTRACT_BARK_BANDS - 1; band++){ |
---|
| 49 | for(n = limits[band]; n < limits[band + 1]; n++) |
---|
| 50 | result[band] += data[n]; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | return XTRACT_SUCCESS; |
---|
| 54 | } |
---|