Thread: [Libxtract-commits] SF.net SVN: libxtract: [106] trunk (Page 2)
Status: Alpha
Brought to you by:
postlude
From: <pos...@us...> - 2007-12-21 11:05:50
|
Revision: 106 http://libxtract.svn.sourceforge.net/libxtract/?rev=106&view=rev Author: postlude Date: 2007-12-21 03:05:20 -0800 (Fri, 21 Dec 2007) Log Message: ----------- - Added some previously uncommitted Pd testing examples - Improved python bindings. Now we can do vector features as well as scalar from Python Modified Paths: -------------- trunk/configure.in trunk/swig/python/test.py trunk/swig/xtract.i Added Paths: ----------- trunk/examples/puredata/simple-test.pd trunk/examples/puredata/spectrum-512-test.pd Removed Paths: ------------- trunk/swig/python/xtract.i Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-10-16 09:37:06 UTC (rev 105) +++ trunk/configure.in 2007-12-21 11:05:20 UTC (rev 106) @@ -162,11 +162,6 @@ esac],[swig=false]) -dnl SWIG stuff -if [[ "$swig" = "true" ]] ; then - AC_PROG_SWIG(1.3.21) - AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) -fi if [[ "$with_java" = "true" ]] ; then if test "$JAVAC" = "" @@ -194,6 +189,12 @@ AM_CONDITIONAL(BUILD_SWIG, test "x${swig}" = 'xtrue') +dnl SWIG stuff +if [[ "$swig" = "true" ]] ; then + AC_PROG_SWIG(1.3.21) + AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) +fi + dnl Are we building with fftw? if [[ "$fft" = "true" ]] ; then LDFLAGS="$LDFLAGS -lfftw3f" Added: trunk/examples/puredata/simple-test.pd =================================================================== --- trunk/examples/puredata/simple-test.pd (rev 0) +++ trunk/examples/puredata/simple-test.pd 2007-12-21 11:05:20 UTC (rev 106) @@ -0,0 +1,11 @@ +#N canvas 642 248 670 289 10; +#X obj 192 63 osc~ 440; +#X floatatom 194 187 10 0 0 0 - - -; +#X obj 194 150 xtract~ spectral_mean; +#X obj 193 94 *~ 0.3; +#X text 337 121 Optional second argument gives blocksize; +#X obj 193 121 xtract~ spectrum 64; +#X connect 0 0 3 0; +#X connect 2 0 1 0; +#X connect 3 0 5 0; +#X connect 5 0 2 0; Added: trunk/examples/puredata/spectrum-512-test.pd =================================================================== --- trunk/examples/puredata/spectrum-512-test.pd (rev 0) +++ trunk/examples/puredata/spectrum-512-test.pd 2007-12-21 11:05:20 UTC (rev 106) @@ -0,0 +1,8 @@ +#N canvas 5 48 450 300 10; +#X obj 127 77 noise~; +#X obj 262 59 loadbang; +#X msg 262 86 list 86.1328; +#X obj 127 112 xtract~ spectrum 64; +#X connect 0 0 3 0; +#X connect 1 0 2 0; +#X connect 2 0 3 1; Modified: trunk/swig/python/test.py =================================================================== --- trunk/swig/python/test.py 2007-10-16 09:37:06 UTC (rev 105) +++ trunk/swig/python/test.py 2007-12-21 11:05:20 UTC (rev 106) @@ -3,11 +3,11 @@ try: import xtract except ImportError: - print 'Failed to load the library "jxtract"' + print 'Failed to load the library "xtract"' print '\nRunning libxtract Python bindings test...\n' -len = 5 +len = 8 a = xtract.floatArray(len) temp = [] @@ -19,4 +19,19 @@ print 'The mean of ' + ', '.join(temp) + ' is: %.2f' % \ xtract.xtract_mean(a,len,None)[1] +print 'Computing spectrum...' + +argv = xtract.floatArray(1) +argv[0] = 44100.0 / len # Fake sample rate + +xtract.xtract_init_fft(len, xtract.XTRACT_SPECTRUM); + +result = xtract.floatArray(len) + +xtract.xtract_spectrum(a,len,argv, result) + + +for i in range(len): + print result[i] + print '\nFinished!\n' Deleted: trunk/swig/python/xtract.i =================================================================== --- trunk/swig/python/xtract.i 2007-10-16 09:37:06 UTC (rev 105) +++ trunk/swig/python/xtract.i 2007-12-21 11:05:20 UTC (rev 106) @@ -1,12 +0,0 @@ -%module xtract -%include carrays.i -%include typemaps.i - -%{ -#include "xtract/xtract_scalar.h" -%} - -%array_functions(float, floatArray); -%apply float *OUTPUT { float *result }; - -%include "xtract/xtract_scalar.h" Modified: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i 2007-10-16 09:37:06 UTC (rev 105) +++ trunk/swig/xtract.i 2007-12-21 11:05:20 UTC (rev 106) @@ -4,10 +4,19 @@ %{ #include "xtract/xtract_scalar.h" +#include "xtract/xtract_vector.h" +#include "xtract/libxtract.h" %} %array_class(float, floatArray); %apply float *OUTPUT { float *result }; /* %apply float *INPUT { float *data }; */ +%ignore xtract; + %include "xtract/xtract_scalar.h" + +%clear float *result; + +%include "xtract/xtract_vector.h" +%include "xtract/libxtract.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-12-24 13:21:17
|
Revision: 107 http://libxtract.svn.sourceforge.net/libxtract/?rev=107&view=rev Author: postlude Date: 2007-12-24 05:21:13 -0800 (Mon, 24 Dec 2007) Log Message: ----------- - Fixes to descriptors.c where no break statement was given for certain cases is switch conditionals - Added LPC and LPCC extraction functions. LPC implements Durbin method as described in Rabiner and Juang and implemented in Dr. Dobbs 1994 edition by Jutta Degener Modified Paths: -------------- trunk/TODO trunk/examples/puredata/xtract~.c trunk/src/descriptors.c trunk/src/libxtract.c trunk/src/vector.c trunk/xtract/libxtract.h trunk/xtract/xtract_vector.h Added Paths: ----------- trunk/examples/puredata/lpcc-test.pd Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-12-21 11:05:20 UTC (rev 106) +++ trunk/TODO 2007-12-24 13:21:13 UTC (rev 107) @@ -13,3 +13,5 @@ ...do other stuff and eventually... ...optimise! Use the fftw guru interface to create multipurpose global plans from xtract_fft_init() +Add LPC via Schur algorithm +If argv uses an integer, then it should point to a variable of type int. At the moment floats are used to store ints. Added: trunk/examples/puredata/lpcc-test.pd =================================================================== --- trunk/examples/puredata/lpcc-test.pd (rev 0) +++ trunk/examples/puredata/lpcc-test.pd 2007-12-24 13:21:13 UTC (rev 107) @@ -0,0 +1,57 @@ +#N canvas 356 233 722 300 10; +#X obj 160 170 xtract~ autocorrelation; +#N canvas 0 0 450 300 graph1 0; +#X array lpcc 16 float 5; +#A 0 0 0 -0.827113 -0.827113 -0.827113 -0.485055 0.314974 0.657032 +0.810476 0.396513 0.0440753 -0.630112 -0.9456 -0.887411 -1.12995 0.596854 +; +#X coords 0 16 15 -16 200 140 1; +#X restore 458 97 graph; +#X obj 149 34 noise~; +#N canvas 9 103 450 300 lpc 0; +#X obj 323 25 block~ 32; +#X obj 140 52 inlet~; +#X obj 140 113 xtract~ lpc; +#N canvas 237 125 450 300 lpcc 0; +#X obj 26 130 xtract~ lpcc; +#N canvas 0 0 450 300 graph1 0; +#X array lpc 16 float 5; +#A 0 -1.03207 -1.03207 -1.03207 -21.8757 -21.8757 -21.8757 -21.8757 +-0.391539 -0.391539 -0.391539 -0.391539 0.448536 0.448536 0.448536 +0.448536 0.516603; +#X coords 0 16 15 -16 200 140 1; +#X restore 219 37 graph; +#X obj 23 12 block~ 16; +#X obj 26 51 tabreceive~ lpc; +#X msg 95 107 list 16; +#X obj 24 196 tabsend~ lpcc; +#X obj 95 85 loadbang; +#X connect 0 0 5 0; +#X connect 3 0 0 0; +#X connect 4 0 0 1; +#X connect 6 0 4 0; +#X restore 298 172 pd lpcc; +#X obj 137 220 tabsend~ lpc; +#X obj 139 152 a_blockswap~ 32; +#X connect 1 0 2 0; +#X connect 2 0 5 0; +#X connect 5 0 4 0; +#X restore 160 218 pd lpc; +#X obj 31 52 a_hann 16; +#X obj 31 25 loadbang; +#X obj 98 23 bng 15 250 50 0 empty empty empty 0 -6 0 10 -262144 -1 +-1; +#X obj 156 139 *~; +#X obj 27 -41 block~ 16 4; +#X obj 265 81 *~ 0.4; +#X obj 148 87 *~ 0.1; +#X obj 266 46 osc~ 1000; +#X connect 0 0 3 0; +#X connect 2 0 10 0; +#X connect 4 0 7 0; +#X connect 5 0 4 0; +#X connect 6 0 4 0; +#X connect 7 0 0 0; +#X connect 9 0 7 1; +#X connect 10 0 7 1; +#X connect 11 0 9 0; Modified: trunk/examples/puredata/xtract~.c =================================================================== --- trunk/examples/puredata/xtract~.c 2007-12-21 11:05:20 UTC (rev 106) +++ trunk/examples/puredata/xtract~.c 2007-12-24 13:21:13 UTC (rev 107) @@ -93,7 +93,7 @@ tmp_in = copybytes(in, N * sizeof(t_float)); tmp_out = getbytes(N * sizeof(t_float)); - if(x->feature == XTRACT_PEAK_SPECTRUM) + if(x->feature == XTRACT_PEAK_SPECTRUM || x->feature == XTRACT_LPC) N >>= 1; return_code = xtract[x->feature](tmp_in, N, x->argv, tmp_out); @@ -239,7 +239,9 @@ x->feature == XTRACT_BARK_COEFFICIENTS || x->feature == XTRACT_SPECTRUM || x->feature == XTRACT_PEAK_SPECTRUM || - x->feature == XTRACT_HARMONIC_SPECTRUM) + x->feature == XTRACT_HARMONIC_SPECTRUM || + x->feature == XTRACT_LPC || + x->feature == XTRACT_LPCC) x->feature_type = XTRACT_VECTOR; else if (x->feature == XTRACT_FLUX || x->feature == XTRACT_ATTACK_TIME || @@ -273,8 +275,8 @@ x->argv = getbytes(argc * sizeof(float)); - while(argc--) - ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); + while(argc--) + ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); /* }*/ } Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2007-12-21 11:05:20 UTC (rev 106) +++ trunk/src/descriptors.c 2007-12-24 13:21:13 UTC (rev 107) @@ -137,21 +137,26 @@ case XTRACT_LOWEST_VALUE: case XTRACT_TONALITY: case XTRACT_MFCC: + case XTRACT_LPC: + case XTRACT_LPCC: *argv_min = XTRACT_ANY; *argv_max = XTRACT_ANY; *argv_def = XTRACT_ANY; *argv_unit = XTRACT_ANY; + break; case XTRACT_SPECTRAL_INHARMONICITY: *argv_min = 0.f; *argv_max = XTRACT_SR_UPPER_LIMIT / 2; *argv_def = XTRACT_FUNDAMENTAL_DEFAULT; *argv_unit = XTRACT_HERTZ; + break; case XTRACT_F0: case XTRACT_FAILSAFE_F0: *argv_min = XTRACT_SR_LOWER_LIMIT; *argv_max = XTRACT_SR_UPPER_LIMIT; *argv_def = XTRACT_SR_DEFAULT; *argv_unit = XTRACT_HERTZ; + break; /* argc = 2 */; case XTRACT_ROLLOFF: *argv_min = XTRACT_FFT_BANDS_MIN; @@ -162,6 +167,7 @@ *(argv_max + 1) = 100.f; *(argv_def + 1) = 95.f; *(argv_unit + 1) = XTRACT_PERCENT; + break; case XTRACT_SPECTRUM: *argv_min = XTRACT_SR_LOWER_LIMIT / 2; *argv_max = XTRACT_SR_UPPER_LIMIT / 2; @@ -171,6 +177,7 @@ *(argv_max + 1) = 3 ; *(argv_def + 1) = 0; *(argv_unit + 1) = XTRACT_NONE; + break; case XTRACT_PEAK_SPECTRUM: *argv_min = XTRACT_SR_LOWER_LIMIT / 2; *argv_max = XTRACT_SR_UPPER_LIMIT / 2; @@ -180,6 +187,7 @@ *(argv_max + 1) = 100.f ; *(argv_def + 1) = 10.f ; *(argv_unit + 1) = XTRACT_PERCENT; + break; case XTRACT_HARMONIC_SPECTRUM: *argv_min = 0.f; *argv_max = XTRACT_SR_UPPER_LIMIT / 2; @@ -189,6 +197,7 @@ *(argv_max + 1) = 1.f ; *(argv_def + 1) = .1f ; *(argv_unit + 1) = XTRACT_NONE; + break; case XTRACT_NOISINESS: case XTRACT_SKEWNESS: case XTRACT_KURTOSIS: @@ -203,6 +212,7 @@ *(argv_max + 1) = XTRACT_NONE; *(argv_def + 1) = XTRACT_NONE; *(argv_unit + 1) = XTRACT_NONE; + break; case XTRACT_BARK_COEFFICIENTS: /* BARK_COEFFICIENTS is special because argc = BARK_BANDS */ default: @@ -210,6 +220,7 @@ *argv_max = XTRACT_NONE; *argv_def = XTRACT_NONE; *argv_unit = XTRACT_NONE; + break; } argv_donor = &d->argv.donor[0]; @@ -326,6 +337,12 @@ case XTRACT_MFCC: *data_format = XTRACT_SPECTRAL_MAGNITUDES; break; + case XTRACT_LPC: + *data_format = XTRACT_AUTOCORRELATION_COEFFS; + break; + case XTRACT_LPCC: + *data_format = XTRACT_LPC_COEFFS; + break; case XTRACT_SPECTRAL_INHARMONICITY: case XTRACT_HARMONIC_SPECTRUM: *data_format = XTRACT_SPECTRAL_PEAKS; @@ -414,6 +431,8 @@ case XTRACT_TONALITY: case XTRACT_LOUDNESS: case XTRACT_NONZERO_COUNT: + case XTRACT_LPC: + case XTRACT_LPCC: *data_unit = XTRACT_ANY; break; case XTRACT_SPECTRAL_MEAN: @@ -646,6 +665,25 @@ strcpy(desc, "Extract MFCC from a spectrum"); strcpy(p_desc, "Extract MFCC from an audio spectrum"); strcpy(author, "Rabiner"); + break; + case XTRACT_LPC: + strcpy(name, "lpc"); + strcpy(p_name, "Linear predictive coding coefficients"); + strcpy(desc, "Extract LPC from autocorrelation coefficients"); + strcpy(p_desc, + "Extract LPC from autocorrelation coefficients"); + strcpy(author, + "Rabiner and Juang as implemented by Jutta Degener"); + *year = 1994; + break; + case XTRACT_LPCC: + strcpy(name, "lpcc"); + strcpy(p_name, "Linear predictive coding cepstral coefficients"); + strcpy(desc, "Extract LPC cepstrum from LPC coefficients"); + strcpy(p_desc, + "Extract LPC cepstrum from LPC coefficients"); + strcpy(author, "Rabiner and Juang"); + *year = 1993; break; case XTRACT_BARK_COEFFICIENTS: strcpy(name, "bark_coefficients"); @@ -926,6 +964,10 @@ *argc = 1; *argv_type = XTRACT_MEL_FILTER; break; + case XTRACT_LPCC: + *argc = 1; + *argv_type = XTRACT_INT; + break; case XTRACT_BARK_COEFFICIENTS: *argc = XTRACT_BARK_BANDS; *argv_type = XTRACT_INT; @@ -961,6 +1003,7 @@ case XTRACT_ASDF: case XTRACT_NONZERO_COUNT: case XTRACT_ODD_EVEN_RATIO: + case XTRACT_LPC: default: *argc = 0; break; @@ -1019,6 +1062,8 @@ case XTRACT_SPECTRUM: case XTRACT_AUTOCORRELATION_FFT: case XTRACT_MFCC: + case XTRACT_LPC: + case XTRACT_LPCC: case XTRACT_DCT: case XTRACT_HARMONIC_SPECTRUM: *is_scalar = XTRACT_FALSE; @@ -1077,14 +1122,17 @@ *result_unit = XTRACT_HERTZ; *result_min = 0.f; *result_max = XTRACT_SR_UPPER_LIMIT / 2; + break; case XTRACT_ZCR: *result_unit = XTRACT_HERTZ; *result_min = 0.f; *result_max = XTRACT_ANY; + break; case XTRACT_ODD_EVEN_RATIO: *result_unit = XTRACT_NONE; *result_min = 0.f; *result_max = 1.f; + break; case XTRACT_LOUDNESS: case XTRACT_FLATNESS: case XTRACT_TONALITY: @@ -1093,10 +1141,13 @@ case XTRACT_POWER: case XTRACT_SHARPNESS: case XTRACT_SPECTRAL_SLOPE: + case XTRACT_LPC: + case XTRACT_LPCC: default: *result_unit = XTRACT_UNKNOWN; *result_min = XTRACT_UNKNOWN; *result_max = XTRACT_UNKNOWN; + break; } } else { @@ -1113,18 +1164,31 @@ case XTRACT_DCT: *result_format = XTRACT_ARBITRARY_SERIES; *result_unit = XTRACT_ANY; + break; case XTRACT_BARK_COEFFICIENTS: *result_format = XTRACT_BARK_COEFFS; *result_unit = XTRACT_UNKNOWN; /* FIX: check */ + break; case XTRACT_PEAK_SPECTRUM: case XTRACT_SPECTRUM: case XTRACT_HARMONIC_SPECTRUM: *result_format = XTRACT_SPECTRAL; *result_unit = XTRACT_ANY_AMPLITUDE_HERTZ; + break; case XTRACT_AUTOCORRELATION_FFT: + break; case XTRACT_MFCC: *result_format = XTRACT_MEL_COEFFS; *result_unit = XTRACT_UNKNOWN; /* FIX: check */ + break; + case XTRACT_LPC: + *result_format = XTRACT_LPC_COEFFS; + *result_unit = XTRACT_UNKNOWN; + break; + case XTRACT_LPCC: + *result_format = XTRACT_LPCC_COEFFS; + *result_unit = XTRACT_UNKNOWN; + break; default: break; } Modified: trunk/src/libxtract.c =================================================================== --- trunk/src/libxtract.c 2007-12-21 11:05:20 UTC (rev 106) +++ trunk/src/libxtract.c 2007-12-24 13:21:13 UTC (rev 107) @@ -79,6 +79,8 @@ xtract_autocorrelation_fft, xtract_mfcc, xtract_dct, - xtract_harmonic_spectrum + xtract_harmonic_spectrum, + xtract_lpc, + xtract_lpcc }; Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-12-21 11:05:20 UTC (rev 106) +++ trunk/src/vector.c 2007-12-24 13:21:13 UTC (rev 107) @@ -449,3 +449,90 @@ return XTRACT_SUCCESS; } +int xtract_lpc(const float *data, const int N, const void *argv, float *result){ + + int i, j, k, M, L; + float r = 0.f, + error = 0.f; + + float *ref = NULL, + *lpc = NULL ; + + error = data[0]; + k = N; /* The length of *data */ + L = N - 1; /* The number of LPC coefficients */ + M = L * 2; /* The length of *result */ + ref = result; + lpc = result+L; + + if(error == 0.0){ + for(i = 0; i < M; i++) + result[i] = 0.f; + return XTRACT_NO_RESULT; + } + + memset(result, 0, M * sizeof(float)); + + for (i = 0; i < L; i++) { + + /* Sum up this iteration's reflection coefficient. */ + r = -data[i + 1]; + for (j = 0; j < i; j++) + r -= lpc[j] * data[i - j]; + ref[i] = r /= error; + + /* Update LPC coefficients and total error. */ + lpc[i] = r; + for (j = 0; j < i / 2; j++) { + float tmp = lpc[j]; + lpc[j] = r * lpc[i - 1 - j]; + lpc[i - 1 - j] += r * tmp; + } + if (i % 2) lpc[j] += lpc[j] * r; + + error *= 1 - r * r; + } + + return XTRACT_SUCCESS; +} + +int xtract_lpcc(const float *data, const int N, const void *argv, float *result){ + + /* Given N lpc coefficients extract an LPC cepstrum of size argv[0] */ + /* Based on an an algorithm by rabiner and Juang */ + + int n, k; + float sum; + int order = N - 1; /* Eventually change this to Q = 3/2 p as suggested in Rabiner */ + int cep_length; + + if(argv == NULL) + cep_length = N - 1; + else + cep_length = (int)((float *)argv)[0]; + + memset(result, 0, cep_length * sizeof(float)); + + for (n = 1; n <= order && n <= cep_length; n++){ + sum = 0.f; + for (k = 1; k < n; k++) + sum += k * result[k-1] * data[n - k]; + result[n-1] = data[n] + sum / n; + } + + /* be wary of these interpolated values */ + for(n = order + 1; n <= cep_length; n++){ + sum = 0.f; + for (k = n - (order - 1); k < n; k++) + sum += k * result[k-1] * data[n - k]; + result[n-1] = sum / n; + } + + return XTRACT_SUCCESS; + +} +//int xtract_lpcc_s(const float *data, const int N, const void *argv, float *result){ +// return XTRACT_SUCCESS; +//} + + Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-12-21 11:05:20 UTC (rev 106) +++ trunk/xtract/libxtract.h 2007-12-24 13:21:13 UTC (rev 107) @@ -56,7 +56,7 @@ * @{ */ -#define XTRACT_FEATURES 54 +#define XTRACT_FEATURES 56 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ enum xtract_features_ { @@ -113,7 +113,9 @@ XTRACT_AUTOCORRELATION_FFT, XTRACT_MFCC, XTRACT_DCT, - XTRACT_HARMONIC_SPECTRUM + XTRACT_HARMONIC_SPECTRUM, + XTRACT_LPC, + XTRACT_LPCC }; /** \brief Enumeration of feature initialisation functions */ @@ -198,9 +200,12 @@ XTRACT_SPECTRAL_HARMONICS_MAGNITUDES, /* N spectral harmonic frequencies */ XTRACT_SPECTRAL_HARMONICS_FREQUENCIES, + XTRACT_AUTOCORRELATION_COEFFS, XTRACT_ARBITRARY_SERIES, XTRACT_AUDIO_SAMPLES, XTRACT_MEL_COEFFS, + XTRACT_LPC_COEFFS, + XTRACT_LPCC_COEFFS, XTRACT_BARK_COEFFS, XTRACT_NO_DATA } xtract_vector_t; Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2007-12-21 11:05:20 UTC (rev 106) +++ trunk/xtract/xtract_vector.h 2007-12-24 13:21:13 UTC (rev 107) @@ -126,6 +126,35 @@ */ int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, float *result); +/** \brief Extract Linear Predictive Coding Coefficients + * + * Based on algorithm in Rabiner and Juang as implemented by Jutta Degener in Dr. Dobb's Journal December, 1994. + * + * Returns N-1 reflection (PARCOR) coefficients and N-1 LPC coefficients via *result + * + * \param *data: N autocorrelation values e.g the data pointed to by *result from xtract_autocorrelation() + * \param N: the number of autocorrelation values to be considered + * \param *argv: a pointer to NULL + * \param *result: a pointer to an array containing N-1 reflection coefficients and N-1 LPC coefficients. + * + * An array of size 2 * (N - 1) must be allocated, and *result must point to its first element. + */ +int xtract_lpc(const float *data, const int N, const void *argv, float *result); + +/** \brief Extract Linear Predictive Coding Cepstral Coefficients + * + * \param *data: a pointer to the first element in an array of LPC coeffiecients e.g. a pointer to the second half of the array pointed to by *result from xtract_lpc() + * \param N: the number of LPC coefficients to be considered + * \param *argv: a pointer to a float representing the order of the result vector. This must be a whole number. According to Rabiner and Juang the ratio between the number (p) of LPC coefficients and the order (Q) of the LPC cepstrum is given by Q ~ (3/2)p where Q > p. + * \param *result: a pointer to an array containing the resultant LPCC. + * + * An array of size Q, where Q is given by argv[0] must be allocated, and *result must point to its first element. + * + */ +int xtract_lpcc(const float *data, const int N, const void *argv, float *result); + + + /** @} */ #ifdef __cplusplus This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-12-27 17:51:13
|
Revision: 108 http://libxtract.svn.sourceforge.net/libxtract/?rev=108&view=rev Author: postlude Date: 2007-12-27 09:51:07 -0800 (Thu, 27 Dec 2007) Log Message: ----------- - Added extra argument to xtract_spectrum to give the option of normalising the magnitude/power coeffificients - Removed duplicate code block (argc assignment) from descriptors.c - Added some extra documentation to libxtract.h Modified Paths: -------------- trunk/src/delta.c trunk/src/descriptors.c trunk/src/vector.c trunk/xtract/libxtract.h trunk/xtract/xtract_vector.h Modified: trunk/src/delta.c =================================================================== --- trunk/src/delta.c 2007-12-24 13:21:13 UTC (rev 107) +++ trunk/src/delta.c 2007-12-27 17:51:07 UTC (rev 108) @@ -24,6 +24,7 @@ int xtract_flux(const float *data, const int N, const void *argv , float *result){ + return XTRACT_FEATURE_NOT_IMPLEMENTED; } Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2007-12-24 13:21:13 UTC (rev 107) +++ trunk/src/descriptors.c 2007-12-27 17:51:07 UTC (rev 108) @@ -48,79 +48,6 @@ argc = &d->argc; argv_type = &d->argv.type; - switch(f){ - - case XTRACT_VARIANCE: - case XTRACT_STANDARD_DEVIATION: - case XTRACT_AVERAGE_DEVIATION: - case XTRACT_SPECTRAL_VARIANCE: - case XTRACT_SPECTRAL_STANDARD_DEVIATION: - case XTRACT_SPECTRAL_AVERAGE_DEVIATION: - case XTRACT_SPECTRAL_INHARMONICITY: - case XTRACT_LOWEST_VALUE: - case XTRACT_F0: - case XTRACT_FAILSAFE_F0: - case XTRACT_TONALITY: - *argc = 1; - *argv_type = XTRACT_FLOAT; - break; - case XTRACT_SKEWNESS: - case XTRACT_KURTOSIS: - case XTRACT_SPECTRAL_SKEWNESS: - case XTRACT_SPECTRAL_KURTOSIS: - case XTRACT_SPECTRUM: - case XTRACT_PEAK_SPECTRUM: - case XTRACT_HARMONIC_SPECTRUM: - case XTRACT_NOISINESS: - case XTRACT_CREST: - case XTRACT_ROLLOFF: - *argc = 2; - *argv_type = XTRACT_FLOAT; - break; - case XTRACT_MFCC: - *argc = 1; - *argv_type = XTRACT_MEL_FILTER; - break; - case XTRACT_BARK_COEFFICIENTS: - *argc = XTRACT_BARK_BANDS; - *argv_type = XTRACT_INT; - break; - case XTRACT_MEAN: - case XTRACT_SPECTRAL_MEAN: - case XTRACT_SPECTRAL_CENTROID: - case XTRACT_IRREGULARITY_K: - case XTRACT_IRREGULARITY_J: - case XTRACT_TRISTIMULUS_1: - case XTRACT_TRISTIMULUS_2: - case XTRACT_TRISTIMULUS_3: - case XTRACT_SMOOTHNESS: - case XTRACT_FLATNESS: - case XTRACT_SPREAD: - case XTRACT_ZCR: - case XTRACT_LOUDNESS: - case XTRACT_HIGHEST_VALUE: - case XTRACT_SUM: - case XTRACT_RMS_AMPLITUDE: - case XTRACT_POWER: - case XTRACT_SHARPNESS: - case XTRACT_SPECTRAL_SLOPE: - case XTRACT_HPS: - case XTRACT_FLUX: - case XTRACT_ATTACK_TIME: - case XTRACT_DECAY_TIME: - case XTRACT_DELTA_FEATURE: - case XTRACT_AUTOCORRELATION_FFT: - case XTRACT_DCT: - case XTRACT_AUTOCORRELATION: - case XTRACT_AMDF: - case XTRACT_ASDF: - case XTRACT_NONZERO_COUNT: - case XTRACT_ODD_EVEN_RATIO: - default: - *argc = 0; - break; - } - argv_min = &d->argv.min[0]; argv_max = &d->argv.max[0]; argv_def = &d->argv.def[0]; @@ -169,14 +96,22 @@ *(argv_unit + 1) = XTRACT_PERCENT; break; case XTRACT_SPECTRUM: - *argv_min = XTRACT_SR_LOWER_LIMIT / 2; - *argv_max = XTRACT_SR_UPPER_LIMIT / 2; - *argv_def = XTRACT_SR_DEFAULT / 2; + *argv_min = XTRACT_SR_LOWER_LIMIT / XTRACT_FFT_BANDS_MIN; + *argv_max = XTRACT_SR_UPPER_LIMIT / XTRACT_FFT_BANDS_MAX; + *argv_def = XTRACT_SR_DEFAULT / XTRACT_FFT_BANDS_DEF; *argv_unit = XTRACT_HERTZ; *(argv_min + 1) = 0; *(argv_max + 1) = 3 ; *(argv_def + 1) = 0; *(argv_unit + 1) = XTRACT_NONE; + *(argv_min + 2) = 0; + *(argv_max + 2) = 1; + *(argv_def + 2) = 0; + *(argv_unit + 2) = XTRACT_NONE; + *(argv_min + 3) = 0; + *(argv_max + 3) = 1; + *(argv_def + 3) = 0; + *(argv_unit + 3) = XTRACT_NONE; break; case XTRACT_PEAK_SPECTRUM: *argv_min = XTRACT_SR_LOWER_LIMIT / 2; @@ -260,7 +195,6 @@ *argv_donor = XTRACT_INIT_MFCC; break; /* argc = 2 */; - case XTRACT_SPECTRUM: case XTRACT_ROLLOFF: case XTRACT_PEAK_SPECTRUM: *argv_donor = XTRACT_ANY; @@ -288,7 +222,14 @@ *argv_donor = XTRACT_HIGHEST_VALUE; *(argv_donor + 1) = XTRACT_MEAN; break; - /* argc = BARK_BANDS */ + /* argc = 4 */ + case XTRACT_SPECTRUM: + *argv_donor = XTRACT_ANY; + *(argv_donor + 1) = XTRACT_ANY; + *(argv_donor + 2) = XTRACT_ANY; + *(argv_donor + 3) = XTRACT_ANY; + break; + /* BARK_BANDS */ case XTRACT_BARK_COEFFICIENTS: *argv_donor = XTRACT_INIT_BARK; break; @@ -951,7 +892,6 @@ case XTRACT_KURTOSIS: case XTRACT_SPECTRAL_SKEWNESS: case XTRACT_SPECTRAL_KURTOSIS: - case XTRACT_SPECTRUM: case XTRACT_PEAK_SPECTRUM: case XTRACT_HARMONIC_SPECTRUM: case XTRACT_NOISINESS: @@ -960,6 +900,10 @@ *argc = 2; *argv_type = XTRACT_FLOAT; break; + case XTRACT_SPECTRUM: + *argc = 4; + *argv_type = XTRACT_FLOAT; + break; case XTRACT_MFCC: *argc = 1; *argv_type = XTRACT_MEL_FILTER; Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-12-24 13:21:13 UTC (rev 107) +++ trunk/src/vector.c 2007-12-27 17:51:07 UTC (rev 108) @@ -45,12 +45,17 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *result){ - float *input, *rfft, q, temp; + float *input, *rfft, q, temp, max; size_t bytes; - int n , NxN, M, vector, withDC, argc; - //fftwf_plan plan; + int n, + NxN, + M, + vector, + withDC, + argc, + normalise; - vector = argc = withDC = 0; + vector = argc = withDC = normalise = 0; M = N >> 1; NxN = XTRACT_SQ(N); @@ -62,13 +67,14 @@ q = *(float *)argv; vector = (int)*((float *)argv+1); withDC = (int)*((float *)argv+2); + normalise = (int)*((float *)argv+3); + temp = 0.f; + max = 0.f; + XTRACT_CHECK_q; if(fft_plans.spectrum_plan == NULL){ - /* FIX: Not sure this should really be here. Might introduce - * DEBUG_POST macro, or some kind of error handler, or leave it to the - * caller... */ fprintf(stderr, "libxtract: Error: xtract_spectrum() has uninitialised plan\n"); return XTRACT_NO_RESULT; @@ -98,6 +104,7 @@ XTRACT_DB_SCALE_OFFSET; result[M + n - 1] = n * q; } + max = result[n] > max ? result[n] : max; } break; @@ -113,6 +120,7 @@ (XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / NxN; result[M + n - 1] = n * q; } + max = result[n] > max ? result[n] : max; } break; @@ -133,6 +141,7 @@ XTRACT_DB_SCALE_OFFSET; result[M + n - 1] = n * q; } + max = result[n] > max ? result[n] : max; } break; @@ -149,6 +158,7 @@ XTRACT_SQ(rfft[N - n])) / N; result[M + n - 1] = n * q; } + max = result[n] > max ? result[n] : max; } break; } @@ -157,16 +167,26 @@ /* The DC component */ result[0] = XTRACT_SQ(rfft[0]); result[M + 1] = 0.f; + max = result[0] > max ? result[0] : max; /* The Nyquist */ result[M] = XTRACT_SQ(rfft[M]); result[N + 1] = q * M; + max = result[M] > max ? result[M] : max; + M++; /* So we normalise the Nyquist (below) */ } else { /* The Nyquist */ result[M - 1] = (float)XTRACT_SQ(rfft[M]); result[N - 1] = q * M; + max = result[M - 1] > max ? result[M - 1] : max; } + + if(normalise){ + for(n = 0; n < M; n++) + result[n] /= max; + } + fftwf_free(rfft); free(input); Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-12-24 13:21:13 UTC (rev 107) +++ trunk/xtract/libxtract.h 2007-12-27 17:51:07 UTC (rev 108) @@ -25,9 +25,20 @@ * * This philosophy of 'cascading' features is followed throughout the library, for example with features that operate on the magnitude spectrum of a signal vector (e.g. 'irregularity'), the magnitude spectrum is not calculated 'inside' the respective function, instead, a pointer to the first element in an array containing the magnitude spectrum is passed in as an argument. * - * Hopefully this not only makes the library more efficient when computing large numbers of features, but also makes it more flexible because extraction functions can be combined arbitrarily (one can take the irregularility of the Mel Frequency Cepstral Coefficients for example). + * Hopefully this not only makes the library more efficient when computing large numbers of features, but also makes it more flexible because extraction functions can be combined arbitrarily (one can take the irregularility of the Mel Frequency Cepstral Coefficients for example). * + * All feature extraction functions follow the same prototype: * +int xtract_function_name(const float *data, const int N, const void *argv, float *result){ + * + * \param const float *data points to an array of floats representing the input data + * \param const int N represents the number of elementes from *data to be considered in the calculation + * \param const void *argv represents an arbitrary list of arguments. Used to pass in values required by the feature calculation + * \param float *result points to an array of floats, or a single float represnting the result of the calculation + * + * + * It is up to the calling function to allocate enough memory for the *data, *argv, and *result, and to free it when required. Some feature extraction functions may also require an _init() function to be called in order to perform some initialisation. The struct xtract_function_descriptor_t is used to give an indication of recommended default values, and argc for the *argv array. + * * LibXtract can be downloaded from http://www.sf.net/projects/libxtract * */ Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2007-12-24 13:21:13 UTC (rev 107) +++ trunk/xtract/xtract_vector.h 2007-12-27 17:51:07 UTC (rev 108) @@ -34,12 +34,15 @@ * @{ */ -/** \brief Extract normalized (0-1) frequency domain spectrum from time domain signal +/** \brief Extract frequency domain spectrum from time domain signal * * \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. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM). The third argument determines whether or not the DC component is included in the output. If argv[2] == 1, then the DC component is included in which case the size of the array pointed to by *result must be N+2. For any further use of the array pointed to by *result, the value of N must reflect the (larger) array size. - * \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 *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). The third argument determines whether or not the DC component is included in the output. If argv[2] == 1, then the DC component is included in which case the size of the array pointed to by *result must be N+2. For any further use of the array pointed to by *result, the value of N must reflect the (larger) array size. The fourth argument determines whether the magnitude/power coefficients are to be normalised. If argv[3] == 1, then the coefficients are normalised. + * \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. + * + * The magnitude/power coefficients are scaled to the range 0-1 so that for a given coefficient x, 0 <= x <= 1 + * */ int xtract_spectrum(const float *data, const int N, const void *argv, float *result); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-12-28 19:35:13
|
Revision: 110 http://libxtract.svn.sourceforge.net/libxtract/?rev=110&view=rev Author: postlude Date: 2007-12-28 11:34:51 -0800 (Fri, 28 Dec 2007) Log Message: ----------- - Added new helper functions: xtract_windowed() and xtract_features_from_subframes() - Added windowing functions (window.c) Modified Paths: -------------- trunk/src/Makefile.am trunk/src/delta.c trunk/src/init.c trunk/src/libxtract.c trunk/src/scalar.c trunk/swig/xtract.i trunk/xtract/Makefile.am trunk/xtract/libxtract.h Added Paths: ----------- trunk/src/helper.c trunk/src/window.c trunk/src/xtract_window_private.h trunk/xtract/xtract_helper.h Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/src/Makefile.am 2007-12-28 19:34:51 UTC (rev 110) @@ -1,6 +1,7 @@ MAINTAINERCLEANFILES = Makefile.in -SOURCES = libxtract.c descriptors.c scalar.c vector.c delta.c init.c fini.c +SOURCES = libxtract.c descriptors.c scalar.c vector.c delta.c init.c\ + window.c fini.c helper.c if BUILD_FFT FFT_DEFINE = -DXTRACT_FFT Modified: trunk/src/delta.c =================================================================== --- trunk/src/delta.c 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/src/delta.c 2007-12-28 19:34:51 UTC (rev 110) @@ -32,8 +32,7 @@ int xtract_lnorm(const float *data, const int N, const void *argv , float *result){ - int feature, - n, + int n, type; float order, @@ -80,7 +79,7 @@ int xtract_difference_vector(const float *data, const int N, const void *argv, float *result){ - float *frame1, + const float *frame1, *frame2; int n; Added: trunk/src/helper.c =================================================================== --- trunk/src/helper.c (rev 0) +++ trunk/src/helper.c 2007-12-28 19:34:51 UTC (rev 110) @@ -0,0 +1,65 @@ +/* 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. + */ + + +/* helper.c: helper functions. */ + +#include "xtract/libxtract.h" + +int xtract_windowed(const float *data, const int N, const void *argv, float *result){ + + int n; + const float *window; + + n = N; + window = (const float *)argv; + + while(n--) + result[n] = data[n] * window[n]; + + return XTRACT_SUCCESS; + +} + +int xtract_features_from_subframes(const float *data, const int N, const int feature, const void *argv, float *result){ + + const float *frame1, + *frame2; + float *result1, + *result2; + + int n, + rv; + + n = N >> 1; + + frame1 = data; + frame2 = data + n; + result1 = result; + result2 = result + n; + + rv = xtract[feature](frame1, n, argv, result1); + + if(rv == XTRACT_SUCCESS) + rv = xtract[feature](frame2, n, argv, result2); + + return rv; + +} Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/src/init.c 2007-12-28 19:34:51 UTC (rev 110) @@ -18,7 +18,7 @@ * USA. */ -/* init.c: defines functions that extract a feature as a single value from an input vector */ +/* init.c: defines initialisation and free functions. Also contains library constructor routine. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -28,6 +28,7 @@ #include <stdlib.h> #include "xtract/libxtract.h" +#include "xtract_window_private.h" #define DEFINE_GLOBALS #include "xtract_globals_private.h" @@ -43,7 +44,7 @@ int n, i, k, *fft_peak, M, next_peak; float norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val, - freq_bw_mel, *mel_peak, *height_norm, *lin_peak; + freq_bw_mel, *mel_peak, *height_norm, *lin_peak; mel_peak = height_norm = lin_peak = NULL; fft_peak = NULL; @@ -60,9 +61,9 @@ height_norm = (float *)malloc(freq_bands * sizeof(float)); if(mel_peak == NULL || height_norm == NULL || - lin_peak == NULL || fft_peak == NULL) - return XTRACT_MALLOC_FAILED; - + lin_peak == NULL || fft_peak == NULL) + return XTRACT_MALLOC_FAILED; + M = N >> 1; mel_peak[0] = mel_freq_min; @@ -91,41 +92,41 @@ } i = 0; - + for(n = 0; n < freq_bands; n++){ - - // calculate the rise increment + + // calculate the rise increment if(n==0) inc = height_norm[n] / fft_peak[n]; else inc = height_norm[n] / (fft_peak[n] - fft_peak[n - 1]); val = 0; - - // zero the start of the array - for(k = 0; k < i; k++) - fft_tables[n][k] = 0.f; - - // fill in the rise + + // zero the start of the array + for(k = 0; k < i; k++) + fft_tables[n][k] = 0.f; + + // fill in the rise for(; i <= fft_peak[n]; i++){ fft_tables[n][i] = val; val += inc; } - + // calculate the fall increment inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]); - + val = 0; - next_peak = fft_peak[n + 1]; - - // reverse fill the 'fall' + next_peak = fft_peak[n + 1]; + + // reverse fill the 'fall' for(i = next_peak; i > fft_peak[n]; i--){ fft_tables[n][i] = val; val += inc; } - // zero the rest of the array - for(k = next_peak + 1; k < N; k++) - fft_tables[n][k] = 0.f; + // zero the rest of the array + for(k = next_peak + 1; k < N; k++) + fft_tables[n][k] = 0.f; } @@ -145,9 +146,9 @@ float *input, *output; int optimisation; - + input = output = NULL; - + fprintf(stderr, "Optimisation level: %d\n", XTRACT_FFT_OPTIMISATION_LEVEL); if(XTRACT_FFT_OPTIMISATION_LEVEL == 0) @@ -209,14 +210,63 @@ 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)*/ int bands = XTRACT_BARK_BANDS; - + while(bands--) band_limits[bands] = edges[bands] / sr * N; - /*FIX shohuld use rounding, but couldn't get it to work */ + /*FIX shohuld use rounding, but couldn't get it to work */ return XTRACT_SUCCESS; } +float *xtract_init_window(const int N, const int type){ + + float *window; + + window = malloc(N * sizeof(float)); + + switch (type) { + case XTRACT_GAUSS: + gauss(window, N, 0.4); + break; + case XTRACT_HAMMING: + hamming(window, N); + break; + case XTRACT_HANN: + hann(window, N); + break; + case XTRACT_BARTLETT: + bartlett(window, N); + break; + case XTRACT_TRIANGULAR: + triangular(window, N); + break; + case XTRACT_BARTLETT_HANN: + bartlett_hann(window, N); + break; + case XTRACT_BLACKMAN: + blackman(window, N); + break; + case XTRACT_KAISER: + kaiser(window, N, 3 * PI); + break; + case XTRACT_BLACKMAN_HARRIS: + blackman_harris(window, N); + break; + default: + hann(window, N); + break; + } + + return window; + +} + +void xtract_free_window(float *window){ + + free(window); + +} + #ifdef __GNUC__ __attribute__((constructor)) void init() #else Modified: trunk/src/libxtract.c =================================================================== --- trunk/src/libxtract.c 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/src/libxtract.c 2007-12-28 19:34:51 UTC (rev 110) @@ -64,13 +64,13 @@ xtract_hps, xtract_f0, xtract_failsafe_f0, -/* xtract_delta.h */ + /* xtract_delta.h */ xtract_lnorm, xtract_flux, xtract_attack_time, xtract_decay_time, xtract_difference_vector, -/* xtract_vector.h */ + /* xtract_vector.h */ xtract_autocorrelation, xtract_amdf, xtract_asdf, @@ -82,6 +82,8 @@ xtract_dct, xtract_harmonic_spectrum, xtract_lpc, - xtract_lpcc + xtract_lpcc, + /* xtract_helper.h */ + xtract_windowed }; Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/src/scalar.c 2007-12-28 19:34:51 UTC (rev 110) @@ -19,7 +19,7 @@ */ -/* xtract_scalar.c: defines functions that extract a feature as a single value from an input vector */ +/* scalar.c: defines functions that extract a feature as a single value from an input vector */ #include "xtract/libxtract.h" #include "xtract_macros_private.h" Added: trunk/src/window.c =================================================================== --- trunk/src/window.c (rev 0) +++ trunk/src/window.c 2007-12-28 19:34:51 UTC (rev 110) @@ -0,0 +1,182 @@ +/* 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. + */ + +/* window.c: defines window generation functions (formulae courtesy of Wikipedia (http://en.wikipedia.org/wiki/Window_function) */ + +#include <math.h> + +#include "xtract_window_private.h" + +void gauss(float *window, const int N, const float sd){ + + int n; + const float M = N - 1; + float num, + den, + exponent; + + for (n = 0; n < N; n++) { + + num = n - M / 2.f; + den = sd * M / 2.f; + + exponent = -0.5 * powf(num / den, 2); + + window[n] = exp(exponent); + + } +} + +void hamming(float *window, const int N){ + + int n; + const float M = N - 1; + + for (n = 0; n < N; n++) + window[n] = 0.53836 - (0.46164 * cosf(2.0 * PI * (float)n / M)); + +} + +void hann(float *window, const int N){ + + int n; + const float M = N - 1; + + for (n = 0; n < N; n++) + window[n] = 0.5 * (1.0 - cosf(2.0 * PI * (float)n / M)); + +} + +void bartlett(float *window, const int N){ + + int n; + const float M = N - 1; + + for (n = 0; n < N; n++) + window[n] = 2.f / M * (M / 2.f - fabsf(n - M / 2.f)); + +} + +void triangular(float *window, const int N){ + + int n; + const float M = N - 1; + + for (n = 0; n < N; n++) + window[n] = 2.f / N * (N / 2.f - fabsf(n - M / 2.f)); +} + +void bartlett_hann(float *window, const int N){ + + int n; + const float M = N - 1, + a0 = 0.62, + a1 = 0.5, + a2 = 0.38; + float term1 = 0.f, + term2 = 0.f; + + for (n = 0; n < N; n++){ + + term1 = a1 * fabsf(n / M - 0.5); + term2 = a2 * cosf(2.0 * PI * (float)n / M); + + window[n] = a0 - term1 - term2; + } +} + +void blackman(float *window, const int N){ + + int n; + const float M = N - 1, + a0 = 0.42, + a1 = 0.5, + a2 = 0.08; + float term1 = 0.f, + term2 = 0.f; + + for (n = 0; n < N; n++) { + + term1 = a1 * cosf(2.0 * PI * (float)n / M); + term2 = a2 * cosf(4.0 * PI * (float)n / M); + + window[n] = a0 - term1 + term2; + } +} + +#define BIZ_EPSILON 1E-21 // Max error acceptable + +/* Based on code from mplayer window.c, and somewhat beyond me */ +float besselI0(float x){ + + float temp; + float sum = 1.0; + float u = 1.0; + float halfx = x/2.0; + int n = 1; + + do { + + temp = halfx/(float)n; + u *=temp * temp; + sum += u; + n++; + + } while (u >= BIZ_EPSILON * sum); + + return(sum); + +} + +void kaiser(float *window, const int N, const float alpha){ + + int n; + const float M = N - 1; + float num; + + for (n = 0; n < N; n++) { + + num = besselI0(alpha * sqrtf(1.0 - powf((2.0 * n / M - 1), 2))); + window[n] = num / besselI0(alpha); + + } +} + +void blackman_harris(float *window, const int N){ + + int n; + const float M = N - 1, + a0 = 0.35875, + a1 = 0.48829, + a2 = 0.14128, + a3 = 0.01168; + float term1 = 0.f, + term2 = 0.f, + term3 = 0.f; + + for (n = 0; n < N; n++) { + + term1 = a1 * cosf(2.0 * PI * n / M); + term2 = a2 * cosf(4.0 * PI * n / M); + term3 = a3 * cosf(6.0 * PI * n / M); + + window[n] = a0 - term1 + term2 - term3; + } +} Added: trunk/src/xtract_window_private.h =================================================================== --- trunk/src/xtract_window_private.h (rev 0) +++ trunk/src/xtract_window_private.h 2007-12-28 19:34:51 UTC (rev 110) @@ -0,0 +1,98 @@ +/* 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. + */ + +/* xtract_window_private.h: declares window generation functions */ + +#define PI 3.1415926535897931 + +/** \brief generate a Gaussian window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * \param sd the standard deviation of the "distribution" represented by the Gaussian curve. The higher the value of sd, the wider the curve. Generally sd <= 0.5 + * + */ +void gauss(float *window, const int N, const float sd); + +/** \brief generate a Hamming window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * + */ +void hamming(float *window, const int N); + +/** \brief generate a Hann window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * + */ +void hann(float *window, const int N); + +/** \brief generate a Bartlett window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * + */ +void bartlett(float *window, const int N); + +/** \brief generate a Triangular window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * + */ +void triangular(float *window, const int N); + +/** \brief generate a Bartlett-Hann window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * + */ +void bartlett_hann(float *window, const int N); + +/** \brief generate a Blackman window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * + */ +void blackman(float *window, const int N); + +/** \brief generate a Kaiser window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * \param alpha The larger the value of |alpha|, the narrower the window becomes + * + */ +void kaiser(float *window, const int N, const float alpha); + +/** \brief generate a Blackman-Harris window + * + * \param *window a pointer to an array to contain the window data + * \param N the number of elements in the array pointed to by *window + * + */ +void blackman_harris(float *window, const int N); + Modified: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/swig/xtract.i 2007-12-28 19:34:51 UTC (rev 110) @@ -5,6 +5,7 @@ %{ #include "xtract/xtract_scalar.h" #include "xtract/xtract_vector.h" +#include "xtract/xtract_helper.h" #include "xtract/libxtract.h" %} @@ -19,4 +20,5 @@ %clear float *result; %include "xtract/xtract_vector.h" +%include "xtract/xtract_helper.h" %include "xtract/libxtract.h" Modified: trunk/xtract/Makefile.am =================================================================== --- trunk/xtract/Makefile.am 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/xtract/Makefile.am 2007-12-28 19:34:51 UTC (rev 110) @@ -3,5 +3,5 @@ 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 Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-12-27 20:37:15 UTC (rev 109) +++ trunk/xtract/libxtract.h 2007-12-28 19:34:51 UTC (rev 110) @@ -60,6 +60,7 @@ #include "xtract_delta.h" #include "xtract_types.h" #include "xtract_macros.h" +#include "xtract_helper.h" /** \defgroup libxtract API * @@ -67,7 +68,7 @@ * @{ */ -#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 @@ 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 @@ 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_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(); Added: trunk/xtract/xtract_helper.h =================================================================== --- trunk/xtract/xtract_helper.h (rev 0) +++ trunk/xtract/xtract_helper.h 2007-12-28 19:34:51 UTC (rev 110) @@ -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 + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2008-02-15 12:43:29
|
Revision: 116 http://libxtract.svn.sourceforge.net/libxtract/?rev=116&view=rev Author: postlude Date: 2008-02-15 04:43:13 -0800 (Fri, 15 Feb 2008) Log Message: ----------- - Fixed bugs in xtract_flatness(), or at least added necessary documentation and error checking to avoid problems - Added xtract_is_denormal() helper function and XTRACT_DENORMAL_FOUND return code - Replaced all instances of log, sqrt, exp etc. with respective floating point counterparts (logf etc.) - Added check for architecture endianness to configure script - Bug fix to PD example, now no longer crashes if no arguments are given - Minor documentation updates Modified Paths: -------------- trunk/ChangeLog trunk/TODO trunk/configure.in trunk/examples/puredata/xtract~.c trunk/src/descriptors.c trunk/src/helper.c trunk/src/init.c trunk/src/libxtract.c trunk/src/scalar.c trunk/src/vector.c trunk/xtract/libxtract.h trunk/xtract/xtract_helper.h trunk/xtract/xtract_scalar.h trunk/xtract/xtract_vector.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/ChangeLog 2008-02-15 12:43:13 UTC (rev 116) @@ -1,3 +1,16 @@ +2008-2-15 Jamie Bullock <ja...@po...> + * version 0.5.9 + * Fixed bugs in xtract_flatness(), or at least added necessary + documentation and error checking to avoid problems + * Added xtract_is_denormal() helper function and XTRACT_DENORMAL_FOUND + return code + * Replaced all instances of log, sqrt, exp etc. with respective + floating point counterparts (logf etc.) + * Added check for architecture endianness to configure script + * Bug fix to PD example, now no longer crashes if no arguments are + given + * Minor documentation updates + 2007-10-09 Dan Stowell * version 0.5.1 * Fixed bug in xtract_init_mfcc() which accidentally missed filling in the very top filter frequency value Modified: trunk/TODO =================================================================== --- trunk/TODO 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/TODO 2008-02-15 12:43:13 UTC (rev 116) @@ -15,3 +15,6 @@ Use the fftw guru interface to create multipurpose global plans from xtract_fft_init() Add LPC via Schur algorithm If argv uses an integer, then it should point to a variable of type int. At the moment floats are used to store ints. +Write macro to truncate numbers <= 0 prior to taking log and integrate into functions across the library +Add xtract_chords() - gets pitch classes from spectrum either as MIDI note numbers or pitch class and octave class - e.g. 'F#4' etc. +Add xtract_subbands() - gets subband power or subband magnitude for given bands Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/configure.in 2008-02-15 12:43:13 UTC (rev 116) @@ -4,7 +4,7 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 5) # Increment for fixes -m4_define(libxtract_fix_version, 0) +m4_define(libxtract_fix_version, 9) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) @@ -17,6 +17,7 @@ AC_PROG_CC AC_PROG_LIBTOOL AC_PROG_INSTALL +AC_C_BIGENDIAN AC_PATH_PROG(PKG_CONFIG, pkg-config, no) AC_ENABLE_STATIC(no) AC_ENABLE_SHARED(yes) @@ -125,7 +126,6 @@ AM_CONDITIONAL(BUILD_SIMPLETEST, test "x${simpletest}" = 'xtrue') - dnl Are we building the PD examples? if [[ "$pd_example" = "true" ]] ; then PD_SOURCES="xtract~.c" @@ -217,7 +217,15 @@ AM_CONDITIONAL(BUILD_FFT, test "x${fft}" = 'xtrue') +dnl Check for architecture endian-ness +#AC_C_BIGENDIAN(bigendian=true, bigendian=false, bigendian=undefined) +#if [[ "$is_bigendian" = "false" ]] ; then +# AC_DEFINE([WORDS_BIGENDIAN], [0], [Architecture is big endian]) +#else +# AC_DEFINE([WORDS_BIGENDIAN], [1], [Architecture is not big endian]) +#fi + dnl ------------------------------------------ dnl ---- do some magic to gues the host opsys dnl ---- taken from libvorbis configure.in Modified: trunk/examples/puredata/xtract~.c =================================================================== --- trunk/examples/puredata/xtract~.c 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/examples/puredata/xtract~.c 2008-02-15 12:43:13 UTC (rev 116) @@ -168,6 +168,10 @@ else x->feature_name = atom_getsymbol(argv); } + else { + post("xtract~: No arguments given"); + return (void *)x; + } if(argc > 1){ if(x->is_subframe) x->feature_name = atom_getsymbol(argv+1); @@ -233,8 +237,6 @@ if(strcmp(author, "") && year) post("xtract~: %s(%d)", author, year); } - else - post("xtract~: No arguments given"); /* Adjust frame size if we are using subframe features */ if(x->is_subframe) Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/src/descriptors.c 2008-02-15 12:43:13 UTC (rev 116) @@ -530,7 +530,7 @@ break; case XTRACT_ODD_EVEN_RATIO: strcpy(name, "odd_even_ratio"); - strcpy(p_name, "Odd/Even Harmonic Ratio"); + strcpy(p_name, "Odd/even Harmonic Ratio"); strcpy(desc, "Extract the odd-to-even harmonic ratio of a spectrum"); strcpy(p_desc, Modified: trunk/src/helper.c =================================================================== --- trunk/src/helper.c 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/src/helper.c 2008-02-15 12:43:13 UTC (rev 116) @@ -21,8 +21,18 @@ /* helper.c: helper functions. */ +#include <config.h> + +#include <stdio.h> + #include "xtract/libxtract.h" +#ifdef WORDS_BIGENDIAN +#define INDEX 0 +#else +#define INDEX 1 +#endif + int xtract_windowed(const float *data, const int N, const void *argv, float *result){ int n; @@ -45,8 +55,7 @@ float *result1, *result2; - int n, i, - rv; + int n, rv; n = N >> 1; @@ -63,3 +72,12 @@ return rv; } + +inline int xtract_is_denormal(double const d){ + if(sizeof(d) != 2 * sizeof(int)) + fprintf(stderr, "libxtract: Error: xtract_is_denormal() detects inconsistent wordlength for type 'double'\n"); + + int l = ((int *)&d)[INDEX]; + return (l&0x7ff00000) == 0 && d!=0; //Check for 0 may not be necessary +} + Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/src/init.c 2008-02-15 12:43:13 UTC (rev 116) @@ -149,7 +149,7 @@ input = output = NULL; - fprintf(stderr, "Optimisation level: %d\n", XTRACT_FFT_OPTIMISATION_LEVEL); + //fprintf(stderr, "Optimisation level: %d\n", XTRACT_FFT_OPTIMISATION_LEVEL); if(XTRACT_FFT_OPTIMISATION_LEVEL == 0) optimisation = FFTW_ESTIMATE; Modified: trunk/src/libxtract.c =================================================================== --- trunk/src/libxtract.c 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/src/libxtract.c 2008-02-15 12:43:13 UTC (rev 116) @@ -48,6 +48,7 @@ xtract_rolloff, xtract_loudness, xtract_flatness, + xtract_flatness_db, xtract_tonality, xtract_crest, xtract_noisiness, Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/src/scalar.c 2008-02-15 12:43:13 UTC (rev 116) @@ -21,13 +21,17 @@ /* scalar.c: defines functions that extract a feature as a single value from an input vector */ -#include "xtract/libxtract.h" -#include "xtract_macros_private.h" -#include "math.h" +#include <config.h> + #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <math.h> +#include "xtract/libxtract.h" +#include "xtract/xtract_helper.h" +#include "xtract_macros_private.h" + #ifndef powf #define powf pow #endif @@ -36,8 +40,20 @@ #define expf exp #endif +#ifndef sqrtf + #define sqrtf sqrt +#endif + +#ifndef fabsf + #define fabsf fabs +#endif + + void test(void){ - printf("Hello world"); + printf("Hello world\n"); +#ifdef WORDS_BIGENDIAN + printf("Big endian!\n"); +#endif } int xtract_mean(const float *data, const int N, const void *argv, float *result){ @@ -58,8 +74,10 @@ int n = N; + *result += 0.f; + while(n--) - *result += pow(data[n] - *(float *)argv, 2); + *result += powf(data[n] - *(float *)argv, 2); *result = *result / (N - 1); @@ -68,7 +86,7 @@ int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result){ - *result = sqrt(*(float *)argv); + *result = sqrtf(*(float *)argv); return XTRACT_SUCCESS; } @@ -77,8 +95,10 @@ int n = N; + *result += 0.f; + while(n--) - *result += fabs(data[n] - *(float *)argv); + *result += fabsf(data[n] - *(float *)argv); *result /= N; @@ -91,9 +111,11 @@ float temp = 0.f; + *result += 0.f; + while(n--){ temp = (data[n] - ((float *)argv)[0]) / ((float *)argv)[1]; - *result += pow(temp, 3); + *result += powf(temp, 3); } *result /= N; @@ -106,11 +128,13 @@ int n = N; - float temp; + float temp = 0.f; + *result += 0.f; + while(n--){ temp = (data[n] - ((float *)argv)[0]) / ((float *)argv)[1]; - *result += pow(temp, 4); + *result += powf(temp, 4); } *result /= N; @@ -134,7 +158,10 @@ A += amps[n]; } - *result = FA / A; + if(A == 0.f) + *result = 0.f; + else + *result = FA / A; return XTRACT_SUCCESS; } @@ -156,6 +183,8 @@ amps = data; freqs = data + m; + *result += 0.f; + while(m--){ A += amps[m]; *result += powf((freqs[m] - *(float *)argv) * amps[m], 2); @@ -168,7 +197,7 @@ int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result){ - *result = sqrt(*(float *)argv); + *result = sqrtf(*(float *)argv); return XTRACT_SUCCESS; } @@ -184,9 +213,11 @@ amps = data; freqs = data + m; + *result += 0.f; + while(m--){ A += amps[m]; - *result += fabs((amps[m] * freqs[m]) - *(float *)argv); + *result += fabsf((amps[m] * freqs[m]) - *(float *)argv); } *result /= A; @@ -205,11 +236,13 @@ amps = data; freqs = data + m; + *result += 0.f; + while(m--){ A += amps[m]; temp = ((amps[m] * freqs[m]) - ((float *)argv)[0]) / ((float *)argv)[1]; - *result += pow(temp, 3); + *result += powf(temp, 3); } *result /= A; @@ -228,11 +261,13 @@ amps = data; freqs = data + m; + *result += 0.f; + while(m--){ A += amps[m]; temp = ((amps[m] * freqs[m]) - ((float *)argv)[0]) / ((float *)argv)[1]; - *result += pow(temp, 4); + *result += powf(temp, 4); } *result /= A; @@ -246,10 +281,10 @@ int n, M = N - 1; - *result = 0.f; + *result = 0.f; for(n = 1; n < M; n++) - *result += fabs(data[n] - (data[n-1] + data[n] + data[n+1]) / 3); + *result += fabsf(data[n] - (data[n-1] + data[n] + data[n+1]) / 3.f); return XTRACT_SUCCESS; } @@ -261,8 +296,8 @@ double num = 0.f, den = 0.f; while(n--){ - num += pow(data[n] - data[n+1], 2); - den += pow(data[n], 2); + num += powf(data[n] - data[n+1], 2); + den += powf(data[n], 2); } *result = (float)(num / den); @@ -286,18 +321,23 @@ } } - *result = p1 / den; - - return XTRACT_SUCCESS; + if(den == 0.f || p1 == 0.f){ + *result = 0.f; + return XTRACT_NO_RESULT; + } + else{ + *result = p1 / den; + return XTRACT_SUCCESS; + } } int xtract_tristimulus_2(const float *data, const int N, const void *argv, float *result){ int n = N; - float den, p2, p3, p4, temp; + float den, p2, p3, p4, ps, temp; - den = p2 = p3 = p4 = temp = 0.f; + den = p2 = p3 = p4 = ps = temp = 0.f; for(n = 0; n < N; n++){ if((temp = data[n])){ @@ -311,9 +351,17 @@ } } - *result = (p2 + p3 + p4) / den; + ps = p2 + p3 + p4; - return XTRACT_SUCCESS; + if(den == 0.f || ps == 0.f){ + *result = 0.f; + return XTRACT_NO_RESULT; + } + else{ + *result = ps / den; + return XTRACT_SUCCESS; + } + } int xtract_tristimulus_3(const float *data, const int N, const void *argv, float *result){ @@ -333,9 +381,14 @@ } } - *result = num / den; - - return XTRACT_SUCCESS; + if(den == 0.f || num == 0.f){ + *result = 0.f; + return XTRACT_NO_RESULT; + } + else{ + *result = num / den; + return XTRACT_SUCCESS; + } } int xtract_smoothness(const float *data, const int N, const void *argv, float *result){ @@ -347,14 +400,18 @@ input = (float *)malloc(N * sizeof(float)); memcpy(input, data, N * sizeof(float)); - if (input[0] <= 0) input[0] = 1; + if (input[0] <= 0) + input[0] = XTRACT_LOG_LIMIT; + if (input[1] <= 0) + input[1] = XTRACT_LOG_LIMIT; M = N - 1; for(n = 1; n < M; n++){ - if(input[n] <= 0) input[n] = 1; - *result += fabs(20 * log(input[n]) - (20 * log(input[n-1]) + - 20 * log(input[n]) + 20 * log(input[n+1])) / 3); + if(input[n+1] <= 0) + input[n+1] = XTRACT_LOG_LIMIT; + *result += fabsf(20.f * logf(input[n]) - (20.f * logf(input[n-1]) + + 20.f * logf(input[n]) + 20.f * logf(input[n+1])) / 3.f); } free(input); @@ -377,7 +434,7 @@ den += data[n]; } - *result = sqrt(num / den); + *result = sqrtf(num / den); return XTRACT_SUCCESS; } @@ -389,7 +446,7 @@ for(n = 1; n < N; n++) if(data[n] * data[n-1] < 0) (*result)++; - *result /= N; + *result /= (float)N; return XTRACT_SUCCESS; } @@ -419,6 +476,8 @@ int n = N, rv; + *result = 0.f; + if(n > XTRACT_BARK_BANDS){ n = XTRACT_BARK_BANDS; rv = XTRACT_BAD_VECTOR_SIZE; @@ -434,45 +493,69 @@ int xtract_flatness(const float *data, const int N, const void *argv, float *result){ - int n; + int n, count, denormal_found; double num, den, temp; - den = data[0]; - num = (data[0] == 0.f ? 1.f : data[0]); + num = 1.f; + den = temp = 0.f; - for(n = 1; n < N; n++){ - if((temp = data[n]) != 0.f) { - num *= temp; - den += temp; - } + denormal_found = 0; + count = 0; + + for(n = 0; n < N; n++){ + if((temp = data[n]) != 0.f) { + if (xtract_is_denormal(num)){ + denormal_found = 1; + break; + } + num *= temp; + den += temp; + count++; + } } - num = powf(num, 1.f / N); - den /= N; + if(!count){ + *result = 0.f; + return XTRACT_NO_RESULT; + } - if(num < XTRACT_VERY_SMALL_NUMBER) - num = XTRACT_VERY_SMALL_NUMBER; + num = powf(num, 1.f / (float)N); + den /= (float)N; - if(den < XTRACT_VERY_SMALL_NUMBER) - den = XTRACT_VERY_SMALL_NUMBER; - *result = 10 * log10(num / den); + *result = (float) (num / den); + if(denormal_found) + return XTRACT_DENORMAL_FOUND; + else + return XTRACT_SUCCESS; + +} + +int xtract_flatness_db(const float *data, const int N, const void *argv, float *result){ + + float flatness_db; + + flatness_db = *(float *)argv; + + if (flatness_db <= 0) + flatness_db = XTRACT_LOG_LIMIT; + + *result = 10 * log10f(flatness_db); + return XTRACT_SUCCESS; } int xtract_tonality(const float *data, const int N, const void *argv, float *result){ - float sfmdb, sfm; + float sfmdb; - sfm = *(float *)argv; + sfmdb = *(float *)argv; - sfmdb = sfm / -60.f; + *result = XTRACT_MIN(sfmdb / -60.f, 1); - *result = XTRACT_MIN(sfmdb, 1); - return XTRACT_SUCCESS; } @@ -512,9 +595,11 @@ int n = N; + *result = 0.f; + while(n--) *result += XTRACT_SQ(data[n]); - *result = sqrt(*result / N); + *result = sqrtf(*result / (float)N); return XTRACT_SUCCESS; } @@ -531,7 +616,7 @@ while(n--){ if(amps[n]){ - num += fabs(freqs[n] - n * fund) * XTRACT_SQ(amps[n]); + num += fabsf(freqs[n] - n * fund) * XTRACT_SQ(amps[n]); den += XTRACT_SQ(amps[n]); } } @@ -552,30 +637,37 @@ int M = (N >> 1), n; - float num = 0.f, den = 0.f, temp; + float odd = 0.f, even = 0.f, temp; for(n = 0; n < M; n++){ if((temp = data[n])){ if(XTRACT_IS_ODD(n)){ - num += temp; + odd += temp; } else{ - den += temp; + even += temp; } } } - *result = num / den; - - return XTRACT_SUCCESS; + if(odd == 0.f || even == 0.f){ + *result = 0.f; + return XTRACT_NO_RESULT; + } + else { + *result = odd / even; + return XTRACT_SUCCESS; + } } int xtract_sharpness(const float *data, const int N, const void *argv, float *result){ int n = N, rv; - float sl, g, temp; /* sl = specific loudness */ + float sl, g; /* sl = specific loudness */ + double temp; - sl = g = temp = 0.f; + sl = g = 0.f; + temp = 0.f; if(n > XTRACT_BARK_BANDS) rv = XTRACT_BAD_VECTOR_SIZE; @@ -589,7 +681,8 @@ temp += n * g * sl; } - *result = 0.11 * temp / N; + temp = 0.11 * temp / (float)N; + *result = (float)temp; return rv; @@ -655,6 +748,8 @@ int n = N; + *result = 0.f; + while(n--) *result += *data++; @@ -665,6 +760,8 @@ int xtract_nonzero_count(const float *data, const int N, const void *argv, float *result){ int n = N; + + *result += 0.f; while(n--) *result += (*data++ ? 1 : 0); @@ -690,7 +787,7 @@ while(n--) coeffs2[n] = coeffs3[n] = 1; M = N >> 1; - L = N / 3; + L = N / 3.f; while(M--){ m = M << 1; @@ -698,7 +795,7 @@ if(M < L){ l = M * 3; - coeffs3[M] = (data[l] + data[l+1] + data[l+2]) / 3; + coeffs3[M] = (data[l] + data[l+1] + data[l+2]) / 3.f; } } @@ -792,12 +889,12 @@ /* Estimate fundamental freq */ for (n = 1; n < M; n++) - err_tau_1 = err_tau_1 + fabs(input[n] - input[n+1]); + err_tau_1 = err_tau_1 + fabsf(input[n] - input[n+1]); /* FIX: this doesn't pose too much load if it returns 'early', but if it can't find f0, load can be significant for larger block sizes M^2 iterations! */ for (tau = 2; tau < M; tau++){ err_tau_x = 0; for (n = 1; n < M; n++){ - err_tau_x = err_tau_x + fabs(input[n] - input[n+tau]); + err_tau_x = err_tau_x + fabsf(input[n] - input[n+tau]); } if (err_tau_x < err_tau_1) { f0 = sr / (tau + (err_tau_x / err_tau_1)); Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/src/vector.c 2008-02-15 12:43:13 UTC (rev 116) @@ -37,6 +37,22 @@ } #endif +#ifndef powf + #define powf pow +#endif + +#ifndef expf + #define expf exp +#endif + +#ifndef sqrtf + #define sqrtf sqrt +#endif + +#ifndef fabsf + #define fabsf fabs +#endif + #ifdef XTRACT_FFT #include <fftw3.h> @@ -45,11 +61,10 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *result){ - float *input, *rfft, q, temp, max; + float *input, *rfft, q, temp, max, NxN; size_t bytes; int n, m, - NxN, M, vector, withDC, @@ -89,7 +104,7 @@ for(n = 1; n < M; n++){ if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) - temp = log(sqrt(temp) / N); + temp = logf(sqrtf(temp) / (float)N); else temp = XTRACT_LOG_LIMIT_DB; @@ -130,7 +145,7 @@ for(n = 1; n < M; n++){ if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) - temp = log(temp / NxN); + temp = logf(temp / NxN); else temp = XTRACT_LOG_LIMIT_DB; @@ -161,8 +176,8 @@ result[M + m] = n * q; } - result[m] = sqrt(XTRACT_SQ(rfft[n]) + - XTRACT_SQ(rfft[N - n])) / N; + result[m] = sqrtf(XTRACT_SQ(rfft[n]) + + XTRACT_SQ(rfft[N - n])) / (float)N; max = result[m] > max ? result[m] : max; } break; @@ -254,7 +269,7 @@ for(n = 0; n < N; n++){ result[filter] += data[n] * f->filters[filter][n]; } - result[filter] = log(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]); + result[filter] = logf(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]); } xtract_dct(result, f->n_filters, NULL, result); @@ -334,13 +349,13 @@ float md, temp; while(n--){ - md = 0; + md = 0.f; for(i = 0; i < N - n; i++){ temp = data[i] - data[i + n]; temp = (temp < 0 ? -temp : temp); md += temp; } - result[n] = md / N; + result[n] = md / (float)N; } return XTRACT_SUCCESS; @@ -353,12 +368,12 @@ float sd; while(n--){ - sd = 0; + sd = 0.f; for(i = 0; i < N - n; i++){ /*sd = 1;*/ sd += XTRACT_SQ(data[i] - data[i + n]); } - result[n] = sd / N; + result[n] = sd / (float)N; } return XTRACT_SUCCESS; @@ -488,13 +503,12 @@ M = L * 2; /* The length of *result */ ref = result; lpc = result+L; -/* + if(error == 0.0){ - for(i = 0; i < M; i++) - result[i] = 0.f; + memset(result, 0, M * sizeof(float)); return XTRACT_NO_RESULT; } -*/ + memset(result, 0, M * sizeof(float)); for (i = 0; i < L; i++) { Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/xtract/libxtract.h 2008-02-15 12:43:13 UTC (rev 116) @@ -96,6 +96,7 @@ XTRACT_ROLLOFF, XTRACT_LOUDNESS, XTRACT_FLATNESS, + XTRACT_FLATNESS_DB, XTRACT_TONALITY, XTRACT_CREST, XTRACT_NOISINESS, @@ -165,7 +166,8 @@ XTRACT_MALLOC_FAILED, XTRACT_BAD_ARGV, XTRACT_BAD_VECTOR_SIZE, - XTRACT_NO_RESULT, + XTRACT_DENORMAL_FOUND, + XTRACT_NO_RESULT, /* This usually occurs when the correct calculation cannot take place because required data is missing or would result in a NaN or infinity/-infinity. Under these curcumstances 0.f is usually given by *result */ XTRACT_FEATURE_NOT_IMPLEMENTED }; Modified: trunk/xtract/xtract_helper.h =================================================================== --- trunk/xtract/xtract_helper.h 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/xtract/xtract_helper.h 2008-02-15 12:43:13 UTC (rev 116) @@ -63,6 +63,9 @@ */ int xtract_features_from_subframes(const float *data, const int N, const int feature, const void *argv, float *result); +/** \brief Test whether a number is denormal */ +inline int xtract_is_denormal(double const d); + /** @} */ #ifdef __cplusplus Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/xtract/xtract_scalar.h 2008-02-15 12:43:13 UTC (rev 116) @@ -239,21 +239,34 @@ */ int xtract_loudness(const float *data, const int N, const void *argv, float *result); -/** \brief Extract the spectral flatness measure of an input vector using a method described by Tristan Jehan (2005) +/** \brief Extract the spectral flatness measure of an input vector, where the flatness measure (SFM) is defined as the ratio of the geometric mean to the arithmetic mean of a magnitude spectrum. + * + * \note The computation method used here is the most efficient by a significant margin, but suffers from precision problems due to the multiplication operationin the geometric mean calculation. This is particularly accute for larger values of N (>=256). However, as noted by Peeters (2003), the SFM should generally be computed on a small number of 'bands' rather than on the complete magnitude spectrum. It is therefore highly recommended that xtract_bands() is used prior to calling xtract_flatness(). * - * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). - * \param N: the number of elements to be considered + * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). Alternatively the magnitudes from a number of 'subbands' can be used by using *result from xtract_bands(). + * \param N: the number of *data array elements to be considered * \param *argv: a pointer to NULL - * \param *result: the spectral flatness of N values from the array pointed to by *data + * \param *result: the flatness of N values from the array pointed to by *data */ int xtract_flatness(const float *data, const int N, const void *argv, float *result); +/** \brief Extract the LOG spectral flatness measure of an input vector + * + * \param *data: a pointer to NULL. + * \param N: not used - can safely be set to 0. + * \param *argv: a pointer to a float represnting spectral flatness. + * \param *result: the LOG spectral flatness of N values from the array pointed to by *data + * + * flatness_db = 10 * log10(flatness) + * + */ +int xtract_flatness_db(const float *data, const int N, const void *argv, float *result); -/** \brief Extract the tonality factor of an input vector using a method described by Tristan Jehan (2005) +/** \brief Extract the tonality factor of an input vector using a method described by Peeters 2003 * - * \param *data: not used. - * \param N: not used - * \param *argv: a pointer to the spectral flatness measure of an audio vector (e.g. the output from xtract_flatness) + * \param *data: a pointer to NULL. + * \param N: not used - can safely be set to 0. + * \param *argv: a pointer to the LOG spectral flatness measure of an audio vector (e.g. the output from xtract_flatness_db) * \param *result: the tonality factor of N values from the array pointed to by *data */ int xtract_tonality(const float *data, const int N, const void *argv, float *result); @@ -309,7 +322,7 @@ * \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 + * \param *result: the even/odd 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); Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2008-01-02 04:10:21 UTC (rev 115) +++ trunk/xtract/xtract_vector.h 2008-02-15 12:43:13 UTC (rev 116) @@ -43,6 +43,8 @@ * * The magnitude/power coefficients are scaled to the range 0-1 so that for a given coefficient x, 0 <= x <= 1 * + * \note Before calling xtract_spectrum(), the FFT must be initialised by calling xtract_init_fft(N, XTRACT_SPECTRUM) + * */ int xtract_spectrum(const float *data, const int N, const void *argv, float *result); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2008-02-15 15:49:55
|
Revision: 117 http://libxtract.svn.sourceforge.net/libxtract/?rev=117&view=rev Author: postlude Date: 2008-02-15 07:49:49 -0800 (Fri, 15 Feb 2008) Log Message: ----------- Added new extraction function: xtract_subbands() Modified Paths: -------------- trunk/TODO trunk/src/descriptors.c trunk/src/vector.c trunk/xtract/libxtract.h trunk/xtract/xtract_vector.h Modified: trunk/TODO =================================================================== --- trunk/TODO 2008-02-15 12:43:13 UTC (rev 116) +++ trunk/TODO 2008-02-15 15:49:49 UTC (rev 117) @@ -16,5 +16,4 @@ Add LPC via Schur algorithm If argv uses an integer, then it should point to a variable of type int. At the moment floats are used to store ints. Write macro to truncate numbers <= 0 prior to taking log and integrate into functions across the library -Add xtract_chords() - gets pitch classes from spectrum either as MIDI note numbers or pitch class and octave class - e.g. 'F#4' etc. Add xtract_subbands() - gets subband power or subband magnitude for given bands Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2008-02-15 12:43:13 UTC (rev 116) +++ trunk/src/descriptors.c 2008-02-15 15:49:49 UTC (rev 117) @@ -86,7 +86,7 @@ *argv_def = XTRACT_SR_DEFAULT; *argv_unit = XTRACT_HERTZ; break; - /* argc = 2 */; + /* argc = 2 */; case XTRACT_ROLLOFF: *argv_min = XTRACT_FFT_BANDS_MIN; *argv_max = XTRACT_FFT_BANDS_MAX; @@ -97,24 +97,6 @@ *(argv_def + 1) = 95.f; *(argv_unit + 1) = XTRACT_PERCENT; break; - case XTRACT_SPECTRUM: - *argv_min = XTRACT_SR_LOWER_LIMIT / XTRACT_FFT_BANDS_MIN; - *argv_max = XTRACT_SR_UPPER_LIMIT / XTRACT_FFT_BANDS_MAX; - *argv_def = XTRACT_SR_DEFAULT / XTRACT_FFT_BANDS_DEF; - *argv_unit = XTRACT_HERTZ; - *(argv_min + 1) = 0; - *(argv_max + 1) = 3 ; - *(argv_def + 1) = 0; - *(argv_unit + 1) = XTRACT_NONE; - *(argv_min + 2) = 0; - *(argv_max + 2) = 1; - *(argv_def + 2) = 0; - *(argv_unit + 2) = XTRACT_NONE; - *(argv_min + 3) = 0; - *(argv_max + 3) = 1; - *(argv_def + 3) = 0; - *(argv_unit + 3) = XTRACT_NONE; - break; case XTRACT_PEAK_SPECTRUM: *argv_min = XTRACT_SR_LOWER_LIMIT / 2; *argv_max = XTRACT_SR_UPPER_LIMIT / 2; @@ -150,6 +132,43 @@ *(argv_def + 1) = XTRACT_NONE; *(argv_unit + 1) = XTRACT_NONE; break; + /* argc = 4 */ + case XTRACT_SPECTRUM: + *argv_min = XTRACT_SR_LOWER_LIMIT / XTRACT_FFT_BANDS_MIN; + *argv_max = XTRACT_SR_UPPER_LIMIT / XTRACT_FFT_BANDS_MAX; + *argv_def = XTRACT_SR_DEFAULT / XTRACT_FFT_BANDS_DEF; + *argv_unit = XTRACT_HERTZ; + *(argv_min + 1) = 0; + *(argv_max + 1) = 3 ; + *(argv_def + 1) = 0; + *(argv_unit + 1) = XTRACT_NONE; + *(argv_min + 2) = 0; + *(argv_max + 2) = 1; + *(argv_def + 2) = 0; + *(argv_unit + 2) = XTRACT_NONE; + *(argv_min + 3) = 0; + *(argv_max + 3) = 1; + *(argv_def + 3) = 0; + *(argv_unit + 3) = XTRACT_NONE; + break; + case XTRACT_SUBBANDS: + *argv_min = XTRACT_ANY; + *argv_max = XTRACT_ANY; + *argv_def = XTRACT_MEAN; + *argv_unit = XTRACT_NONE; + *(argv_min + 1) = 1; + *(argv_max + 1) = 16384; + *(argv_def + 1) = 4; + *(argv_unit + 1) = XTRACT_NONE; + *(argv_min + 2) = 0; + *(argv_max + 2) = 32; + *(argv_def + 2) = 0; + *(argv_unit + 2) = XTRACT_NONE; + *(argv_min + 3) = 0; + *(argv_max + 3) = 1; + *(argv_def + 3) = 0; + *(argv_unit + 3) = XTRACT_NONE; + break; case XTRACT_BARK_COEFFICIENTS: /* BARK_COEFFICIENTS is special because argc = BARK_BANDS */ case XTRACT_WINDOWED: Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2008-02-15 12:43:13 UTC (rev 116) +++ trunk/src/vector.c 2008-02-15 15:49:49 UTC (rev 117) @@ -573,4 +573,52 @@ // return XTRACT_SUCCESS; //} +int xtract_subbands(const float *data, const int N, const void *argv, float *result){ + int n, bw, xtract_func, nbands, scale, start, lower, *argi, rv; + + argi = (int *)argv; + + xtract_func = argi[0]; + nbands = argi[1]; + scale = argi[2]; + start = argi[3]; + + + if(scale == XTRACT_LINEAR_SUBBANDS) + bw = floorf((N - start) / nbands); + else + bw = start; + + lower = start; + + for(n = 0; n < nbands; n++){ + + /* Bounds sanity check */ + if(lower + bw >= N) + result[n] = 0.f + continue; + + rv = xtract[xtract_func](data+lower, bw, NULL, &result[n]); + + if(rv != XTRACT_SUCCESS) + return rv; + + switch(scale){ + case XTRACT_OCTAVE_SUBBANDS: + lower += bw; + bw = lower; + break; + case XTRACT_LINEAR_SUBBANDS: + lower += bw; + break; + } + + } + + return rv; + +} + + + Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2008-02-15 12:43:13 UTC (rev 116) +++ trunk/xtract/libxtract.h 2008-02-15 15:49:49 UTC (rev 117) @@ -130,6 +130,7 @@ XTRACT_HARMONIC_SPECTRUM, XTRACT_LPC, XTRACT_LPCC, + XTRACT_SUBBANDS, /* Helper functions */ XTRACT_WINDOWED }; @@ -179,6 +180,12 @@ XTRACT_LOG_POWER_SPECTRUM }; +/** \brief Subband scales */ +enum xtract_subband_scales_ { + XTRACT_OCTAVE_SUBBANDS, + XTRACT_LINEAR_SUBBANDS +}; + /** \brief Enumeration of data types*/ typedef enum type_ { XTRACT_FLOAT, Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2008-02-15 12:43:13 UTC (rev 116) +++ trunk/xtract/xtract_vector.h 2008-02-15 15:49:49 UTC (rev 117) @@ -158,8 +158,23 @@ */ int xtract_lpcc(const float *data, const int N, const void *argv, float *result); - - +/** \brief Extract subbands from a spectrum + * + * \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 number of elements from the array pointed to by *data to be considered + * \param *argv: A pointer to an array containing four integers. The first represents the extraction function to applied to each subband e.g. XTRACT_SUM or XTRACT_MEAN, the second represents the number of subbands required, and the third represents the frequency scale to be used for the subband bounds as defined in the enumeration xtract_subband_scales_ (libxtract.h). The fourth integer represent the start point of the subbands as a location in the input array as pointed to by *data (e.g. a value of 5 would start the subband extraction at bin 5) + * \param *result: A pointer to an array containing the resultant subband values. The calling function is responsible for allocating and freeing memory for *result. xtract_subbands() assumes that at least argv[1] * sizeof(float) bytes have been allocated. If the requested nbands extends the subband range beyond N, then the remaining bands will be set to 0. If the array pointed to by *result has more than argv[1] elements, the superfluous elements will be unchanged. + * + * xtract_subbands() divides a spectrum into subbands and applies the function given by argv[0] to the values in each subband to give a 'reduced' representation of the spectrum as *result + * + * Specifying XTRACT_OCTAVE_SUBBANDS will extract subbands at each octave from the start bin until argv[1] is reached or N is reached + * Specifying XTRACT_LINEAR_SUBBANDS will extract argv[1] equal sized subbands between the start bin and N + * + * + * It is assumed that a sensible function will be given in argv[0], and for this function argv will always be NULL. Sensible values for argv[0] are XTRACT_MEAN and XTRACT_SUM, although something like XTRACT_IRREGULARITY_K might yield interesting results. + * + */ +int xtract_subbands(const float *data, const int N, const void *argv, float *result); /** @} */ #ifdef __cplusplus This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2008-02-16 20:13:30
|
Revision: 118 http://libxtract.svn.sourceforge.net/libxtract/?rev=118&view=rev Author: postlude Date: 2008-02-16 12:13:05 -0800 (Sat, 16 Feb 2008) Log Message: ----------- - Added to pd example the ability to differentiate between different argv types (XTRACT_FLOAT, XTRACT_INT) and pass the correct data type to the xtract[]() function - Added xtract_flatness_db() details to descriptors.c - Fixes to tonality and xtract_subbands descriptors - Added Pd examples for 'subband mean' and tonality calculated using subbands Modified Paths: -------------- trunk/ChangeLog trunk/TODO trunk/configure.in trunk/examples/puredata/subframe-test.pd trunk/examples/puredata/xtract~.c trunk/src/descriptors.c trunk/src/libxtract.c trunk/src/scalar.c trunk/src/vector.c trunk/xtract/libxtract.h Added Paths: ----------- trunk/examples/puredata/subband_mean.pd trunk/examples/puredata/tonality_from_subbands.pd Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/ChangeLog 2008-02-16 20:13:05 UTC (rev 118) @@ -1,3 +1,12 @@ +2008-2-16 Jamie Bullock <ja...@po...> + * version 0.6.0 + * Added to pd example the ability to differentiate between different + argv types (XTRACT_FLOAT, XTRACT_INT) and pass the correct data type + to the xtract[]() function + * Added xtract_flatness_db() details to descriptors.c + * Fixes to tonality and xtract_subbands descriptors + * Added Pd examples for 'subband mean' and tonality calculated using subbands + 2008-2-15 Jamie Bullock <ja...@po...> * version 0.5.9 * Fixed bugs in xtract_flatness(), or at least added necessary Modified: trunk/TODO =================================================================== --- trunk/TODO 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/TODO 2008-02-16 20:13:05 UTC (rev 118) @@ -1,19 +1,12 @@ Add -fPIC in intelligent way to build system for 64-bit builds -Rationalise use of powf etc. vs pow -Add spectral_flux -Add geometric_mean -Add spectral_mean, spectral_deviation, spectral_geometric_mean etc. Add weighted temporal features as per Peeters (xtract_weighted_mean etc) weight given as argv? Improve noise robustness of xtract_f0 Fix xtract_hps - it doesn't work! -Add Pure Data help file -Add delta functions Add Max/MSP external example Check and add return values as appropriate. Make them more sensible! ...do other stuff and eventually... ...optimise! Use the fftw guru interface to create multipurpose global plans from xtract_fft_init() Add LPC via Schur algorithm -If argv uses an integer, then it should point to a variable of type int. At the moment floats are used to store ints. Write macro to truncate numbers <= 0 prior to taking log and integrate into functions across the library -Add xtract_subbands() - gets subband power or subband magnitude for given bands +Add functionality to Pd example to convert symbols 'XTRACT_MEAN', 'XTRACT_*' to corresponding integers to ease the construction of argv lists Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/configure.in 2008-02-16 20:13:05 UTC (rev 118) @@ -2,9 +2,9 @@ # Increment for major API changes, release status changes m4_define(libxtract_major_version, 0) # Increment for feature additions and enhancements -m4_define(libxtract_minor_version, 5) +m4_define(libxtract_minor_version, 6) # Increment for fixes -m4_define(libxtract_fix_version, 9) +m4_define(libxtract_fix_version, 0) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) Added: trunk/examples/puredata/subband_mean.pd =================================================================== --- trunk/examples/puredata/subband_mean.pd (rev 0) +++ trunk/examples/puredata/subband_mean.pd 2008-02-16 20:13:05 UTC (rev 118) @@ -0,0 +1,102 @@ +#N canvas 493 51 587 478 10; +#X obj 82 127 xtract~ spectrum; +#N canvas 6 48 450 300 mag_spectrum 0; +#X obj 260 64 block~ 512; +#N canvas 0 0 450 300 (subpatch) 0; +#X array mag_spectrum 512 float 3; +#A 0 0.0132486 0.0096563 0.0354424 0.0165249 0.0339139 0.0245265 0.0429209 +0.0604935 0.0858024 0.472867 0.131911 0.0710302 0.0320982 0.0389981 +0.0272274 0.015468 0.0195354 0.0195954 0.0188111 0.0207361 0.0166347 +0.00157469 0.02206 0.0104267 0.0070746 0.0295359 0.0121162 0.013655 +0.0102867 0.00591679 0.00586671 0.00641669 0.0105255 0.0120749 0.00294434 +0.013461 0.00875645 0.0157844 0.00649163 0.0150134 0.0135169 0.0191429 +0.0282347 0.0241475 0.0185751 0.00689928 0.022662 0.00670788 0.00318354 +0.00283897 0.0142583 0.017543 0.00907015 0.0164521 0.0223336 0.02503 +0.0121266 0.0170551 0.0284856 0.0271476 0.00775067 0.00155745 0.0197414 +0.0150477 0.0279912 0.0224467 0.00407337 0.00497963 0.000851764 0.0161942 +0.0176389 0.0160251 0.0175218 0.027366 0.00792114 0.0222662 0.0160268 +0.0279591 0.0112953 0.00409087 0.00645786 0.015363 0.0293401 0.0105894 +0.00844756 0.0175758 0.0215718 0.0200431 0.00260135 0.0101493 0.0200218 +0.00456712 0.0278158 0.0215603 0.0262786 0.0129843 0.00468684 0.024167 +0.0149199 0.0101847 0.00482173 0.00959639 0.0325585 0.0291854 0.0138181 +0.0169087 0.0236841 0.0291382 0.0199014 0.00511631 0.00370711 0.0101142 +0.0120038 0.00115485 0.0154999 0.00297503 0.0140602 0.0191407 0.0210018 +0.0322096 0.0224205 0.0206845 0.0191659 0.031921 0.0151202 0.0168541 +0.036274 0.0229901 0.0349309 0.0208622 0.0131437 0.00933729 0.0126362 +0.025394 0.00901058 0.01157 0.0131736 0.00677092 0.0194996 0.0173273 +0.00325973 0.0124627 0.0110635 0.0167556 0.0136908 0.0065692 0.0262649 +0.0225311 0.0235114 0.0197293 0.00282572 0.0240237 0.00657686 0.0173891 +0.0257314 0.012755 0.0217556 0.00329426 0.0158449 0.0240496 0.0106366 +0.022061 0.00708543 0.0209552 0.00957124 0.0102439 0.016452 0.00943987 +0.0137701 0.0165189 0.0184722 0.0335198 0.023159 0.0140537 0.0137668 +0.0249716 0.0252517 0.0222753 0.0196876 0.00917165 0.0231789 0.0223262 +0.0130253 0.0143873 0.0174217 0.0262216 0.0221904 0.00554891 0.0169622 +0.0214176 0.00636145 0.0190085 0.00084364 0.00991013 0.00538487 0.0132557 +0.034742 0.00783582 0.0329481 0.00777087 0.0132578 0.0246518 0.00381398 +0.0136186 0.0101923 0.0105305 0.0135506 0.00659576 0.00948354 0.0244682 +0.00372209 0.0144119 0.00303586 0.0193436 0.0127196 0.0248709 0.0018994 +0.0102549 0.00929058 0.0222578 0.0290115 0.0211259 0.0397477 0.0200812 +0.0044044 0.0132484 0.0407253 0.00666307 0.0303175 0.014019 0.00897817 +0.00528597 0.0267464 0.014286 0.0215917 0.0260188 0.0217563 0.00233073 +0.01223 0.0020918 0.00739707 0.00231818 0.0237471 0.0197745 0.0138808 +0.00300929 0.0166336 0.0104104 0.0131831 0.00639908 0.00556837 0.0145624 +0.00884734 0.023722 0.0139918 0.0214095 0.0136722 0.0246529 0.0212282 +0.0214965 0.0114811 0.0181338 0.0193226 0.0165735 0.0138509 0.0193118 +0.00444871 0.0119447 0.00337634 0.0148758 0.0187246 0.0244031 0.010354 +0.0146917 0.0135728 0.0135919 0.0270935 0.00721325 0.0254225 0.0171227 +0.0239136 0.00854048 0.00875449 0.0127878 0.0253363 0.0114877 0.0122164 +0.0159164 0.0182439 0.0100041 0.00461047 0.0245388 0.0189458 0.00619877 +0.0248993 0.00963699 0.0249874 0.0271515 0.0145729 0.0279523 0.027924 +0.0220959 0.0262779 0.015607 0.00716239 0.012087 0.0337037 0.00516229 +0.0170121 0.0336761 0.00650737 0.00497518 0.02043 0.0105242 0.00488026 +0.0104467 0.00818958 0.00628406 0.0211596 0.0165034 0.0182923 0.0199196 +0.0249672 0.0164662 0.0214767 0.0120562 0.0322599 0.00383154 0.00921745 +0.00146418 0.0356547 0.0103786 0.0165492 0.0304809 0.0131255 0.0167945 +0.00558382 0.0238359 0.0175395 0.00780578 0.0346175 0.00236843 0.0255091 +0.0201751 0.0108775 0.0210824 0.0209226 0.0320313 0.0437274 0.00560051 +0.0344518 0.00791858 0.0208586 0.0286015 0.0248276 0.0237304 0.0412748 +0.0120705 0.0241371 0.00511147 0.0317298 0.0139929 0.028099 0.0103861 +0.00891256 0.00822179 0.016315 0.0248265 0.0213948 0.0239172 0.0166187 +0.0310473 0.0186244 0.0166212 0.0366136 0.0136573 0.0269544 0.010431 +0.0249531 0.0120786 0.0109345 0.0123368 0.0151866 0.0357349 0.00463059 +0.0118539 0.00970646 0.00946582 0.00969734 0.00891857 0.00890028 0.0202631 +0.0215117 0.0111571 0.0250767 0.0209911 0.0198019 0.0093692 0.0131443 +0.00748891 0.024563 0.0247875 0.0230017 0.00794473 0.00888343 0.0217427 +0.0343637 0.0287685 0.00968487 0.0498302 0.0171984 0.0315536 0.00588345 +0.010743 0.0126087 0.0182915 0.00907374 0.00443379 0.0379275 0.023097 +0.0160588 0.00775962 0.0344518 0.0164484 0.0376125 0.0172285 0.0132559 +0.029612 0.0116543 0.0273187 0.023721 0.0046918 0.0172711 0.00766218 +0.0112108 0.0180092 0.0278611 0.0190289 0.0202484 0.0127141 0.0276473 +0.0169104 0.028993 0.00897726 0.00712007 0.0122292 0.00820719 0.0168334 +0.00864513 0.0127985 0.0237389 0.0120437 0.0212306 0.0304613 0.0189116 +0.0197339 0.0212744 0.0151605 0.0141882 0.0195768 0.00291933 0.0358095 +0.0293726 0.0169182 0.0103468 0.0135299 0.0266578 0.0154398 0.00245885 +0.00794718 0.0127344 0.0298125 0.00820393 0.00626316 0.0170656 0.0230811 +0.00259497 0.0173437 0.00922873 0.0205893 0.0209727 0.00431716 0.00870416 +0.00315811 0.0163018 0.0292532 0.0154488 0.0141043 0.0250745 0.00961138 +0.0142033 0.010861 0.0187522 0.0241866 0.016184 0.0184565 0.0162928 +0.011523 0.0141778 0.0157446 0.0228784 0.0380396 0.0176535 0.0102128 +0.0272628 0.0115185 0.0148983 0.0233291 0.00915212 0.0157429 0.0298723 +101.909; +#X coords 0 1 511 0 200 140 1; +#X restore 125 121 graph; +#X restore 245 43 pd mag_spectrum; +#X obj 82 162 tabsend~ mag_spectrum; +#X obj 244 15 block~ 1024; +#X obj 279 224 tabreceive~ mag_spectrum; +#X obj 58 71 noise~; +#X obj 113 70 osc~ 440; +#X obj 278 307 print~; +#X obj 453 188 loadbang; +#X obj 278 266 xtract~ subbands 1024; +#X obj 118 230 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X msg 453 223 list 0 8 0 16; +#X connect 0 0 2 0; +#X connect 4 0 9 0; +#X connect 5 0 0 0; +#X connect 6 0 0 0; +#X connect 8 0 11 0; +#X connect 9 0 7 0; +#X connect 10 0 7 0; +#X connect 11 0 9 1; Modified: trunk/examples/puredata/subframe-test.pd =================================================================== --- trunk/examples/puredata/subframe-test.pd 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/examples/puredata/subframe-test.pd 2008-02-16 20:13:05 UTC (rev 118) @@ -1,42 +1,42 @@ -#N canvas 667 50 557 639 10; +#N canvas 667 51 613 639 10; #X obj 263 -160 xtract~ subframe windowed 64; -#X obj 442 -125 tabsend~ windowed; +#X obj 473 -126 tabsend~ windowed; #N canvas 0 0 450 300 (subpatch) 0; #X array windowed 64 float 5; -#A 0 0 0.00988792 0.0386044 0.0571912 0.0189603 -0.101949 -0.277669 --0.42422 -0.437499 -0.251716 0.11162 0.534831 0.846232 0.89682 0.634185 -0.135697 -0.418906 -0.823923 -0.937159 -0.739218 -0.334947 0.101471 -0.40821 0.503437 0.407727 0.215338 0.0353621 -0.0632974 -0.0748772 --0.0405181 -0.00868179 -3.27457e-15 0 0.00657018 0.0386642 0.0864644 -0.104272 0.0386758 -0.128569 -0.351139 -0.525142 -0.535095 -0.31781 -0.0907861 0.554834 0.890148 0.946246 0.679244 0.177795 -0.372091 -0.768033 --0.878652 -0.69562 -0.326984 0.0615718 0.325607 0.401064 0.317179 0.162825 -0.0298987 -0.0329445 -0.0328739 -0.0102196 -6.65005e-15; +#A 0 0 -0.00539658 -0.0365654 -0.0889249 -0.119512 -0.0710801 0.0849429 +0.314014 0.517949 0.575413 0.405857 0.0231818 -0.452978 -0.839845 -0.971146 +-0.775526 -0.314544 0.24085 0.684547 0.864859 0.746131 0.414296 0.0268876 +-0.264158 -0.377502 -0.324844 -0.185212 -0.0511399 0.0208516 0.0292007 +0.0100387 7.11504e-15 0 0.000585724 -0.0198747 -0.079146 -0.154996 +-0.187268 -0.111695 0.0928308 0.373338 0.611529 0.674151 0.482276 0.0628278 +-0.447978 -0.856285 -0.995151 -0.80163 -0.347457 0.191996 0.616082 +0.785785 0.677697 0.381243 0.044994 -0.197483 -0.283735 -0.235181 -0.126292 +-0.0330596 0.00773548 0.00706581 7.42552e-15; #X coords 0 1 63 -1 200 140 1; #X restore 46 -552 graph; #X obj 264 -125 xtract~ subframe spectrum 64; #N canvas 0 0 450 300 (subpatch) 0; #X array sf_mags1 16 float 5; -#A 0 0.00733392 0.14449 0.240482 0.109887 0.00135916 0.000113993 5.63786e-05 -7.59283e-05 7.22785e-05 6.48168e-05 5.62613e-05 5.20935e-05 4.72571e-05 -4.40774e-05 4.34346e-05 1.76297e-06; +#A 0 0.00796987 0.144169 0.24068 0.109756 0.00127541 0.000110428 0.000122432 +0.000120516 0.000102996 8.516e-05 6.88438e-05 5.77259e-05 4.7595e-05 +4.13114e-05 3.56295e-05 1.33207e-06; #X coords 0 1 15 -1 200 140 1; #X restore 261 -551 graph; #N canvas 0 0 450 300 (subpatch) 0; #X array sf_mags2 32 float 5; -#A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0077164 0.1443 0.240599 0.109809 -0.00131069 0.00011119 0.000100841 0.00010453 9.17035e-05 7.68611e-05 -6.53814e-05 5.45444e-05 4.76852e-05 4.18391e-05 4.00649e-05 1.43191e-06 +#A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00902428 0.143577 0.241043 0.109515 +0.001105 0.000101461 0.000191993 0.000175226 0.000143044 0.000113519 +8.72515e-05 6.69791e-05 4.84639e-05 3.34907e-05 1.99719e-05 2.52196e-07 ; #X coords 0 1 31 -1 200 140 1; #X restore 259 -389 graph; #N canvas 0 0 450 300 (subpatch) 0; #X array both 35 float 5; -#A 0 0.00733392 0.14449 0.240482 0.109887 0.00135916 0.000113993 5.63786e-05 -7.59283e-05 7.22785e-05 6.48168e-05 5.62613e-05 5.20935e-05 4.72571e-05 -4.40774e-05 4.34346e-05 1.76297e-06 0.0077164 0.1443 0.240599 0.109809 -0.00131069 0.00011119 0.000100841 0.00010453 9.17035e-05 7.68611e-05 -6.53814e-05 5.45444e-05 4.76852e-05 4.18391e-05 4.00649e-05 1.43191e-06 +#A 0 0.00796987 0.144169 0.24068 0.109756 0.00127541 0.000110428 0.000122432 +0.000120516 0.000102996 8.516e-05 6.88438e-05 5.77259e-05 4.7595e-05 +4.13114e-05 3.56295e-05 1.33207e-06 0.00902428 0.143577 0.241043 0.109515 +0.001105 0.000101461 0.000191993 0.000175226 0.000143044 0.000113519 +8.72515e-05 6.69791e-05 4.84639e-05 3.34907e-05 1.99719e-05 2.52196e-07 0 0 0; #X coords 0 1 34 -1 200 140 1; #X restore 46 -393 graph; @@ -52,11 +52,11 @@ #X obj 70 -10 inlet~; #X obj 70 59 a_blockswap~ 64; #X obj 69 151 a_blockswap~ 32; -#N canvas 0 0 450 300 graph4 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array temp 16 float 5; -#A 0 0.0077164 0.1443 0.240599 0.109809 0.00131069 0.00011119 0.000100841 -0.00010453 9.17035e-05 7.68611e-05 6.53814e-05 5.45444e-05 4.76852e-05 -4.18391e-05 4.00649e-05 1.43191e-06; +#A 0 0.00902428 0.143577 0.241043 0.109515 0.001105 0.000101461 0.000191993 +0.000175226 0.000143044 0.000113519 8.72515e-05 6.69791e-05 4.84639e-05 +3.34907e-05 1.99719e-05 2.52196e-07; #X coords 0 1 15 -1 200 140 1; #X restore 226 -6 graph; #X connect 0 0 7 0; @@ -68,11 +68,11 @@ #X connect 9 0 4 0; #X connect 10 0 6 0; #X restore 263 -94 pd get_mags; -#N canvas 0 0 450 300 graph4 0; +#N canvas 0 0 450 300 (subpatch) 0; #X array diff 16 float 5; -#A 0 -0.000382476 0.000189289 -0.000116706 7.71508e-05 4.8466e-05 2.80288e-06 --4.44625e-05 -2.86015e-05 -1.9425e-05 -1.20443e-05 -9.12002e-06 -2.45091e-06 --4.28088e-07 2.23831e-06 3.36968e-06 3.31062e-07; +#A 0 -0.00105441 0.000592396 -0.000363603 0.000240721 0.00017041 8.96674e-06 +-6.95604e-05 -5.47096e-05 -4.00485e-05 -2.83591e-05 -1.84077e-05 -9.25315e-06 +-8.68906e-07 7.82074e-06 1.56576e-05 1.07988e-06; #X coords 0 1 15 -1 200 140 1; #X restore 46 -234 graph; #N canvas 6 433 450 300 diff 0; Added: trunk/examples/puredata/tonality_from_subbands.pd =================================================================== --- trunk/examples/puredata/tonality_from_subbands.pd (rev 0) +++ trunk/examples/puredata/tonality_from_subbands.pd 2008-02-16 20:13:05 UTC (rev 118) @@ -0,0 +1,160 @@ +#N canvas 493 51 587 478 10; +#X obj 82 212 xtract~ spectrum; +#N canvas 9 75 450 300 mag_spectrum 0; +#X obj 260 64 block~ 512; +#N canvas 0 0 450 300 (subpatch) 0; +#X array mag_spectrum 512 float 3; +#A 0 0.00791511 0.00796441 0.00804782 0.00816725 0.00832556 0.00852671 +0.00877601 0.00908054 0.00944968 0.00989593 0.0104362 0.0110935 0.0119005 +0.0129037 0.0141728 0.0158165 0.0180132 0.0210785 0.0256274 0.0330392 +0.0471787 0.0845833 0.462538 0.12868 0.0556718 0.0352146 0.0256003 +0.0200227 0.0163861 0.013831 0.0119397 0.0104852 0.00933302 0.00839885 +0.00762689 0.00697887 0.00642763 0.00595337 0.00554132 0.00518025 0.00486145 +0.00457808 0.00432469 0.00409689 0.00389113 0.00370479 0.00353334 0.00337798 +0.00323515 0.00310359 0.00298209 0.00286958 0.00276511 0.00266788 0.00257719 +0.00249241 0.00241301 0.00233849 0.00226844 0.00220248 0.00214026 0.00208149 +0.00202589 0.00197323 0.00192327 0.00187583 0.00183072 0.00178779 0.00174693 +0.00170751 0.00167039 0.00163477 0.00160066 0.00156795 0.00153673 0.00150668 +0.00147784 0.00145013 0.00142347 0.00139785 0.00137317 0.00134938 0.00132645 +0.00130433 0.00128297 0.00126234 0.0012424 0.00122312 0.00120446 0.0011864 +0.00116891 0.00115197 0.00113544 0.00111958 0.00110411 0.0010891 0.00107452 +0.00106035 0.00104659 0.00103319 0.00102017 0.00100749 0.000995155 +0.000983141 0.000971438 0.000960027 0.000948909 0.000938068 0.000927495 +0.000917176 0.000907107 0.000897275 0.000887676 0.000878296 0.000869136 +0.000860182 0.000851426 0.000842866 0.000834491 0.0008263 0.000818288 +0.000810442 0.000802759 0.000795238 0.000787864 0.00078067 0.000773593 +0.000766665 0.000759872 0.000753206 0.000746684 0.000740281 0.000733997 +0.000727835 0.000721787 0.00071585 0.000710022 0.000704302 0.000698687 +0.000693163 0.000687744 0.00068242 0.000677189 0.000672046 0.000666989 +0.000662008 0.000657152 0.000652346 0.000647625 0.000642983 0.00063827 +0.000633902 0.00062948 0.00062513 0.000620847 0.00061663 0.00061248 +0.000608394 0.000604371 0.00060041 0.000596508 0.000592662 0.000588881 +0.000585149 0.000581476 0.000577854 0.000574287 0.000570768 0.0005673 +0.000563885 0.000560517 0.000557198 0.000553921 0.000550691 0.000547506 +0.000544363 0.00054127 0.000538212 0.000535196 0.000532221 0.000529285 +0.000526391 0.000523531 0.000520713 0.00051793 0.000515163 0.00051246 +0.000509783 0.00050714 0.000504528 0.000501949 0.000499401 0.000496887 +0.000494399 0.000491941 0.000489499 0.000486984 0.000484886 0.00048249 +0.000480167 0.000477879 0.00047517 0.000473408 0.000471204 0.000469028 +0.000466878 0.000464756 0.000462657 0.000460551 0.000458529 0.000456502 +0.000454496 0.000452516 0.000450556 0.000448618 0.000446703 0.000444806 +0.000442933 0.000441081 0.000439249 0.000437435 0.000435644 0.000433869 +0.000432115 0.00043038 0.000428663 0.000426967 0.000425283 0.000423621 +0.000421977 0.000420346 0.000418718 0.000417151 0.000415575 0.000414008 +0.000412461 0.000410933 0.000409421 0.000407924 0.000406438 0.00040497 +0.000403515 0.000402073 0.000400648 0.000399229 0.000397818 0.000396404 +0.000394843 0.000394005 0.000392514 0.000391154 0.000389825 0.000388485 +0.00038723 0.000385942 0.000384692 0.000383438 0.000382193 0.000380966 +0.000379752 0.000378546 0.000377355 0.000376173 0.000375004 0.000373846 +0.000372698 0.000371564 0.000370438 0.000369319 0.000368222 0.000367128 +0.000366044 0.00036497 0.000363896 0.000362854 0.000361811 0.000360777 +0.000359753 0.000358738 0.000357735 0.000356738 0.000355751 0.000354775 +0.000353804 0.000352844 0.000351894 0.000350951 0.000350019 0.000349093 +0.000348178 0.000347267 0.000346367 0.000345476 0.000344592 0.000343716 +0.000342849 0.000341989 0.000341133 0.000340284 0.000339464 0.000338628 +0.000337809 0.000336992 0.000336174 0.000335386 0.000334592 0.000333804 +0.000333026 0.000332255 0.000331489 0.000330732 0.000329979 0.000329234 +0.000328496 0.000327764 0.000327041 0.000326322 0.000325609 0.000324903 +0.000324195 0.000323522 0.000322828 0.000322148 0.000321469 0.000320755 +0.000320146 0.000319485 0.000318837 0.000318193 0.000317549 0.000316917 +0.000316288 0.000315666 0.000315051 0.000314437 0.000313833 0.000313232 +0.000312637 0.000312049 0.000311464 0.000310884 0.000310312 0.000309744 +0.000309181 0.000308621 0.000308068 0.00030752 0.000306974 0.00030644 +0.000305907 0.000305374 0.000304852 0.000304332 0.000303818 0.00030331 +0.000302803 0.000302303 0.000301806 0.000301317 0.000300826 0.000300345 +0.000299868 0.000299394 0.000298923 0.000298458 0.000297995 0.000297538 +0.000297083 0.000296631 0.000296177 0.000295711 0.000295329 0.000294857 +0.000294385 0.000293858 0.00029202 0.00029358 0.000292995 0.000292537 +0.000292112 0.000291698 0.000291297 0.000290902 0.00029051 0.000290124 +0.000289743 0.000289366 0.000288996 0.000288627 0.000288263 0.0002879 +0.000287544 0.000287195 0.000286843 0.000286509 0.000286161 0.000285818 +0.000285489 0.000285158 0.000284832 0.000284511 0.000284184 0.000283871 +0.000283558 0.00028325 0.000282946 0.000282636 0.000282341 0.000282046 +0.000281753 0.000281465 0.000281177 0.000280893 0.000280613 0.000280336 +0.000280061 0.000279788 0.000279522 0.000279243 0.000278967 0.000278676 +0.000278261 0.000278674 0.000278138 0.000277848 0.000277583 0.000277294 +0.000277122 0.000276878 0.000276643 0.000276415 0.000276191 0.000275971 +0.000275756 0.00027554 0.000275331 0.000275124 0.000274919 0.000274721 +0.000274521 0.000274329 0.000274132 0.00027394 0.000273764 0.00027358 +0.000273397 0.000273221 0.000273038 0.000272878 0.000272708 0.000272543 +0.000272381 0.000272217 0.000272063 0.000271911 0.000271758 0.00027161 +0.000271463 0.00027132 0.000271182 0.000271044 0.00027091 0.000270778 +0.000270653 0.000270522 0.0002704 0.000270284 0.000270164 0.000270048 +0.000269937 0.00026983 0.000269723 0.00026963 0.000269475 0.000269405 +0.000269311 0.00026922 0.000269133 0.000269041 0.000268957 0.000268874 +0.000268794 0.000268718 0.000268642 0.00026857 0.000268503 0.000268438 +0.000268366 0.000268309 0.000268254 0.000268193 0.000268139 0.000268089 +0.000268038 0.000268001 0.000267953 0.000267913 0.000267873 0.000267822 +0.000267814 0.000267781 0.000267753 0.000267727 0.000267703 0.000267684 +0.000267668 0.000267654 0.000267642 0.000267632 0.000267626 0.000267624 +0.0751003; +#X coords 0 1 511 0 200 140 1; +#X restore 125 121 graph; +#X restore 245 43 pd mag_spectrum; +#X obj 82 247 tabsend~ mag_spectrum; +#X obj 244 15 block~ 1024; +#X obj 82 46 noise~; +#N canvas 9 100 450 653 tonality 0; +#N canvas 0 0 450 300 (subpatch) 0; +#X array subbands 8 float 5; +#A 0 0.459222 0.00349705 0.00161501 0.00109469 0.000855802 0.000726442 +0.000653362 0; +#X coords 0 1 7 -1 200 140 1; +#X restore 35 -128 graph; +#X obj 60 73 tabreceive~ subbands; +#X obj 366 -129 block~ 8; +#X obj 61 127 xtract~ flatness 8; +#X msg 173 200 list \$1; +#X obj 30 227 xtract~ flatness_db 8; +#X obj 35 283 xtract~ tonality 8; +#X msg 156 257 list \$1; +#X obj 37 353 outlet; +#X connect 1 0 3 0; +#X connect 3 0 4 0; +#X connect 4 0 5 1; +#X connect 5 0 7 0; +#X connect 6 0 8 0; +#X connect 7 0 6 1; +#X restore 282 354 pd tonality; +#X floatatom 282 414 5 0 0 0 - - -; +#X obj 82 186 *~ 0; +#X obj 122 186 *~ 0; +#X obj 144 120 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 12700 1; +#N canvas 3 50 450 300 xfade 0; +#X obj 183 139 -; +#X obj 183 170 outlet; +#X obj 183 30 inlet; +#X obj 272 175 outlet; +#X obj 183 87 t a a; +#X msg 183 116 1 \$1; +#X obj 183 58 / 127; +#X connect 0 0 1 0; +#X connect 2 0 6 0; +#X connect 4 0 5 0; +#X connect 4 1 3 0; +#X connect 5 0 0 0; +#X connect 6 0 4 0; +#X restore 141 145 pd xfade; +#N canvas 262 411 450 300 subbands 0; +#X obj 89 114 tabreceive~ mag_spectrum; +#X obj 263 78 loadbang; +#X obj 88 197 tabsend~ subbands; +#X obj 362 28 block~ 512; +#X obj 88 156 xtract~ subbands 512; +#X msg 263 113 list 35 8 1 0; +#X connect 0 0 4 0; +#X connect 1 0 5 0; +#X connect 4 0 2 0; +#X connect 5 0 4 1; +#X restore 84 297 pd subbands; +#X obj 122 77 osc~ 1000; +#X connect 0 0 2 0; +#X connect 4 0 7 0; +#X connect 5 0 6 0; +#X connect 7 0 0 0; +#X connect 8 0 0 0; +#X connect 9 0 10 0; +#X connect 10 0 7 1; +#X connect 10 1 8 1; +#X connect 12 0 8 0; Modified: trunk/examples/puredata/xtract~.c =================================================================== --- trunk/examples/puredata/xtract~.c 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/examples/puredata/xtract~.c 2008-02-16 20:13:05 UTC (rev 118) @@ -50,6 +50,7 @@ t_int feature, is_scalar, is_subframe, + argv_type, init_blocksize, done_init; t_symbol *feature_name; @@ -123,11 +124,13 @@ static void xtract_dsp(t_xtract_tilde *x, t_signal **sp) { - if(!x->is_scalar) + if(!x->is_scalar){ dsp_add(xtract_perform_vector, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); + } - else dsp_add(xtract_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); + else + dsp_add(xtract_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); } @@ -155,6 +158,7 @@ N = BLOCKSIZE; x->argv = NULL; + x->argv_type = 0; x->done_init = 0; x->is_scalar = 0; x->is_subframe = 0; @@ -203,6 +207,8 @@ n_args = fd[f].argc; type = fd[f].argv.type; + x->argv_type = type; + if(n_args){ for(n = 0; n < n_args; n++){ argv_max = &fd[f].argv.max[n]; @@ -335,8 +341,17 @@ x->argv = getbytes(argc * sizeof(float)); - while(argc--) - ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); + while(argc--){ + switch(x->argv_type){ + case XTRACT_INT: + ((t_int *)x->argv)[argc] = (int)atom_getfloat(&argv[argc]); + break; + case XTRACT_FLOAT: + default: + ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); + break; + } + } /* }*/ } Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/src/descriptors.c 2008-02-16 20:13:05 UTC (rev 118) @@ -71,7 +71,7 @@ *argv_min = XTRACT_ANY; *argv_max = XTRACT_ANY; *argv_def = XTRACT_ANY; - *argv_unit = XTRACT_ANY; + *argv_unit = XTRACT_DBFS; break; case XTRACT_SPECTRAL_INHARMONICITY: *argv_min = 0.f; @@ -86,6 +86,12 @@ *argv_def = XTRACT_SR_DEFAULT; *argv_unit = XTRACT_HERTZ; break; + case XTRACT_FLATNESS_DB: + *argv_min = 0; + *argv_max = 1.0; + *argv_def = XTRACT_ANY; + *argv_unit = XTRACT_DBFS; + break; /* argc = 2 */; case XTRACT_ROLLOFF: *argv_min = XTRACT_FFT_BANDS_MIN; @@ -165,9 +171,9 @@ *(argv_def + 2) = 0; *(argv_unit + 2) = XTRACT_NONE; *(argv_min + 3) = 0; - *(argv_max + 3) = 1; + *(argv_max + 3) = XTRACT_ANY; *(argv_def + 3) = 0; - *(argv_unit + 3) = XTRACT_NONE; + *(argv_unit + 3) = XTRACT_BINS; break; case XTRACT_BARK_COEFFICIENTS: /* BARK_COEFFICIENTS is special because argc = BARK_BANDS */ @@ -206,9 +212,12 @@ case XTRACT_SPECTRAL_INHARMONICITY: *argv_donor = XTRACT_FAILSAFE_F0; break; - case XTRACT_TONALITY: + case XTRACT_FLATNESS_DB: *argv_donor = XTRACT_FLATNESS; break; + case XTRACT_TONALITY: + *argv_donor = XTRACT_FLATNESS_DB; + break; case XTRACT_LOWEST_VALUE: case XTRACT_F0: case XTRACT_FAILSAFE_F0: @@ -254,6 +263,12 @@ *(argv_donor + 2) = XTRACT_ANY; *(argv_donor + 3) = XTRACT_ANY; break; + case XTRACT_SUBBANDS: + *argv_donor = XTRACT_ANY; + *(argv_donor + 1) = XTRACT_ANY; + *(argv_donor + 2) = XTRACT_ANY; + *(argv_donor + 3) = XTRACT_ANY; + break; /* BARK_BANDS */ case XTRACT_BARK_COEFFICIENTS: *argv_donor = XTRACT_INIT_BARK; @@ -304,6 +319,7 @@ case XTRACT_POWER: case XTRACT_HPS: case XTRACT_PEAK_SPECTRUM: + case XTRACT_SUBBANDS: case XTRACT_MFCC: *data_format = XTRACT_SPECTRAL_MAGNITUDES; break; @@ -335,6 +351,7 @@ *data_format = XTRACT_AUDIO_SAMPLES; break; case XTRACT_TONALITY: + case XTRACT_FLATNESS_DB: *data_format = XTRACT_NO_DATA; break; case XTRACT_TRISTIMULUS_1: @@ -394,6 +411,7 @@ case XTRACT_NOISINESS: case XTRACT_CREST: case XTRACT_FLATNESS: + case XTRACT_FLATNESS_DB: case XTRACT_POWER: case XTRACT_BARK_COEFFICIENTS: case XTRACT_RMS_AMPLITUDE: @@ -408,6 +426,7 @@ case XTRACT_LPC: case XTRACT_LPCC: case XTRACT_WINDOWED: + case XTRACT_SUBBANDS: *data_unit = XTRACT_ANY; break; case XTRACT_SPECTRAL_MEAN: @@ -444,7 +463,6 @@ strcpy(desc, "Extract the mean of an input vector"); strcpy(p_desc, "Extract the mean of a range of values"); strcpy(author, ""); - d->argv.type = XTRACT_NONE; break; case XTRACT_VARIANCE: strcpy(name, "variance"); @@ -660,6 +678,14 @@ strcpy(author, "Rabiner and Juang"); *year = 1993; break; + case XTRACT_SUBBANDS: + strcpy(name, "subbands"); + strcpy(p_name, "Sub band coefficients"); + strcpy(desc, "Extract subband coefficients from spectral magnitudes"); + strcpy(p_desc, + "Extract subband coefficients from spectral magnitudes"); + strcpy(author, ""); + break; case XTRACT_BARK_COEFFICIENTS: strcpy(name, "bark_coefficients"); strcpy(p_name, "Bark Coefficients"); @@ -740,6 +766,15 @@ strcpy(author, "Tristan Jehan"); *year = 2005; break; + case XTRACT_FLATNESS_DB: + strcpy(name, "flatness_db"); + strcpy(p_name, "Log Spectral Flatness"); + strcpy(desc, "Extract the log spectral flatness of a spectrum"); + strcpy(p_desc, + "Extract the log spectral flatness of an audio spectrum"); + strcpy(author, "Peeters"); + *year = 2003; + break; case XTRACT_SPREAD: strcpy(name, "spread"); strcpy(p_name, "Spectral Spread"); @@ -933,6 +968,7 @@ case XTRACT_LOWEST_VALUE: case XTRACT_F0: case XTRACT_FAILSAFE_F0: + case XTRACT_FLATNESS_DB: case XTRACT_TONALITY: *argc = 1; *argv_type = XTRACT_FLOAT; @@ -955,6 +991,10 @@ *argc = 4; *argv_type = XTRACT_FLOAT; break; + case XTRACT_SUBBANDS: + *argc = 4; + *argv_type = XTRACT_INT; + break; case XTRACT_MFCC: *argc = 1; *argv_type = XTRACT_MEL_FILTER; @@ -1034,6 +1074,7 @@ case XTRACT_ROLLOFF: case XTRACT_LOUDNESS: case XTRACT_FLATNESS: + case XTRACT_FLATNESS_DB: case XTRACT_TONALITY: case XTRACT_CREST: case XTRACT_NOISINESS: @@ -1060,6 +1101,7 @@ case XTRACT_BARK_COEFFICIENTS: case XTRACT_PEAK_SPECTRUM: case XTRACT_SPECTRUM: + case XTRACT_SUBBANDS: case XTRACT_AUTOCORRELATION_FFT: case XTRACT_MFCC: case XTRACT_LPC: @@ -1108,6 +1150,7 @@ case XTRACT_ROLLOFF: case XTRACT_LOUDNESS: case XTRACT_FLATNESS: + case XTRACT_FLATNESS_DB: case XTRACT_TONALITY: case XTRACT_CREST: case XTRACT_NOISINESS: @@ -1130,6 +1173,7 @@ case XTRACT_BARK_COEFFICIENTS: case XTRACT_PEAK_SPECTRUM: case XTRACT_SPECTRUM: + case XTRACT_SUBBANDS: case XTRACT_AUTOCORRELATION_FFT: case XTRACT_MFCC: case XTRACT_LPC: @@ -1204,6 +1248,11 @@ *result_min = 0.f; *result_max = 1.f; break; + case XTRACT_FLATNESS_DB: + *result_unit = XTRACT_DBFS; + *result_min = XTRACT_ANY; /* FIX: check this */ + *result_max = XTRACT_ANY; + break; case XTRACT_LOUDNESS: case XTRACT_FLATNESS: case XTRACT_TONALITY: @@ -1233,6 +1282,7 @@ case XTRACT_AMDF: case XTRACT_ASDF: case XTRACT_DCT: + case XTRACT_SUBBANDS: case XTRACT_WINDOWED: *result_format = XTRACT_ARBITRARY_SERIES; *result_unit = XTRACT_ANY; Modified: trunk/src/libxtract.c =================================================================== --- trunk/src/libxtract.c 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/src/libxtract.c 2008-02-16 20:13:05 UTC (rev 118) @@ -84,6 +84,7 @@ xtract_harmonic_spectrum, xtract_lpc, xtract_lpcc, + xtract_subbands, /* xtract_helper.h */ xtract_windowed }; Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/src/scalar.c 2008-02-16 20:13:05 UTC (rev 118) @@ -535,14 +535,14 @@ int xtract_flatness_db(const float *data, const int N, const void *argv, float *result){ - float flatness_db; + float flatness; - flatness_db = *(float *)argv; + flatness = *(float *)argv; - if (flatness_db <= 0) - flatness_db = XTRACT_LOG_LIMIT; + if (flatness <= 0) + flatness = XTRACT_LOG_LIMIT; - *result = 10 * log10f(flatness_db); + *result = 10 * log10f(flatness); return XTRACT_SUCCESS; Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/src/vector.c 2008-02-16 20:13:05 UTC (rev 118) @@ -545,9 +545,10 @@ int cep_length; if(argv == NULL) - cep_length = N - 1; + cep_length = N - 1; /* FIX: if we're going to have default values, they should come from the descriptor */ else - cep_length = (int)((float *)argv)[0]; + cep_length = *(int *)argv; + //cep_length = (int)((float *)argv)[0]; memset(result, 0, cep_length * sizeof(float)); @@ -584,20 +585,22 @@ scale = argi[2]; start = argi[3]; - if(scale == XTRACT_LINEAR_SUBBANDS) bw = floorf((N - start) / nbands); else bw = start; lower = start; + rv = XTRACT_SUCCESS; for(n = 0; n < nbands; n++){ /* Bounds sanity check */ - if(lower + bw >= N) - result[n] = 0.f + if(lower >= N || lower + bw >= N){ + // printf("n: %d\n", n); + result[n] = 0.f; continue; + } rv = xtract[xtract_func](data+lower, bw, NULL, &result[n]); Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2008-02-15 15:49:49 UTC (rev 117) +++ trunk/xtract/libxtract.h 2008-02-16 20:13:05 UTC (rev 118) @@ -68,7 +68,7 @@ * @{ */ -#define XTRACT_FEATURES 59 +#define XTRACT_FEATURES 60 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ enum xtract_features_ { @@ -202,6 +202,7 @@ XTRACT_DBFS, XTRACT_DBFS_HERTZ, XTRACT_PERCENT, + XTRACT_BINS, XTRACT_SONE } xtract_unit_t; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2008-03-26 13:04:38
|
Revision: 119 http://libxtract.svn.sourceforge.net/libxtract/?rev=119&view=rev Author: postlude Date: 2008-03-26 06:04:33 -0700 (Wed, 26 Mar 2008) Log Message: ----------- - Fixed build fail if --enable-fft not specified - Fixed doxygen build so that it includes libxtract.h - Doxygen tweaks Modified Paths: -------------- trunk/ChangeLog trunk/configure.in trunk/doc/Makefile.am trunk/doc/documentation.doxygen.in trunk/src/init.c trunk/xtract/xtract_delta.h trunk/xtract/xtract_macros.h trunk/xtract/xtract_scalar.h trunk/xtract/xtract_vector.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/ChangeLog 2008-03-26 13:04:33 UTC (rev 119) @@ -1,3 +1,9 @@ +2008-3-26 Jamie Bullock <ja...@po...> + * version 0.6.0 + * Fixed build fail if --enable-fft not specified + * Fixed doxygen build so that it includes libxtract.h + * Doxygen tweaks + 2008-2-16 Jamie Bullock <ja...@po...> * version 0.6.0 * Added to pd example the ability to differentiate between different Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/configure.in 2008-03-26 13:04:33 UTC (rev 119) @@ -4,7 +4,7 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 6) # Increment for fixes -m4_define(libxtract_fix_version, 0) +m4_define(libxtract_fix_version, 1) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/doc/Makefile.am 2008-03-26 13:04:33 UTC (rev 119) @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in #Stolen from Steve Harris' liblo, thanks Steve! -MAINTAINERCLEANFILES=Makefile.in +MAINTAINERCLEANFILES=Makefile.in config.log CLEANFILES=doxygen-build.stamp Modified: trunk/doc/documentation.doxygen.in =================================================================== --- trunk/doc/documentation.doxygen.in 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/doc/documentation.doxygen.in 2008-03-26 13:04:33 UTC (rev 119) @@ -1,4 +1,4 @@ -# Doxyfile 1.4.6 +# Doxyfile 1.5.3 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -14,6 +14,14 @@ # Project related configuration options #--------------------------------------------------------------------------- +# This tag specifies the encoding used for all characters in the config file that +# follow. The default is UTF-8 which is also the encoding used for all text before +# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into +# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of +# possible encodings. + +DOXYFILE_ENCODING = UTF-8 + # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. @@ -30,7 +38,7 @@ # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = . +OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -45,24 +53,14 @@ # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. OUTPUT_LANGUAGE = English -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). @@ -135,11 +133,19 @@ # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. @@ -204,6 +210,11 @@ BUILTIN_STL_SUPPORT = NO +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default @@ -228,7 +239,7 @@ # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = YES +EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. @@ -253,6 +264,13 @@ EXTRACT_LOCAL_METHODS = NO +# If this flag is set to YES, the members of anonymous namespaces will be extracted +# and appear in the documentation as a namespace called 'anonymous_namespace{file}', +# where file will be replaced with the base name of the file that contains the anonymous +# namespace. By default anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the @@ -459,8 +477,16 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @top_srcdir@/xtract/libxtract.h @top_srcdir@/xtract/xtract_scalar.h @top_srcdir@/xtract/xtract_vector.h +INPUT = @top_srcdir@/xtract +#INPUT = +# This tag can be used to specify the character encoding of the source files that +# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default +# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. +# See http://www.gnu.org/software/libiconv for the list of possible encodings. + +INPUT_ENCODING = UTF-8 + # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left @@ -496,6 +522,13 @@ EXCLUDE_PATTERNS = +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the output. +# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, +# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). @@ -554,7 +587,9 @@ # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. +# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH +# then you must also enable this option. If you don't then doxygen will produce +# a warning and turn it on anyway SOURCE_BROWSER = NO @@ -581,6 +616,13 @@ REFERENCES_RELATION = YES +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source @@ -673,6 +715,14 @@ GENERATE_HTMLHELP = NO +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be @@ -748,7 +798,7 @@ # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. -LATEX_CMD_NAME = latex +LATEX_CMD_NAME = pdflatex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the @@ -760,13 +810,13 @@ # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. -COMPACT_LATEX = NO +COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. -PAPER_TYPE = a4wide +PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. @@ -785,13 +835,13 @@ # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. -PDF_HYPERLINKS = NO +PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. -USE_PDFLATEX = NO +USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep @@ -1005,7 +1055,7 @@ # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = XTRACT_H XTRACT_FFT +PREDEFINED = XTRACT_FFT # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. @@ -1078,6 +1128,14 @@ CLASS_DIAGRAMS = YES +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to +# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to +# specify the directory where the mscgen tool resides. If left empty the tool is assumed to +# be found in the default search path. + +MSCGEN_PATH = + # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. @@ -1089,7 +1147,7 @@ # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = NO +HAVE_DOT = YES # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and @@ -1135,7 +1193,7 @@ INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected @@ -1143,6 +1201,14 @@ CALL_GRAPH = NO +# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. @@ -1172,31 +1238,23 @@ DOTFILE_DIRS = -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the number +# of direct children of the root node in a graph is already larger than +# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -MAX_DOT_GRAPH_WIDTH = 1024 +DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that a graph may be further truncated if the graph's -# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH -# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), -# the graph is not depth-constrained. +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/src/init.c 2008-03-26 13:04:33 UTC (rev 119) @@ -285,8 +285,10 @@ void _init()· #endif { +#ifdef XTRACT_FFT fft_plans.spectrum_plan = NULL; fft_plans.autocorrelation_fft_plan_1 = NULL; fft_plans.autocorrelation_fft_plan_2 = NULL; fft_plans.dct_plan = NULL; +#endif } Modified: trunk/xtract/xtract_delta.h =================================================================== --- trunk/xtract/xtract_delta.h 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/xtract/xtract_delta.h 2008-03-26 13:04:33 UTC (rev 119) @@ -18,7 +18,7 @@ * USA. */ -/** \file xtract_delta.h: declares functions that extract a feature as a single value or vector from more than one input vector */ +/** \file xtract_delta.h: declares functions that scalar or vector value from 2 or more input vectors */ #ifndef XTRACT_DELTA_H #define XTRACT_DELTA_H @@ -27,15 +27,23 @@ extern "C" { #endif +/** + * \defgroup delta `delta' extraction functions + * + * Functions that extract a scalar or vector value from 2 or more input vectors + * + * @{ + */ + #include "xtract_types.h" -/* \brief Extract flux +/** \brief Extract flux * * An alias for xtract_lnorm() */ int xtract_flux(const float *data, const int N, const void *argv , float *result); -/* \brief Extract the L-norm of a vector +/** \brief Extract the L-norm of a vector * * \param *data: a pointer to the first element in an array of floats representing the difference between two subsequent frames of output from a vector-based feature e.g. the *result from xtract_difference_vector() * \param N: the length of the array pointed to by *data @@ -67,6 +75,8 @@ /*xtract_frame_tracker *xf */ /*float frames*/ +/** @} */ + #ifdef __cplusplus } #endif Modified: trunk/xtract/xtract_macros.h =================================================================== --- trunk/xtract/xtract_macros.h 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/xtract/xtract_macros.h 2008-03-26 13:04:33 UTC (rev 119) @@ -18,8 +18,6 @@ * USA. */ - - /** \file xtract_macros.h: defines useful public macros */ #ifndef XTRACT_MACROS_H Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/xtract/xtract_scalar.h 2008-03-26 13:04:33 UTC (rev 119) @@ -29,8 +29,9 @@ /** * \defgroup scalar scalar extraction functions + * + * Functions that extract a feature as a single value from an input vector * - * Defines scalar extraction functions, and their parameters. * @{ */ Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2008-02-16 20:13:05 UTC (rev 118) +++ trunk/xtract/xtract_vector.h 2008-03-26 13:04:33 UTC (rev 119) @@ -18,7 +18,7 @@ * USA. */ -/* xtract_scalar.h: declares functions that extract a feature as a vector from an input vector */ +/** \file xtract_vector.h: declares functions that extract a feature as a vector from an input vector */ #ifndef XTRACT_VECTOR_H #define XTRACT_VECTOR_H @@ -30,7 +30,8 @@ /** * \defgroup vector vector extraction functions * - * Defines vector extraction functions, and their parameters. + * Functions that extract a feature as a vector from an input vector + * * @{ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2008-05-04 11:02:54
|
Revision: 120 http://libxtract.svn.sourceforge.net/libxtract/?rev=120&view=rev Author: postlude Date: 2008-05-04 04:02:40 -0700 (Sun, 04 May 2008) Log Message: ----------- Fixed bug in peak interpolation algorithm in xtract_peak_spectrum() Modified Paths: -------------- trunk/src/delta.c trunk/src/scalar.c trunk/src/vector.c trunk/xtract/xtract_delta.h trunk/xtract/xtract_scalar.h Modified: trunk/src/delta.c =================================================================== --- trunk/src/delta.c 2008-03-26 13:04:33 UTC (rev 119) +++ trunk/src/delta.c 2008-05-04 11:02:40 UTC (rev 120) @@ -26,6 +26,7 @@ int xtract_flux(const float *data, const int N, const void *argv , float *result){ + /* FIX: don't be lazy -- take the lnorm of the difference vector! */ return xtract_lnorm(data, N, argv, result); } Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2008-03-26 13:04:33 UTC (rev 119) +++ trunk/src/scalar.c 2008-05-04 11:02:40 UTC (rev 120) @@ -434,6 +434,8 @@ den += data[n]; } + /* FIX: spectral spread is mathematically equivalent to spectral variance -- + * here we are computing the spectral standard deviation */ *result = sqrtf(num / den); return XTRACT_SUCCESS; Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2008-03-26 13:04:33 UTC (rev 119) +++ trunk/src/vector.c 2008-05-04 11:02:40 UTC (rev 120) @@ -436,7 +436,7 @@ for(n = 1; n < N; n++){ if(input[n] >= threshold){ if(input[n] > input[n - 1] && input[n] > input[n + 1]){ - result[N + n] = q * (n + (p = .5 * (y = input[n-1] - + result[N + n] = q * (n + (p = .5 * ((y = input[n-1]) - (y3 = input[n+1])) / (input[n - 1] - 2 * (y2 = input[n]) + input[n + 1]))); result[n] = y2 - .25 * (y - y3) * p; Modified: trunk/xtract/xtract_delta.h =================================================================== --- trunk/xtract/xtract_delta.h 2008-03-26 13:04:33 UTC (rev 119) +++ trunk/xtract/xtract_delta.h 2008-05-04 11:02:40 UTC (rev 120) @@ -39,6 +39,7 @@ /** \brief Extract flux * + * \note FIX: don't be lazy -- take the lnorm of the difference vector! * An alias for xtract_lnorm() */ int xtract_flux(const float *data, const int N, const void *argv , float *result); Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2008-03-26 13:04:33 UTC (rev 119) +++ trunk/xtract/xtract_scalar.h 2008-05-04 11:02:40 UTC (rev 120) @@ -394,6 +394,8 @@ * \param *result: the pitch of N values from the array pointed to by *data * * This algorithm is based on the AMDF, with peak and centre clipping. It would benefit from further improvements to improve noise robustness and overall efficiency + * + * It is based on suggestion by Robert Bristow-Johnson in a discussion on the comp.dsp mailing list, subject "Reference implementation of pitch detection" * */ int xtract_f0(const float *data, const int N, const void *argv, float *result); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |