Thread: [Libxtract-commits] SF.net SVN: libxtract: [61] trunk
Status: Alpha
Brought to you by:
postlude
From: <pos...@us...> - 2007-01-29 15:12:14
|
Revision: 61 http://libxtract.svn.sourceforge.net/libxtract/?rev=61&view=rev Author: postlude Date: 2007-01-29 07:11:59 -0800 (Mon, 29 Jan 2007) Log Message: ----------- Version 0.4.0. Updated ChangeLog Modified Paths: -------------- trunk/ChangeLog trunk/configure.in Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-01-29 12:34:50 UTC (rev 60) +++ trunk/ChangeLog 2007-01-29 15:11:59 UTC (rev 61) @@ -1,3 +1,12 @@ +2007-01-29 Jamie Bullock <ja...@po...> + * version 0.4.0 + * Added namespacing for macros and enumerations + * Made most macros private + * Rationalised formats for data (*data and argv) to create consistency + between functions + * Added spectral_mean() and friends + * Added feature descriptors (see libxtract.h/descriptors.c + 2006-12-15 Jamie Bullock <ja...@po...> * version 0.3.4 * Changed xtract_lowest_match(), to xtract_lowest(). It just returns the Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-01-29 12:34:50 UTC (rev 60) +++ trunk/configure.in 2007-01-29 15:11:59 UTC (rev 61) @@ -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, 3) +m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 4) +m4_define(libxtract_fix_version, 0) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-02-12 17:11:55
|
Revision: 62 http://libxtract.svn.sourceforge.net/libxtract/?rev=62&view=rev Author: postlude Date: 2007-02-12 09:11:31 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Various minor fixes Modified Paths: -------------- trunk/configure.in trunk/examples/puredata/xtract~.c trunk/src/descriptors.c trunk/src/init.c trunk/src/libxtract.c trunk/src/scalar.c trunk/src/vector.c trunk/src/xtract_macros_private.h trunk/xtract/libxtract.h trunk/xtract/xtract_scalar.h trunk/xtract/xtract_vector.h Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/configure.in 2007-02-12 17:11:31 UTC (rev 62) @@ -4,7 +4,7 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # 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/examples/puredata/xtract~.c =================================================================== --- trunk/examples/puredata/xtract~.c 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/examples/puredata/xtract~.c 2007-02-12 17:11:31 UTC (rev 62) @@ -140,7 +140,7 @@ if(n_args){ for(n = 0; n < n_args; n++){ argv_max = &fd[f].argv.max[n]; - post("Argument %d, max: %.2f", n, *argv_max); + //post("Argument %d, max: %.2f", n, *argv_max); } if(type == XTRACT_MEL_FILTER){ x->memory.argv = (size_t)(n_args * sizeof(xtract_mel_filter)); Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/src/descriptors.c 2007-02-12 17:11:31 UTC (rev 62) @@ -57,7 +57,6 @@ case XTRACT_SPECTRAL_STANDARD_DEVIATION: case XTRACT_SPECTRAL_AVERAGE_DEVIATION: case XTRACT_SPECTRAL_INHARMONICITY: - case XTRACT_ODD_EVEN_RATIO: case XTRACT_LOWEST_VALUE: case XTRACT_F0: case XTRACT_FAILSAFE_F0: @@ -115,6 +114,8 @@ case XTRACT_AUTOCORRELATION: case XTRACT_AMDF: case XTRACT_ASDF: + case XTRACT_NONZERO_COUNT: + case XTRACT_ODD_EVEN_RATIO: default: *argc = 0; break; @@ -141,7 +142,6 @@ *argv_def = XTRACT_ANY; *argv_unit = XTRACT_ANY; case XTRACT_SPECTRAL_INHARMONICITY: - case XTRACT_ODD_EVEN_RATIO: *argv_min = 0.f; *argv_max = XTRACT_SR_UPPER_LIMIT / 2; *argv_def = XTRACT_FUNDAMENTAL_DEFAULT; @@ -235,7 +235,6 @@ *argv_donor = XTRACT_SPECTRAL_MEAN; break; case XTRACT_SPECTRAL_INHARMONICITY: - case XTRACT_ODD_EVEN_RATIO: *argv_donor = XTRACT_FAILSAFE_F0; break; case XTRACT_TONALITY: @@ -276,7 +275,7 @@ break; case XTRACT_CREST: *argv_donor = XTRACT_HIGHEST_VALUE; - *(argv_donor + 1) = XTRACT_SPECTRAL_MEAN; + *(argv_donor + 1) = XTRACT_MEAN; break; /* argc = BARK_BANDS */ case XTRACT_BARK_COEFFICIENTS: @@ -300,7 +299,6 @@ case XTRACT_LOWEST_VALUE: case XTRACT_HIGHEST_VALUE: case XTRACT_SUM: - case XTRACT_ZCR: *data_format = XTRACT_ARBITRARY_SERIES; break; case XTRACT_SPECTRAL_MEAN: @@ -311,8 +309,6 @@ case XTRACT_SPECTRAL_KURTOSIS: case XTRACT_SPECTRAL_CENTROID: case XTRACT_SPECTRAL_SLOPE: - case XTRACT_PEAK_SPECTRUM: - case XTRACT_HARMONIC_SPECTRUM: *data_format = XTRACT_SPECTRAL; break; case XTRACT_ROLLOFF: @@ -324,17 +320,17 @@ case XTRACT_SMOOTHNESS: case XTRACT_FLATNESS: case XTRACT_SPREAD: - case XTRACT_RMS_AMPLITUDE: case XTRACT_POWER: - case XTRACT_SHARPNESS: case XTRACT_HPS: + case XTRACT_PEAK_SPECTRUM: *data_format = XTRACT_SPECTRAL_MAGNITUDES; break; case XTRACT_SPECTRAL_INHARMONICITY: + case XTRACT_HARMONIC_SPECTRUM: *data_format = XTRACT_SPECTRAL_PEAKS; break; - case XTRACT_ODD_EVEN_RATIO: - *data_format = XTRACT_SPECTRAL_HARMONICS_FREQUENCIES; + case XTRACT_NONZERO_COUNT: + *data_format = XTRACT_SPECTRAL_PEAKS_MAGNITUDES; break; case XTRACT_F0: case XTRACT_FAILSAFE_F0: @@ -345,6 +341,8 @@ case XTRACT_DCT: case XTRACT_AMDF: case XTRACT_ASDF: + case XTRACT_ZCR: + case XTRACT_RMS_AMPLITUDE: *data_format = XTRACT_AUDIO_SAMPLES; break; case XTRACT_TONALITY: @@ -353,9 +351,11 @@ case XTRACT_TRISTIMULUS_1: case XTRACT_TRISTIMULUS_2: case XTRACT_TRISTIMULUS_3: + case XTRACT_ODD_EVEN_RATIO: *data_format = XTRACT_SPECTRAL_HARMONICS_MAGNITUDES; break; case XTRACT_LOUDNESS: + case XTRACT_SHARPNESS: *data_format = XTRACT_BARK_COEFFS; break; case XTRACT_FLUX: @@ -413,6 +413,7 @@ case XTRACT_SPECTRUM: case XTRACT_TONALITY: case XTRACT_LOUDNESS: + case XTRACT_NONZERO_COUNT: *data_unit = XTRACT_ANY; break; case XTRACT_SPECTRAL_MEAN: @@ -475,6 +476,24 @@ "Extract the average deviation of a range of values"); strcpy(author, ""); break; + case XTRACT_SKEWNESS: + strcpy(name, "skewness"); + strcpy(p_name, "Skewness"); + strcpy(desc, + "Extract the skewness of an input vector"); + strcpy(p_desc, + "Extract the skewness of a range of values"); + strcpy(author, ""); + break; + case XTRACT_KURTOSIS: + strcpy(name, "kurtosis"); + strcpy(p_name, "Kurtosis"); + strcpy(desc, + "Extract the kurtosis of an input vector"); + strcpy(p_desc, + "Extract the kurtosis of a range of values"); + strcpy(author, ""); + break; case XTRACT_SPECTRAL_MEAN: strcpy(name, "spectral_mean"); strcpy(p_name, "Spectral Mean"); @@ -555,23 +574,23 @@ strcpy(desc, "Extract the fundamental frequency of a signal"); strcpy(p_desc, "Extract the fundamental frequency of an audio signal"); - strcpy(author, ""); + strcpy(author, "Jamie Bullock"); break; case XTRACT_FAILSAFE_F0: strcpy(name, "failsafe_f0"); strcpy(p_name, "Fundamental Frequency (failsafe)"); - strcpy(desc, "Extract the fundamental frequency of a signal"); + strcpy(desc, "Extract the fundamental frequency of a signal (failsafe)"); strcpy(p_desc, - "Extract the fundamental frequency of an audio signal"); - strcpy(author, ""); + "Extract the fundamental frequency of an audio signal (failsafe)"); + strcpy(author, "Jamie Bullock"); break; case XTRACT_TONALITY: strcpy(name, "tonality"); strcpy(p_name, "Tonality"); strcpy(desc, "Extract the tonality of a spectrum"); strcpy(p_desc, "Extract the tonality an audio spectrum"); - strcpy(author, "Tristan Jehan"); - *year = 2005; + strcpy(author, "J. D. Johnston"); + *year = 1988; break; case XTRACT_SPECTRAL_SKEWNESS: strcpy(name, "spectral_skewness"); @@ -646,18 +665,18 @@ case XTRACT_IRREGULARITY_K: strcpy(name, "irregularity_k"); strcpy(p_name, "Irregularity I"); - strcpy(desc, "Extract the irregularity of a spectrum"); + strcpy(desc, "Extract the irregularity (type I) of a spectrum"); strcpy(p_desc, - "Extract the irregularity of an audio spectrum"); + "Extract the irregularity (type I) of an audio spectrum"); strcpy(author, "Krimphoff"); *year = 1994; break; case XTRACT_IRREGULARITY_J: strcpy(name, "irregularity_j"); strcpy(p_name, "Irregularity II"); - strcpy(desc, "Extract the irregularity of a spectrum"); + strcpy(desc, "Extract the irregularity (type II) of a spectrum"); strcpy(p_desc, - "Extract the irregularity of an audio spectrum"); + "Extract the irregularity (type II) of an audio spectrum"); strcpy(author, "Jensen"); *year = 1999; break; @@ -823,8 +842,8 @@ case XTRACT_AUTOCORRELATION_FFT: strcpy(name, "autocorrelation_fft"); strcpy(p_name, "Autocorrelation (FFT method)"); - strcpy(desc, "Extract the autocorrelation of a signal"); - strcpy(p_desc, "Extract the autocorrelation of an audio signal"); + strcpy(desc, "Extract the autocorrelation of a signal (fft method)"); + strcpy(p_desc, "Extract the autocorrelation of an audio signal (fft method)"); strcpy(author, ""); break; case XTRACT_DCT: @@ -856,6 +875,13 @@ strcpy(p_desc, "Extract the ASDF of an audio signal"); strcpy(author, ""); break; + case XTRACT_NONZERO_COUNT: + strcpy(name, "nonzero_count"); + strcpy(p_name, "Non-zero count"); + strcpy(desc, "Extract the number of non-zero elements in the input vector"); + strcpy(p_desc, "Extract the number of non-zero elements in an input spectrum"); + strcpy(author, ""); + break; default: strcpy(name, ""); strcpy(p_name, ""); @@ -875,7 +901,6 @@ case XTRACT_SPECTRAL_STANDARD_DEVIATION: case XTRACT_SPECTRAL_AVERAGE_DEVIATION: case XTRACT_SPECTRAL_INHARMONICITY: - case XTRACT_ODD_EVEN_RATIO: case XTRACT_LOWEST_VALUE: case XTRACT_F0: case XTRACT_FAILSAFE_F0: @@ -933,6 +958,8 @@ case XTRACT_AUTOCORRELATION: case XTRACT_AMDF: case XTRACT_ASDF: + case XTRACT_NONZERO_COUNT: + case XTRACT_ODD_EVEN_RATIO: default: *argc = 0; break; @@ -980,6 +1007,7 @@ case XTRACT_HPS: case XTRACT_F0: case XTRACT_FAILSAFE_F0: + case XTRACT_NONZERO_COUNT: *is_scalar = XTRACT_TRUE; break; case XTRACT_AUTOCORRELATION: @@ -1017,6 +1045,7 @@ case XTRACT_LOWEST_VALUE: case XTRACT_HIGHEST_VALUE: case XTRACT_SUM: + case XTRACT_NONZERO_COUNT: *result_unit = XTRACT_ANY; *result_min = XTRACT_ANY; *result_max = XTRACT_ANY; Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/src/init.c 2007-02-12 17:11:31 UTC (rev 62) @@ -122,16 +122,14 @@ } -int xtract_init_bark(int N, float nyquist, int *band_limits){ +int xtract_init_bark(int N, float sr, int *band_limits){ 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 M, bands = XTRACT_BARK_BANDS; + int bands = XTRACT_BARK_BANDS; - M = N >> 1; - while(bands--) - band_limits[bands] = edges[bands] / nyquist * M; + band_limits[bands] = edges[bands] / sr * N; /*FIX shohuld use rounding, but couldn't get it to work */ return XTRACT_SUCCESS; Modified: trunk/src/libxtract.c =================================================================== --- trunk/src/libxtract.c 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/src/libxtract.c 2007-02-12 17:11:31 UTC (rev 62) @@ -60,6 +60,7 @@ xtract_lowest_value, xtract_highest_value, xtract_sum, + xtract_nonzero_count, xtract_hps, xtract_f0, xtract_failsafe_f0, Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/src/scalar.c 2007-02-12 17:11:31 UTC (rev 62) @@ -53,7 +53,8 @@ int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result){ - *result = sqrt(*(float *)argv); + //*result = sqrt(*(float *)argv); + *result = sqrt(-40.); return XTRACT_SUCCESS; } @@ -74,7 +75,7 @@ int n = N; - float temp; + float temp = 0.f; while(n--){ temp = (data[n] - ((float *)argv)[0]) / ((float *)argv)[1]; @@ -83,6 +84,7 @@ *result /= N; + return XTRACT_SUCCESS; } @@ -142,17 +144,17 @@ while(m--){ A += amps[m]; - *result += pow((freqs[m] - *(float *)argv) * amps[m], 2); + *result += powf((freqs[m] - *(float *)argv) * amps[m], 2); } - *result = *result / (A - 1); + *result = *result / (A /*- 1*/); return XTRACT_SUCCESS; } int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result){ - *result = sqrt(*(float *)argv); + *result = sqrt(*(float *)argv); return XTRACT_SUCCESS; } @@ -240,14 +242,14 @@ int n = N; - float num = 0.f, den = 0.f; + double num = 0.f, den = 0.f; while(n--){ num += pow(data[n] - data[n+1], 2); den += pow(data[n], 2); } - *result = num / den; + *result = (float)(num / den); return XTRACT_SUCCESS; } @@ -322,20 +324,21 @@ int xtract_smoothness(const float *data, const int N, const void *argv, float *result){ - int n = N; + int n, M; float *input; input = (float *)malloc(N * sizeof(float)); - input = memcpy(input, data, N * sizeof(float)); + memcpy(input, data, N * sizeof(float)); if (input[0] <= 0) input[0] = 1; - if (input[1] <= 0) input[1] = 1; - for(n = 2; n < N; n++){ + M = N - 1; + + for(n = 1; n < M; n++){ if(input[n] <= 0) input[n] = 1; - *result += abs(20 * log(input[n-1]) - (20 * log(input[n-2]) + - 20 * log(input[n-1]) + 20 * log(input[n])) / 3); + *result += fabs(20 * log(input[n]) - (20 * log(input[n-1]) + + 20 * log(input[n]) + 20 * log(input[n+1])) / 3); } free(input); @@ -403,7 +406,7 @@ rv = XTRACT_SUCCESS; while(n--) - *result += pow(data[n], 0.23); + *result += powf(data[n], 0.23); return rv; } @@ -424,7 +427,7 @@ } } - num = pow(num, 1.f / N); + num = powf(num, 1.f / N); den /= N; if(num < XTRACT_VERY_SMALL_NUMBER) @@ -433,7 +436,7 @@ if(den < XTRACT_VERY_SMALL_NUMBER) den = XTRACT_VERY_SMALL_NUMBER; - *result = num / den; + *result = 10 * log10(num / den); return XTRACT_SUCCESS; @@ -445,9 +448,10 @@ sfm = *(float *)argv; - sfmdb = (sfm > 0 ? ((10 * log10(sfm)) / -60) : 0); + sfmdb = sfm / -60.f; *result = XTRACT_MIN(sfmdb, 1); + //*result = sfmdb; return XTRACT_SUCCESS; } @@ -506,8 +510,10 @@ freqs = data + n; while(n--){ - num += abs(freqs[n] - n * fund) * XTRACT_SQ(amps[n]); - den += XTRACT_SQ(amps[n]); + if(amps[n]){ + num += fabs(freqs[n] - n * fund) * XTRACT_SQ(amps[n]); + den += XTRACT_SQ(amps[n]); + } } *result = (2 * num) / (fund * den); @@ -526,17 +532,15 @@ int M = (N >> 1), n; - float num = 0.f, den = 0.f, temp, f0; + float num = 0.f, den = 0.f, temp; - f0 = *(float *)argv; - for(n = 0; n < M; n++){ if((temp = data[n])){ - if(((int)(rintf(temp / f0)) % 2) != 0){ - num += data[M + n]; + if(XTRACT_IS_ODD(n)){ + num += temp; } else{ - den += data[M + n]; + den += temp; } } } @@ -560,8 +564,8 @@ while(n--){ - sl = pow(data[n], 0.23); - g = (n < 15 ? 1.f : 0.066 * exp(0.171 * n)); + sl = powf(data[n], 0.23); + g = (n < 15 ? 1.f : 0.066 * expf(0.171 * n)); temp += n * g * sl; } @@ -638,6 +642,17 @@ } +int xtract_nonzero_count(const float *data, const int N, const void *argv, float *result){ + + int n = N; + + while(n--) + *result += (*data++ ? 1 : 0); + + return XTRACT_SUCCESS; + +} + int xtract_hps(const float *data, const int N, const void *argv, float *result){ int n = N, M, m, l, peak_index, position1_lwr; @@ -773,22 +788,24 @@ int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result){ - float *magnitudes = NULL, argf[2], *peaks = NULL, return_code; + float *spectrum = NULL, argf[2], *peaks = NULL, return_code, sr; return_code = xtract_f0(data, N, argv, result); if(return_code == XTRACT_NO_RESULT){ - magnitudes = (float *)malloc(N * sizeof(float)); + sr = *(float *)argv; + spectrum = (float *)malloc(N * sizeof(float)); peaks = (float *)malloc(N * sizeof(float)); - xtract_spectrum(data, N, argv, magnitudes); - argf[0] = 10.f; - argf[1] = *(float *)argv; - xtract_peak_spectrum(magnitudes, N, argf, peaks); + argf[0] = sr; + argf[1] = XTRACT_MAGNITUDE_SPECTRUM; + xtract_spectrum(data, N, argf, spectrum); + argf[1] = 10.f; + xtract_peak_spectrum(spectrum, N >> 1, argf, peaks); argf[0] = 0.f; - xtract_lowest_value(peaks, N >> 1, argf, result); + xtract_lowest_value(peaks+(N >> 1), N >> 1, argf, result); - free(magnitudes); + free(spectrum); free(peaks); } Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/src/vector.c 2007-02-12 17:11:31 UTC (rev 62) @@ -270,7 +270,7 @@ limits = (int *)argv; - for(band = 0; band < XTRACT_BARK_BANDS; band++){ + for(band = 0; band < XTRACT_BARK_BANDS - 1; band++){ for(n = limits[band]; n < limits[band + 1]; n++) result[band] += data[n]; } @@ -282,7 +282,7 @@ float threshold, max, y, y2, y3, p, q, *input = NULL; size_t bytes; - int n = N, M, rv = XTRACT_SUCCESS; + int n = N, rv = XTRACT_SUCCESS; threshold = max = y = y2 = y3 = p = q = 0.f; @@ -307,32 +307,30 @@ else return XTRACT_MALLOC_FAILED; - M = N >> 1; - while(n--) max = XTRACT_MAX(max, input[n]); threshold *= .01 * max; result[0] = 0; - result[M] = 0; + result[N] = 0; - for(n = 1; n < M; n++){ + for(n = 1; n < N; n++){ if(input[n] >= threshold){ if(input[n] > input[n - 1] && input[n] > input[n + 1]){ - result[M + 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; } else{ result[n] = 0; - result[M + n] = 0; + result[N + n] = 0; } } else{ result[n] = 0; - result[M + n] = 0; + result[N + n] = 0; } } Modified: trunk/src/xtract_macros_private.h =================================================================== --- trunk/src/xtract_macros_private.h 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/src/xtract_macros_private.h 2007-02-12 17:11:31 UTC (rev 62) @@ -40,6 +40,7 @@ #define XTRACT_FUNDAMENTAL_DEFAULT 440 #define XTRACT_CHECK_nyquist if(!nyquist) nyquist = XTRACT_SR_DEFAULT / 2 #define XTRACT_CHECK_q if(!q) q = XTRACT_SR_DEFAULT / N +#define XTRACT_IS_ODD(x) (x % 2 != 0 ? 1 : 0) #define XTRACT_SR_LIMIT SR_UPPER_LIMIT #define XTRACT_FFT_BANDS_MIN 16 #define XTRACT_FFT_BANDS_MAX 65536 Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/xtract/libxtract.h 2007-02-12 17:11:31 UTC (rev 62) @@ -53,7 +53,7 @@ * @{ */ -#define XTRACT_FEATURES 53 +#define XTRACT_FEATURES 54 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ enum xtract_features_ { @@ -93,6 +93,7 @@ XTRACT_LOWEST_VALUE, XTRACT_HIGHEST_VALUE, XTRACT_SUM, + XTRACT_NONZERO_COUNT, XTRACT_HPS, XTRACT_F0, XTRACT_FAILSAFE_F0, @@ -184,7 +185,9 @@ * frequencies */ XTRACT_SPECTRAL_PEAKS, /* N spectral peak amplitudes */ - XTRACT_SPECTRAL_PEAK_MAGNITUDES, + XTRACT_SPECTRAL_PEAKS_MAGNITUDES, + /* N spectral peak frequencies */ + XTRACT_SPECTRAL_PEAKS_FREQUENCIES, /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2 * frequencies */ XTRACT_SPECTRAL_HARMONICS, @@ -313,8 +316,12 @@ /** \brief A function to initialise bark filter bounds * * A pointer to an array of BARK_BANDS ints most be passed in, and is populated with BARK_BANDS fft bin numbers representing the limits of each band + * + * \param N: the audio block size + * \param sr: The sample audio sample rate + * \param *band_limits: a pointer to an array of BARK_BANDS ints */ -int xtract_init_bark(int N, float nyquist, int *band_limits); +int xtract_init_bark(int N, float sr, int *band_limits); /* \brief A function to build an array of function descriptors */ void *xtract_make_descriptors(); Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/xtract/xtract_scalar.h 2007-02-12 17:11:31 UTC (rev 62) @@ -102,7 +102,7 @@ * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). * \param N: the number of elements to be considered * \param N: the size of the array pointed to by *data - * \param *argv: a pointer to a float representing the mean of the input spectrum + * \param *argv: a pointer to a float representing the spectral mean of the input spectrum * \param *result: the variance of the spectrum pointed to by *data */ int xtract_spectral_variance(const float *data, const int N, const void *argv, float *result); @@ -111,7 +111,7 @@ * * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). * \param N: the size of the array pointed to by *data - * \param *argv: a pointer to a float representing the variance of the input spectrum + * \param *argv: a pointer to a float representing the spectral variance of the input spectrum * \param *result: the deviation of the spectrum pointed to by *data */ int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result); @@ -120,7 +120,7 @@ * * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). * \param N: the size of the array pointed to by *data - * \param *argv: a pointer to a float representing the mean of the input spectrum + * \param *argv: a pointer to a float representing the spectral mean of the input spectrum * \param *result: the average deviation of the spectrum pointed to by *data */ int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result); @@ -129,7 +129,7 @@ * * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). * \param N: the size of the array pointed to by *data - * \param *argv: a pointer to an array of floats representing the mean and standard deviation of the input spectrum + * \param *argv: a pointer to an array of floats representing the spectral mean and spectral standard deviation of the input spectrum * \param *result: the skewness of the spectrum pointed to by *data */ int xtract_spectral_skewness(const float *data, const int N, const void *argv, float *result); @@ -138,7 +138,7 @@ * * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). * \param N: the size of the array pointed to by *data - * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input spectrum + * \param *argv: a pointer to an array of values representing the spectral mean and spectral standard deviation of the input spectrum * \param *result: the kurtosis of the spectrum pointed to by *data */ int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, float *result); @@ -304,9 +304,9 @@ /* Odd to even harmonic ratio */ /** \brief Extract the Odd to even harmonic ratio of an input vector * - * \param *data: a pointer to the first element in an array of floats representing the frequencies of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to the second 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 frequencies of the peaks. - * \param *argv: a pointer to a float representing the fundamental frequency of the input vector. + * \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 */ int xtract_odd_even_ratio(const float *data, const int N, const void *argv, float *result); @@ -394,6 +394,16 @@ */ int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result); +/** \brief Extract the number of non-zero elements in an input vector + * + * \param *data: a pointer to the first element in an array of floats + * \param N: the number of elements to be considered + * \param *argv: not used + * \param *result: the number of non-zero elements in the array pointed to by *data + * + */ +int xtract_nonzero_count(const float *data, const int N, const void *argv, float *result); + /** @} */ #ifdef __cplusplus Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2007-01-29 15:11:59 UTC (rev 61) +++ trunk/xtract/xtract_vector.h 2007-02-12 17:11:31 UTC (rev 62) @@ -38,7 +38,7 @@ * * \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. MAGNITUDE_SPECTRUM, LOG_POWER_SPECTRUM) + * \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) * \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. */ int xtract_spectrum(const float *data, const int N, const void *argv, float *result); @@ -110,10 +110,10 @@ int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result); /** \brief Extract the amplitude and frequency of spectral peaks from a magnitude spectrum - * \param *data: a pointer to an array of size N containing N/2 magnitude/power/log magnitude/log power coefficients and N/2 bin frequencies. (e.g. the first half of the array pointed to by *result from xtract_spectrum(). - * \param N: the size of the output array (note: the input array can be of size N/2, i.e. just the magnitudes) + * \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 size of the input array (note: it is assumed that enough memory has been allocated for an output array twice the size) * \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found - * \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 *result: a pointer to an array of size N * 2 containing N magnitude/power/log magnitude/log power coefficients and N bin frequencies. * */ int xtract_peak_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-02-15 10:48:43
|
Revision: 64 http://libxtract.svn.sourceforge.net/libxtract/?rev=64&view=rev Author: postlude Date: 2007-02-15 02:48:41 -0800 (Thu, 15 Feb 2007) Log Message: ----------- Removed '//' comments Modified Paths: -------------- trunk/TODO trunk/src/scalar.c Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-02-15 10:44:28 UTC (rev 63) +++ trunk/TODO 2007-02-15 10:48:41 UTC (rev 64) @@ -1,3 +1,4 @@ +Rationalise use of powf etc. vs pow Add spectral_flux Add geometric_mean Add spectral_mean, spectral_deviation, spectral_geometric_mean etc. Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-02-15 10:44:28 UTC (rev 63) +++ trunk/src/scalar.c 2007-02-15 10:48:41 UTC (rev 64) @@ -53,8 +53,7 @@ int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result){ - //*result = sqrt(*(float *)argv); - *result = sqrt(-40.); + *result = sqrt(*(float *)argv); return XTRACT_SUCCESS; } @@ -451,7 +450,6 @@ sfmdb = sfm / -60.f; *result = XTRACT_MIN(sfmdb, 1); - //*result = sfmdb; return XTRACT_SUCCESS; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-03-12 19:01:18
|
Revision: 66 http://libxtract.svn.sourceforge.net/libxtract/?rev=66&view=rev Author: postlude Date: 2007-03-12 12:01:10 -0700 (Mon, 12 Mar 2007) Log Message: ----------- Removed -Werror from CFLAGS to make the PD example compile on OS X Modified Paths: -------------- trunk/config.h.in trunk/configure.in Modified: trunk/config.h.in =================================================================== --- trunk/config.h.in 2007-03-12 18:20:43 UTC (rev 65) +++ trunk/config.h.in 2007-03-12 19:01:10 UTC (rev 66) @@ -18,8 +18,8 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the <math.h,> header file. */ -#undef HAVE_MATH_H_ +/* Define to 1 if you have the <math.h */ +#undef HAVE_MATH_H /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -30,12 +30,9 @@ /* Define to 1 if you have the <stdio.h> header file. */ #undef HAVE_STDIO_H -/* Define to 1 if you have the <stdlib.h> header file. */ +/* Define to 1 if you have the <stdlib.h */ #undef HAVE_STDLIB_H -/* Define to 1 if you have the <stdlib.h,> header file. */ -#undef HAVE_STDLIB_H_ - /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-03-12 18:20:43 UTC (rev 65) +++ trunk/configure.in 2007-03-12 19:01:10 UTC (rev 66) @@ -64,7 +64,7 @@ # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99 -I/usr/local/include" +CFLAGS="$CFLAGS -pedantic -ansi -Wall -std=c99 -I/usr/local/include" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-03-14 17:20:21
|
Revision: 70 http://libxtract.svn.sourceforge.net/libxtract/?rev=70&view=rev Author: postlude Date: 2007-03-14 10:20:14 -0700 (Wed, 14 Mar 2007) Log Message: ----------- Fixed bug in xtract_spectrum() FFTW_R2HC now interpreted correctly. Updated ChangeLog and AUTHORS files. Modified Paths: -------------- trunk/AUTHORS trunk/ChangeLog trunk/TODO trunk/config.h.in trunk/configure.in trunk/src/vector.c Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2007-03-13 10:14:32 UTC (rev 69) +++ trunk/AUTHORS 2007-03-14 17:20:14 UTC (rev 70) @@ -1 +1,6 @@ + +Main author: Jamie Bullock <ja...@po...> + +Fixes contributed by: +Dan Stowell Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-03-13 10:14:32 UTC (rev 69) +++ trunk/ChangeLog 2007-03-14 17:20:14 UTC (rev 70) @@ -1,3 +1,8 @@ +2007-03-14 Jamie Bullock <ja...@po...> + * version 0.4.4 + * Fixed return value macros for functions if fftw not used + * Fixed bug in xtract_spectrum() FFTW_R2HC not interpreted correctly + 2007-01-29 Jamie Bullock <ja...@po...> * version 0.4.0 * Added namespacing for macros and enumerations Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-03-13 10:14:32 UTC (rev 69) +++ trunk/TODO 2007-03-14 17:20:14 UTC (rev 70) @@ -4,12 +4,10 @@ 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 -Add feature advertisement Fix xtract_hps - it doesn't work! Add Pure Data help file Add delta functions Add Max/MSP external example -Add self documentation Check and add return values as appropriate. Make them more sensible! ...do other stuff and eventually... ...optimise! Modified: trunk/config.h.in =================================================================== --- trunk/config.h.in 2007-03-13 10:14:32 UTC (rev 69) +++ trunk/config.h.in 2007-03-14 17:20:14 UTC (rev 70) @@ -18,8 +18,8 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the <math.h */ -#undef HAVE_MATH_H +/* Define to 1 if you have the <math.h,> header file. */ +#undef HAVE_MATH_H_ /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -30,9 +30,12 @@ /* Define to 1 if you have the <stdio.h> header file. */ #undef HAVE_STDIO_H -/* Define to 1 if you have the <stdlib.h */ +/* Define to 1 if you have the <stdlib.h> header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the <stdlib.h,> header file. */ +#undef HAVE_STDLIB_H_ + /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-03-13 10:14:32 UTC (rev 69) +++ trunk/configure.in 2007-03-14 17:20:14 UTC (rev 70) @@ -4,7 +4,7 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 2) +m4_define(libxtract_fix_version, 4) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-03-13 10:14:32 UTC (rev 69) +++ trunk/src/vector.c 2007-03-14 17:20:14 UTC (rev 70) @@ -55,49 +55,63 @@ fftwf_execute(plan); switch(vector){ - case XTRACT_MAGNITUDE_SPECTRUM: - for(n = 0; n < M; n++){ - result[n] = sqrt(XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / N; + +/* case XTRACT_MAGNITUDE_SPECTRUM: + for(n = 1; n < M; n++){ + result[n] = sqrt(XTRACT_SQ(rfft[n]) + + XTRACT_SQ(rfft[N - n - 1])) / N; result[M + n] = n * q; } break; +*/ case XTRACT_LOG_MAGNITUDE_SPECTRUM: - for(n = 0; n < M; n++){ - if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) + for(n = 1; n < M; n++){ + if ((temp = XTRACT_SQ(rfft[n]) + + XTRACT_SQ(rfft[N - n - 1])) > XTRACT_LOG_LIMIT) temp = log(sqrt(temp) / N); else temp = XTRACT_LOG_LIMIT_DB; /*Normalise*/ - result[n] = (temp + XTRACT_DB_SCALE_OFFSET) / XTRACT_DB_SCALE_OFFSET; + result[n] = + (temp + XTRACT_DB_SCALE_OFFSET) / XTRACT_DB_SCALE_OFFSET; result[M + n] = n * q; } break; + case XTRACT_POWER_SPECTRUM: - for(n = 0; n < M; n++){ - result[n] = (XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / NxN; + for(n = 1; n < M; n++){ + result[n] = (XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n - 1])) + / NxN; result[M + n] = n * q; } break; + case XTRACT_LOG_POWER_SPECTRUM: - for(n = 0; n < M; n++){ - if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) + for(n = 1; n < M; n++){ + if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n - 1])) > + XTRACT_LOG_LIMIT) temp = log(temp / NxN); else temp = XTRACT_LOG_LIMIT_DB; - result[n] = (temp + XTRACT_DB_SCALE_OFFSET) / XTRACT_DB_SCALE_OFFSET; + result[n] = (temp + XTRACT_DB_SCALE_OFFSET) / + XTRACT_DB_SCALE_OFFSET; result[M + n] = n * q; } break; + default: /* MAGNITUDE_SPECTRUM */ - for(n = 0; n < M; n++){ - result[n] = sqrt(XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / N; + for(n = 1; n < M; n++){ + result[n] = sqrt(XTRACT_SQ(rfft[n]) + + XTRACT_SQ(rfft[N - n - 1])) / N; result[M + n] = n * q; } break; } - /* result[0] = fabs(temp[0]) / N */ + /* Set the DC component to 0 */ + result[0] = result[M] = 0.f; + /* Set the Nyquist */ result[N] = q * M; fftwf_destroy_plan(plan); @@ -182,7 +196,7 @@ #else -int xtract_magnitude_spectrum(const float *data, const int N, const void *argv, float *result){ +int xtract_spectrum(const float *data, const int N, const void *argv, float *result){ XTRACT_NEEDS_FFTW; return XTRACT_NO_RESULT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-03-19 19:07:22
|
Revision: 73 http://libxtract.svn.sourceforge.net/libxtract/?rev=73&view=rev Author: postlude Date: 2007-03-19 11:58:21 -0700 (Mon, 19 Mar 2007) Log Message: ----------- Further updated xtract_spectrum() to hopefully fix fft iteration bug and nyquist/DC inclusion. Added new boolean argument 'withDC' to select whether the DC component is required in the output Modified Paths: -------------- trunk/src/vector.c trunk/xtract/xtract_vector.h Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-03-19 15:06:55 UTC (rev 72) +++ trunk/src/vector.c 2007-03-19 18:58:21 UTC (rev 73) @@ -35,11 +35,12 @@ float *input, *rfft, q, temp; size_t bytes; - int n , NxN, M, vector; + int n , NxN, M, vector, withDC; fftwf_plan plan; M = N >> 1; NxN = XTRACT_SQ(N); + withDC = 0; rfft = (float *)fftwf_malloc(N * sizeof(float)); input = (float *)malloc(bytes = N * sizeof(float)); @@ -47,6 +48,7 @@ q = *(float *)argv; vector = (int)*((float *)argv+1); + withDC = (int)*((float *)argv+2); XTRACT_CHECK_q; @@ -56,63 +58,94 @@ switch(vector){ -/* case XTRACT_MAGNITUDE_SPECTRUM: - for(n = 1; n < M; n++){ - result[n] = sqrt(XTRACT_SQ(rfft[n]) + - XTRACT_SQ(rfft[N - n - 1])) / N; - result[M + n] = n * q; - } - break; -*/ case XTRACT_LOG_MAGNITUDE_SPECTRUM: for(n = 1; n < M; n++){ if ((temp = XTRACT_SQ(rfft[n]) + - XTRACT_SQ(rfft[N - n - 1])) > XTRACT_LOG_LIMIT) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) temp = log(sqrt(temp) / N); else temp = XTRACT_LOG_LIMIT_DB; - /*Normalise*/ - result[n] = - (temp + XTRACT_DB_SCALE_OFFSET) / XTRACT_DB_SCALE_OFFSET; - result[M + n] = n * q; + if(withDC) { + result[n] = + /*Normalise*/ + (temp + XTRACT_DB_SCALE_OFFSET) / + XTRACT_DB_SCALE_OFFSET; + result[M + n + 1] = n * q; + } + else { + result[n - 1] = + (temp + XTRACT_DB_SCALE_OFFSET) / + XTRACT_DB_SCALE_OFFSET; + result[M + n - 1] = n * q; + } } break; case XTRACT_POWER_SPECTRUM: for(n = 1; n < M; n++){ - result[n] = (XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n - 1])) - / NxN; - result[M + n] = n * q; + if(withDC){ + result[n] = (XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) + / NxN; + result[M + n + 1] = n * q; + } + else { + result[n - 1] = + (XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / NxN; + result[M + n - 1] = n * q; + } } break; case XTRACT_LOG_POWER_SPECTRUM: for(n = 1; n < M; n++){ - if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n - 1])) > + if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) temp = log(temp / NxN); else temp = XTRACT_LOG_LIMIT_DB; - result[n] = (temp + XTRACT_DB_SCALE_OFFSET) / - XTRACT_DB_SCALE_OFFSET; - result[M + n] = n * q; + if(withDC){ + result[n] = (temp + XTRACT_DB_SCALE_OFFSET) / + XTRACT_DB_SCALE_OFFSET; + result[M + n + 1] = n * q; + } + else { + result[n - 1] = (temp + XTRACT_DB_SCALE_OFFSET) / + XTRACT_DB_SCALE_OFFSET; + result[M + n - 1] = n * q; + } } break; default: /* MAGNITUDE_SPECTRUM */ for(n = 1; n < M; n++){ - result[n] = sqrt(XTRACT_SQ(rfft[n]) + - XTRACT_SQ(rfft[N - n - 1])) / N; - result[M + n] = n * q; + if(withDC){ + result[n] = sqrt(XTRACT_SQ(rfft[n]) + + XTRACT_SQ(rfft[N - n])) / N; + result[M + n + 1] = n * q; + } + else { + result[n - 1] = sqrt(XTRACT_SQ(rfft[n]) + + XTRACT_SQ(rfft[N - n])) / N; + result[M + n - 1] = n * q; + } } break; } - /* Set the DC component to 0 */ - result[0] = result[M] = 0.f; - /* Set the Nyquist */ - result[N] = q * M; + if(withDC){ + /* The DC component */ + result[0] = XTRACT_SQ(rfft[0]); + result[M + 1] = 0.f; + /* The Nyquist */ + result[M] = XTRACT_SQ(rfft[M]); + result[N + 1] = q * M; + } + else { + /* The Nyquist */ + result[M - 1] = XTRACT_SQ(rfft[M]); + result[N - 1] = q * M; + } fftwf_destroy_plan(plan); fftwf_free(rfft); Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2007-03-19 15:06:55 UTC (rev 72) +++ trunk/xtract/xtract_vector.h 2007-03-19 18:58:21 UTC (rev 73) @@ -38,7 +38,7 @@ * * \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) + * \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). An optional 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. */ 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-04-20 08:49:52
|
Revision: 78 http://libxtract.svn.sourceforge.net/libxtract/?rev=78&view=rev Author: postlude Date: 2007-04-20 01:49:49 -0700 (Fri, 20 Apr 2007) Log Message: ----------- Fixed autocorrelation_fft() it now gives comparable output to autocorrelation() Modified Paths: -------------- trunk/ChangeLog trunk/Makefile.am trunk/configure.in trunk/examples/Makefile.am trunk/examples/puredata/Makefile.am trunk/src/Makefile.am trunk/src/vector.c trunk/xtract/Makefile.am Removed Paths: ------------- trunk/config.h.in Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/ChangeLog 2007-04-20 08:49:49 UTC (rev 78) @@ -1,3 +1,8 @@ +2007-04-20 Jamie Bullock <ja...@po...> + * version 0.4.5 + * Fixed autocorrelation_fft() + * Added MAINTAINERCLEAN files to Makefile.am + 2007-03-14 Jamie Bullock <ja...@po...> * version 0.4.4 * Fixed return value macros for functions if fftw not used Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/Makefile.am 2007-04-20 08:49:49 UTC (rev 78) @@ -1,3 +1,5 @@ +MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ + SUBDIRS = src xtract examples @DOXYGEN@ pkgconfigdir = $(libdir)/pkgconfig Deleted: trunk/config.h.in =================================================================== --- trunk/config.h.in 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/config.h.in 2007-04-20 08:49:49 UTC (rev 78) @@ -1,79 +0,0 @@ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* Build the fft functions */ -#undef BUILD_FFT - -/* Build the pd example */ -#undef BUILD_PD_EXAMPLE - -/* Build the simpletest example */ -#undef BUILD_SIMPLETEST - -/* Define to enable debug */ -#undef DEBUG - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the <inttypes.h> header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the <math.h,> header file. */ -#undef HAVE_MATH_H_ - -/* Define to 1 if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the <stdint.h> header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the <stdio.h> header file. */ -#undef HAVE_STDIO_H - -/* Define to 1 if you have the <stdlib.h> header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the <stdlib.h,> header file. */ -#undef HAVE_STDLIB_H_ - -/* Define to 1 if you have the <strings.h> header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the <string.h> header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the <sys/types.h> header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the <unistd.h> header file. */ -#undef HAVE_UNISTD_H - -/* LibXtract Version */ -#undef LIBXTRACT_VERSION - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/configure.in 2007-04-20 08:49:49 UTC (rev 78) @@ -4,7 +4,7 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 4) +m4_define(libxtract_fix_version, 5) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) Modified: trunk/examples/Makefile.am =================================================================== --- trunk/examples/Makefile.am 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/examples/Makefile.am 2007-04-20 08:49:49 UTC (rev 78) @@ -1,3 +1,5 @@ +MAINTAINERCLEANFILES = Makefile.in + if BUILD_PD_EXAMPLE PUREDATA_DIR = puredata endif Modified: trunk/examples/puredata/Makefile.am =================================================================== --- trunk/examples/puredata/Makefile.am 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/examples/puredata/Makefile.am 2007-04-20 08:49:49 UTC (rev 78) @@ -1,3 +1,4 @@ +MAINTAINERCLEANFILES = Makefile.in SUFFIXES = .@PD_SUFFIX@ PDDIR = $(prefix)/lib/pd Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/src/Makefile.am 2007-04-20 08:49:49 UTC (rev 78) @@ -1,6 +1,5 @@ +MAINTAINERCLEANFILES = Makefile.in - - SOURCES = libxtract.c descriptors.c scalar.c vector.c delta.c init.c if BUILD_FFT Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/src/vector.c 2007-04-20 08:49:49 UTC (rev 78) @@ -156,25 +156,43 @@ int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result){ - float *temp, *input; - size_t bytes; - int n; + float *freq, *time; + int n, M; fftwf_plan plan; - temp = (float *)fftwf_malloc(N * sizeof(float)); - input = (float *)malloc(bytes = N * sizeof(float)); - input = memcpy(input, data, bytes); + M = N << 1; - plan = fftwf_plan_r2r_1d(N, input, temp, FFTW_HC2R, FFTW_ESTIMATE); + freq = (float *)fftwf_malloc(M * sizeof(float)); + /* Zero pad the input vector */ + time = (float *)calloc(M, sizeof(float)); + time = memcpy(time, data, N * sizeof(float)); + plan = fftwf_plan_r2r_1d(M, time, freq, FFTW_R2HC, FFTW_ESTIMATE); + fftwf_execute(plan); + + for(n = 1; n < M / 2; n++){ + freq[n] = XTRACT_SQ(freq[n]) + XTRACT_SQ(freq[M - n]); + freq[M - n] = 0.f; + } - for(n = 0; n < N - 1; n++) - result[n] = temp[n+1]; - + freq[0] = XTRACT_SQ(freq[0]); + freq[N] = XTRACT_SQ(freq[N]); + + plan = fftwf_plan_r2r_1d(M, freq, time, FFTW_HC2R, FFTW_ESTIMATE); + + fftwf_execute(plan); + + /* Normalisation factor */ + M = M * N; + + for(n = 0; n < N; n++) + result[n] = time[n] / (float)M; + /* result[n] = time[n+1] / (float)M; */ + fftwf_destroy_plan(plan); - fftwf_free(temp); - free(input); + fftwf_free(freq); + free(time); return XTRACT_SUCCESS; } Modified: trunk/xtract/Makefile.am =================================================================== --- trunk/xtract/Makefile.am 2007-04-04 10:25:47 UTC (rev 77) +++ trunk/xtract/Makefile.am 2007-04-20 08:49:49 UTC (rev 78) @@ -1,3 +1,5 @@ +MAINTAINERCLEANFILES = Makefile.in + libxtractdir = $(includedir)/xtract libxtract_HEADERS = libxtract.h xtract_macros.h xtract_types.h xtract_delta.h \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-08-19 16:54:34
|
Revision: 81 http://libxtract.svn.sourceforge.net/libxtract/?rev=81&view=rev Author: postlude Date: 2007-08-19 09:54:25 -0700 (Sun, 19 Aug 2007) Log Message: ----------- Fixes for MSP example, and changed the fundamental estimators so that if they don't get a samplerate 44100 is assumed (I'm not sure if this is a good idea!). Modified Paths: -------------- trunk/examples/MSP/Makefile trunk/examples/MSP/xtract~.c trunk/src/scalar.c trunk/xtract/xtract_scalar.h Modified: trunk/examples/MSP/Makefile =================================================================== --- trunk/examples/MSP/Makefile 2007-07-31 20:44:17 UTC (rev 80) +++ trunk/examples/MSP/Makefile 2007-08-19 16:54:25 UTC (rev 81) @@ -7,7 +7,7 @@ MAXINCLUDE = /usr/local/include/max-includes MSPINCLUDE = /usr/local/include/msp-includes FRAMEWORKS = /Library/Frameworks -INSTALLDIR = /Applications/MaxMSP\ 4.6/Cycling\ \'74/externals/ +INSTALLDIR = /Applications/Audio/MaxMSP\ 4.6.3/Cycling\ \'74/externals/ LIPO = /usr/bin/lipo CC = gcc @@ -15,7 +15,7 @@ CFLAGS = -F$(FRAMEWORKS) -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -x c -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -I$(MAXINCLUDE) -I$(MSPINCLUDE) -include macho-prefix.h -Werror I386CFLAGS = -arch i386 -PPCCFLAGS = -arch ppc -faltivec -fasm-blocks +PPCCFLAGS = -arch ppc -faltivec -fasm-blocks -Wno-unused LDFLAGS = -F$(FRAMEWORKS) -L$(MAXINCLUDE) -L$(MSPINCLUDE) -framework Carbon -framework MaxAPI -framework MaxAudioAPI -Wl,-Y,1455 -bundle -L/usr/local/lib -lxtract @@ -24,10 +24,10 @@ universal: $(CC) $(CFLAGS) $(I386CFLAGS) -o $(NAME)-i386.o -c $(NAME).c -# $(CC) $(CFLAGS) $(PPCCFLAGS) -o $(NAME)-ppc.o -c $(NAME).c + $(CC) $(CFLAGS) $(PPCCFLAGS) -o $(NAME)-ppc.o -c $(NAME).c $(CC) $(LDFLAGS) $(I386LDFLAGS) -o $(NAME)-i386 $(NAME)-i386.o -# $(CC) $(LDFLAGS) $(PPCLDFLAGS) -o $(NAME)-ppc $(NAME)-ppc.o -# $(LIPO) -create $(NAME)-ppc $(NAME)-i386 -output $(NAME) + $(CC) $(LDFLAGS) $(PPCLDFLAGS) -o $(NAME)-ppc $(NAME)-ppc.o + $(LIPO) -create $(NAME)-ppc $(NAME)-i386 -output $(NAME) $(LIPO) -create $(NAME)-i386 -output $(NAME) mkdir -p $(NAME).mxo/Contents/MacOS cp Info.plist PkgInfo $(NAME).mxo/Contents/ Modified: trunk/examples/MSP/xtract~.c =================================================================== --- trunk/examples/MSP/xtract~.c 2007-07-31 20:44:17 UTC (rev 80) +++ trunk/examples/MSP/xtract~.c 2007-08-19 16:54:25 UTC (rev 81) @@ -46,11 +46,11 @@ } t_xtract_tilde; static t_int *xtract_perform(t_int *w) { - t_sample *in = (t_sample *)(w[1]); + t_float *in = (t_float *)(w[1]); t_xtract_tilde *x = (t_xtract_tilde *)(w[2]); t_int N = (t_int)(w[3]); t_int return_code = 0; - float result = 0; + float result = 0.f; return_code = xtract[x->feature]((float *)in, N, x->argv, &result); @@ -65,8 +65,8 @@ } static t_int *xtract_perform_vector(t_int *w) { - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); + t_sample *in = (t_float *)(w[1]); + t_sample *out = (t_float *)(w[2]); float *temp_in, *temp_out; t_xtract_tilde *x = (t_xtract_tilde *)(w[3]); t_int N = (t_int)(w[4]), n; @@ -114,24 +114,32 @@ t_symbol *tmp; t_xtract_tilde *x = (t_xtract_tilde *)newobject(xtract_tilde_class); xtract_mel_filter *mf; - t_int n, N, f, F, n_args, type; + t_int n, N, f, F, n_args, type, blocksize; t_float *argv_max; xtract_function_descriptor_t *fd; char *p_name, *p_desc, *author; int year; + + blocksize = BLOCKSIZE; /* Default */ + tmp = NULL; p_name = p_desc = author = NULL; n_args = type = x->feature = 0; f = F = XTRACT_FEATURES; - N = BLOCKSIZE; + /* N = BLOCKSIZE;*/ x->argv = NULL; - tmp = argv->a_w.w_sym; /*atom_getsymbol(argv); */ + if(argc) + tmp = argv[0].a_w.w_sym; /*atom_getsymbol(argv); */ + if(argc > 1) + blocksize = (t_int)argv[1].a_w.w_long; + N = blocksize; + /* get function descriptors */ fd = (xtract_function_descriptor_t *)xtract_make_descriptors(); @@ -186,7 +194,6 @@ else post("xtract~: No arguments given"); - /* do init if needed */ if(x->feature == XTRACT_MFCC){ @@ -224,7 +231,7 @@ else x->feature_type = XTRACT_SCALAR; /* argv through right inlet */ - inlet_new((t_pxobject *)x, "argv"); + inlet_new((t_pxobject *)x, "list"); /* DSP inlet */ dsp_setup((t_pxobject *)x, 1); @@ -294,7 +301,7 @@ A_GIMME, 0); addmess((method)xtract_tilde_dsp, "dsp", A_CANT, 0); - addmess((method)xtract_tilde_get_args, "argv", A_GIMME, 0); + addmess((method)xtract_tilde_get_args, "list", A_GIMME, 0); addmess((method)xtract_tilde_show_help, "help", A_DEFSYM, 0); dsp_initclass(); //class_setname("xtract~", "xtract~"); Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-07-31 20:44:17 UTC (rev 80) +++ trunk/src/scalar.c 2007-08-19 16:54:25 UTC (rev 81) @@ -26,6 +26,7 @@ #include "math.h" #include <stdlib.h> #include <string.h> +#include <stdio.h> int xtract_mean(const float *data, const int N, const void *argv, float *result){ @@ -658,6 +659,8 @@ largest1_lwr, peak, ratio1, sr; sr = *(float*)argv; + if(sr == 0) + sr = 44100.f; coeffs2 = (float *)malloc(N * sizeof(float)); coeffs3 = (float *)malloc(N * sizeof(float)); @@ -715,13 +718,16 @@ int xtract_f0(const float *data, const int N, const void *argv, float *result){ - int M, sr, tau, n; + int M, tau, n; + float sr; size_t bytes; float f0, err_tau_1, err_tau_x, array_max, threshold_peak, threshold_centre, *input; sr = *(float *)argv; + if(sr == 0) + sr = 44100.f; input = (float *)malloc(bytes = N * sizeof(float)); input = memcpy(input, data, bytes); @@ -793,6 +799,8 @@ if(return_code == XTRACT_NO_RESULT){ sr = *(float *)argv; + if(sr == 0) + sr = 44100.f; spectrum = (float *)malloc(N * sizeof(float)); peaks = (float *)malloc(N * sizeof(float)); argf[0] = sr; Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2007-07-31 20:44:17 UTC (rev 80) +++ trunk/xtract/xtract_scalar.h 2007-08-19 16:54:25 UTC (rev 81) @@ -90,7 +90,7 @@ /** \brief Extract the mean of an input spectrum * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the size of the array pointed to by *data * \param *argv: a pointer to NULL * \param *result: the mean of the spectrum pointed to by *data @@ -99,7 +99,7 @@ /** \brief Extract the variance of an input spectrum * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the number of elements to be considered * \param N: the size of the array pointed to by *data * \param *argv: a pointer to a float representing the spectral mean of the input spectrum @@ -109,7 +109,7 @@ /** \brief Extract the deviation of an input spectrum * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the size of the array pointed to by *data * \param *argv: a pointer to a float representing the spectral variance of the input spectrum * \param *result: the deviation of the spectrum pointed to by *data @@ -118,7 +118,7 @@ /** \brief Extract the average deviation of an input spectrum * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the size of the array pointed to by *data * \param *argv: a pointer to a float representing the spectral mean of the input spectrum * \param *result: the average deviation of the spectrum pointed to by *data @@ -127,7 +127,7 @@ /** \brief Extract the skewness of an input spectrum * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the size of the array pointed to by *data * \param *argv: a pointer to an array of floats representing the spectral mean and spectral standard deviation of the input spectrum * \param *result: the skewness of the spectrum pointed to by *data @@ -136,7 +136,7 @@ /** \brief Extract the kurtosis of an input spectrum * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the size of the array pointed to by *data * \param *argv: a pointer to an array of values representing the spectral mean and spectral standard deviation of the input spectrum * \param *result: the kurtosis of the spectrum pointed to by *data @@ -145,12 +145,12 @@ /** \brief Extract the centroid of an input vector * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the centroid of the values pointed to by *data * - * Note: for a more 'accurate' result *result from xtract_spectral_peaks() can be passed in. This gives the interpolated peak frequency locations. + * Note: for a more 'accurate' result *result from xtract_peak_spectrum() can be passed in. This gives the interpolated peak frequency locations. * */ int xtract_spectral_centroid(const float *data, const int N, const void *argv, float *result); @@ -175,7 +175,7 @@ /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982) * - * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients of the harmonic spectrum of an audio vector e.g. a pointer to the first half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_spectral_peaks()) can be used if one wishes to consider all partials not just harmonics. + * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients of the harmonic spectrum of an audio vector e.g. a pointer to the first half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_peak_spectrum()) can be used if one wishes to consider all partials not just harmonics. * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the tristimulus of N values from the array pointed to by *data @@ -276,7 +276,7 @@ /** \brief Extract the Inharmonicity of an input vector * - * \param *data: a pointer to the first element in an array of floats represeting a magnitude peak spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_spectral_peaks()) + * \param *data: a pointer to the first element in an array of floats represeting a magnitude peak spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_peak_spectrum()) * \param N: the number of elements to be considered * \param *argv: a pointer to a float representing the fundamental frequency of the input vector. * \param *result: the inharmonicity of N values from the array pointed to by *data @@ -322,7 +322,7 @@ /** \brief Extract the Slope of an input vector using a method described by Peeters(2003) * - * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_magnitude_spectrum(), xtract_spectral_peaks() or xtract_spectral_harmonics()). + * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()). * \param N: the number of elements to be considered * \param *argv: a pointer to NULL * \param *result: the Slope of N values from the array pointed to by *data This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-08-19 21:46:42
|
Revision: 84 http://libxtract.svn.sourceforge.net/libxtract/?rev=84&view=rev Author: postlude Date: 2007-08-19 14:46:41 -0700 (Sun, 19 Aug 2007) Log Message: ----------- Added MSP example test patches and modified MSP Makefile to cater for specific architectures Modified Paths: -------------- trunk/configure.in trunk/examples/MSP/Makefile Added Paths: ----------- trunk/examples/MSP/test/ trunk/examples/MSP/test/magspec trunk/examples/MSP/test/xtract-test Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-08-19 21:29:14 UTC (rev 83) +++ trunk/configure.in 2007-08-19 21:46:41 UTC (rev 84) @@ -4,7 +4,7 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 6) +m4_define(libxtract_fix_version, 7) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) Modified: trunk/examples/MSP/Makefile =================================================================== --- trunk/examples/MSP/Makefile 2007-08-19 21:29:14 UTC (rev 83) +++ trunk/examples/MSP/Makefile 2007-08-19 21:46:41 UTC (rev 84) @@ -28,6 +28,21 @@ $(CC) $(LDFLAGS) $(I386LDFLAGS) -o $(NAME)-i386 $(NAME)-i386.o $(CC) $(LDFLAGS) $(PPCLDFLAGS) -o $(NAME)-ppc $(NAME)-ppc.o $(LIPO) -create $(NAME)-ppc $(NAME)-i386 -output $(NAME) + mkdir -p $(NAME).mxo/Contents/MacOS + cp Info.plist PkgInfo $(NAME).mxo/Contents/ + cp $(NAME) $(NAME).mxo/Contents/MacOS + +ppc: + $(CC) $(CFLAGS) $(PPCCFLAGS) -o $(NAME)-ppc.o -c $(NAME).c + $(CC) $(LDFLAGS) $(PPCLDFLAGS) -o $(NAME)-ppc $(NAME)-ppc.o + $(LIPO) -create $(NAME)-ppc -output $(NAME) + mkdir -p $(NAME).mxo/Contents/MacOS + cp Info.plist PkgInfo $(NAME).mxo/Contents/ + cp $(NAME) $(NAME).mxo/Contents/MacOS + +intel: + $(CC) $(CFLAGS) $(I386CFLAGS) -o $(NAME)-i386.o -c $(NAME).c + $(CC) $(LDFLAGS) $(I386LDFLAGS) -o $(NAME)-i386 $(NAME)-i386.o $(LIPO) -create $(NAME)-i386 -output $(NAME) mkdir -p $(NAME).mxo/Contents/MacOS cp Info.plist PkgInfo $(NAME).mxo/Contents/ Added: trunk/examples/MSP/test/magspec =================================================================== --- trunk/examples/MSP/test/magspec (rev 0) +++ trunk/examples/MSP/test/magspec 2007-08-19 21:46:41 UTC (rev 84) @@ -0,0 +1,19 @@ +max v2; +#N vpatcher 762 88 1362 488; +#P window setfont "Sans Serif" 9.; +#N out 1; +#P newobj 219 220 33 196617 out 1; +#N in 2; +#P newobj 316 36 25 196617 in 2; +#N in 1; +#P newobj 218 44 25 196617 in 1; +#P newex 218 112 108 196617 wave~ mags 0. 11.61; +#P newex 218 77 101 196617 phasor~ 86.133003; +#P newex 53 119 100 196617 buffer~ mags 11.62; +#P newex 218 146 134 196617 xtract~ irregularity_k 512; +#P connect 4 0 2 0; +#P connect 2 0 3 0; +#P connect 3 0 0 0; +#P connect 0 0 6 0; +#P connect 5 0 3 2; +#P pop; Added: trunk/examples/MSP/test/xtract-test =================================================================== --- trunk/examples/MSP/test/xtract-test (rev 0) +++ trunk/examples/MSP/test/xtract-test 2007-08-19 21:46:41 UTC (rev 84) @@ -0,0 +1,193 @@ +max v2; +#N vpatcher 22 65 823 798; +#P origin -203 -11; +#P window setfont "Sans Serif" 9.; +#P newex 154 177 46 196617 / 1000.; +#P newex 19 349 39 196617 noise~; +#P flonum 79 206 88 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; +#P newex 79 180 71 196617 expr log($f1); +#P message 377 385 68 196617 /braun/5 \$1; +#P message 305 385 68 196617 /braun/4 \$1; +#P message 229 385 68 196617 /braun/3 \$1; +#P message 155 386 68 196617 /braun/2 \$1; +#P flonum 657 181 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; +#P flonum 511 176 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; +#P flonum 426 179 66 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; +#P flonum 334 180 63 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; +#P flonum 594 180 55 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; +#P newex 0 378 69 196617 send~ source; +#P newex 425 150 72 196617 r irregularity; +#P newex 508 151 72 196617 r fundamental; +#P newex 656 151 57 196617 r variance; +#P newex 223 151 104 196617 r standard_deviation; +#P newex 593 150 55 196617 r centroid; +#P newex 79 148 55 196617 r kurtosis; +#P newex 332 151 80 196617 r inharmonicity; +#P newex 154 151 61 196617 r skewness; +#N vpatcher 9 59 787 818; +#P window setfont "Sans Serif" 9.; +#P newex 622 460 37 196617 pack f; +#P window linecount 1; +#P newex 213 260 83 196617 receive~ source; +#P newex 213 290 35 196617 *~ 1.; +#P newex 516 261 72 196617 s irregularity; +#P newex 226 390 72 196617 s fundamental; +#P newex 557 514 57 196617 s variance; +#P newex 364 560 104 196617 s standard_deviation; +#P newex 312 444 55 196617 s centroid; +#P newex 183 688 55 196617 s kurtosis; +#P newex 70 468 80 196617 s inharmonicity; +#P newex 7 689 61 196617 s skewness; +#P newex 71 423 95 196617 receive~ spectrum; +#P message 213 426 40 196617 list \$1; +#P newex 70 445 153 196617 xtract~ spectral_inharmonicity; +#P newex 529 403 62 196617 poke~ mags; +#P newex 436 265 27 196617 / 2.; +#P newex 470 207 29 196617 * 2.; +#P newex 555 378 85 196617 count~ 0 1024 1; +#P newex 470 232 111 196617 poly~ magspec vs 512; +#P newex 7 667 134 196617 xtract~ spectral_skewness; +#P newex 7 644 95 196617 receive~ spectrum; +#P newex 408 337 44 196617 pack f f; +#P newex 183 667 128 196617 xtract~ spectral_kurtosis; +#P newex 183 644 95 196617 receive~ spectrum; +#P newex 301 559 44 196617 pack f f; +#P newex 333 513 95 196617 receive~ spectrum; +#P message 502 514 40 196617 list \$1; +#P newex 335 533 177 196617 xtract~ spectral_standard_deviation; +#P newex 502 467 95 196617 receive~ spectrum; +#P newex 442 403 81 196617 send~ spectrum; +#P newex 502 488 130 196617 xtract~ spectral_variance; +#P newex 213 360 58 196617 xtract~ f0; +#P newex 394 234 47 196617 * 1000.; +#P newex 394 212 31 196617 !/ 0.; +#P newex 324 80 27 196617 i 10; +#P newex 304 57 30 196617 t b b; +#P newex 304 35 48 196617 loadbang; +#P newex 318 169 27 196617 / 0.; +#P newex 301 326 27 196617 *~; +#P newex 318 274 46 196617 phasor~; +#P newex 318 298 87 196617 wave~ hann 0. 0.; +#P newex 304 130 54 196617 dspstate~; +#P newex 324 103 73 196617 adstatus sigvs; +#B color 5; +#P newex 301 405 128 196617 xtract~ spectral_centroid; +#P newex 301 360 117 196617 xtract~ spectrum 1024; +#P comment 406 300 109 196617 //windowing function; +#P window linecount 0; +#P comment 46 52 100 196617 //basic feature cascade; +#P comment 596 233 100 196617 //poly~ used to reduce down to half-block size to get just magnitudes; +#P comment 598 406 140 196617 //mags is inside the poly~; +#P connect 28 0 29 0; +#P connect 29 0 38 0; +#P connect 37 0 35 0; +#P connect 35 0 39 0; +#P connect 24 0 29 1; +#P connect 25 0 26 0; +#P connect 26 0 40 0; +#P connect 47 0 46 0; +#P connect 46 0 17 0; +#P connect 17 0 36 0; +#P connect 36 0 35 1; +#P connect 17 0 44 0; +#P connect 46 0 10 0; +#P connect 10 0 4 0; +#P connect 4 0 5 0; +#P connect 5 0 24 0; +#P connect 24 0 26 1; +#P connect 12 0 13 0; +#P connect 13 0 7 0; +#P connect 5 0 41 0; +#P connect 7 1 11 0; +#P connect 11 0 9 0; +#P connect 9 0 8 0; +#P connect 8 0 10 1; +#P connect 13 1 14 0; +#P connect 14 0 6 0; +#P connect 7 3 11 1; +#P connect 23 0 21 0; +#P connect 21 0 24 1; +#P connect 21 0 42 0; +#P connect 7 1 15 0; +#P connect 15 0 16 0; +#P connect 16 0 8 2; +#P connect 11 0 27 0; +#P connect 27 0 4 1; +#P connect 7 3 15 1; +#P connect 16 0 33 0; +#P connect 4 0 19 0; +#P connect 11 0 32 0; +#P connect 32 0 30 0; +#P connect 20 0 18 0; +#P connect 18 0 22 0; +#P connect 22 0 21 1; +#P connect 30 0 45 0; +#P connect 4 0 34 0; +#P connect 31 0 34 1; +#P connect 18 0 43 0; +#P connect 33 0 30 1; +#P connect 5 0 48 0; +#P connect 48 0 18 1; +#P pop; +#P newobj 594 83 37 196617 p guts; +#P newex 0 269 38 196617 * 100; +#P slider 0 116 15 128 0 1; +#P number 0 294 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; +#P message 79 386 68 196617 /braun/1 \$1; +#P newex 79 476 120 196617 udpsend 127.0.0.1 4444; +#N vpatcher 10 59 364 406; +#P window setfont "Sans Serif" 9.; +#P newex 47 33 48 196617 loadbang; +#P window linecount 1; +#P newex 87 102 27 196617 t i i; +#P newex 87 258 43 196617 pack i f; +#P newex 87 80 27 196617 - 1; +#P newex 47 59 51 196617 Uzi 1024; +#P newex 87 283 59 196617 peek~ hann; +#P newex 120 227 38 196617 + 0.5; +#P newex 120 206 42 196617 * -0.5; +#P newex 104 126 46 196617 / 1023.; +#P newex 120 161 47 196617 * 6.283; +#P newex 120 183 23 196617 cos; +#P window linecount 0; +#P comment 182 38 100 196617 //makes a hanning window in a buffer called hann; +#P connect 11 0 7 0; +#P connect 7 2 8 0; +#P connect 8 0 10 0; +#P connect 10 0 9 0; +#P connect 9 0 6 0; +#P connect 10 1 3 0; +#P connect 3 0 2 0; +#P connect 2 0 1 0; +#P connect 1 0 4 0; +#P connect 4 0 5 0; +#P connect 5 0 9 1; +#P pop; +#P newobj 550 35 80 196617 p make_hanning; +#P newex 533 57 97 196617 buffer~ hann 23.22; +#P user ezdac~ 648 37 692 70 0; +#P newex 0 321 55 196617 saw~ 440; +#P connect 7 0 8 0; +#P connect 8 0 6 0; +#P connect 6 0 0 0; +#P connect 0 0 18 0; +#P connect 30 0 18 0; +#P connect 12 0 28 0; +#P connect 28 0 29 0; +#P connect 28 0 5 0; +#P connect 27 0 4 0; +#P connect 26 0 4 0; +#P connect 25 0 4 0; +#P connect 24 0 4 0; +#P connect 5 0 4 0; +#P connect 10 0 31 0; +#P connect 11 0 24 0; +#P connect 17 0 25 0; +#P connect 16 0 26 0; +#P connect 11 0 20 0; +#P connect 13 0 27 0; +#P connect 17 0 21 0; +#P connect 16 0 22 0; +#P connect 13 0 19 0; +#P connect 15 0 23 0; +#P pop; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-08-20 08:12:10
|
Revision: 86 http://libxtract.svn.sourceforge.net/libxtract/?rev=86&view=rev Author: postlude Date: 2007-08-20 01:12:04 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Minor mods and typos corrections that were lurking uncommitted Modified Paths: -------------- trunk/TODO trunk/src/scalar.c trunk/xtract/libxtract.h trunk/xtract/xtract_scalar.h trunk/xtract/xtract_vector.h Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-08-19 21:54:10 UTC (rev 85) +++ trunk/TODO 2007-08-20 08:12:04 UTC (rev 86) @@ -1,3 +1,4 @@ +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 Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-08-19 21:54:10 UTC (rev 85) +++ trunk/src/scalar.c 2007-08-20 08:12:04 UTC (rev 86) @@ -350,8 +350,11 @@ int n = N; - float num = 0.f, den = 0.f, temp; + float num = 0.f, den = 0.f, temp = 0.f; + if(argv == NULL) + return XTRACT_BAD_ARGV; + while(n--){ temp = n - *(float *)argv; num += XTRACT_SQ(temp) * data[n]; Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-08-19 21:54:10 UTC (rev 85) +++ trunk/xtract/libxtract.h 2007-08-20 08:12:04 UTC (rev 86) @@ -27,6 +27,9 @@ * * 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). * + * + * LibXtract can be downloaded from http://www.sf.net/projects/libxtract + * */ #ifndef XTRACT_H Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2007-08-19 21:54:10 UTC (rev 85) +++ trunk/xtract/xtract_scalar.h 2007-08-20 08:12:04 UTC (rev 86) @@ -28,7 +28,7 @@ #endif /** - * \defgroup scalar extraction functions + * \defgroup scalar scalar extraction functions * * Defines scalar extraction functions, and their parameters. * @{ @@ -200,7 +200,7 @@ * * \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 *argv: a pointer to NULL + * \param *argv: a pointer to a float corresponding to the spectral centroid * \param *result: the spectral spread of N values from the array pointed to by *data */ int xtract_spread(const float *data, const int N, const void *argv, float *result); Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2007-08-19 21:54:10 UTC (rev 85) +++ trunk/xtract/xtract_vector.h 2007-08-20 08:12:04 UTC (rev 86) @@ -28,9 +28,9 @@ #endif /** - * \defgroup vector extraction functions + * \defgroup vector vector extraction functions * - * Defines vectorr extraction functions, and their parameters. + * Defines vector extraction functions, and their parameters. * @{ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-03 14:32:06
|
Revision: 88 http://libxtract.svn.sourceforge.net/libxtract/?rev=88&view=rev Author: postlude Date: 2007-09-03 07:31:58 -0700 (Mon, 03 Sep 2007) Log Message: ----------- Checked ANSI C89 compliance (basically a few ifndefs for the C99 math functions: powf, roundf etc). Added a few PD examples/tests. Modified Paths: -------------- trunk/configure.in trunk/examples/puredata/xtract~.c trunk/src/scalar.c trunk/src/vector.c Added Paths: ----------- trunk/examples/puredata/harmonic_spectrum.pd trunk/examples/puredata/regression-test.pd trunk/examples/puredata/simple-example.pd Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-02 14:28:00 UTC (rev 87) +++ trunk/configure.in 2007-09-03 14:31:58 UTC (rev 88) @@ -64,7 +64,7 @@ # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -std=c99 -I/usr/local/include" +CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c89 -I/usr/local/include" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, Added: trunk/examples/puredata/harmonic_spectrum.pd =================================================================== --- trunk/examples/puredata/harmonic_spectrum.pd (rev 0) +++ trunk/examples/puredata/harmonic_spectrum.pd 2007-09-03 14:31:58 UTC (rev 88) @@ -0,0 +1,108 @@ +#N canvas 621 238 587 354 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.0212162 0.0317487 0.0195466 0.00561563 0.0177077 0.0476304 0.0567499 +0.0474959 0.0970338 0.464764 0.096619 0.0562304 0.0238859 0.0221252 +0.0281975 0.0124481 0.0234213 0.0308018 0.0182565 0.0118857 0.0086735 +0.0188852 0.0119291 0.0237176 0.00864544 0.00273517 0.0113407 0.0100331 +0.0382518 0.0213396 0.0296342 0.034342 0.0171451 0.00243189 0.0301973 +0.00739387 0.0278942 0.0198999 0.0173251 0.0225384 0.0042204 0.0186626 +0.0191895 0.0116634 0.00931694 0.00501582 0.012182 0.0301927 0.0167377 +0.0194199 0.0254657 0.0208484 0.0438904 0.030928 0.0123733 0.0220734 +0.0199979 0.028819 0.00481497 0.0136932 0.00975227 0.0256796 0.0157346 +0.040834 0.0247319 0.0333543 0.00981976 0.00128905 0.0108467 0.00859555 +0.00120924 0.0198812 0.00942567 0.0179 0.021585 0.0144289 0.0138407 +0.0259725 0.0088767 0.0189066 0.0241189 0.0123437 0.0110563 0.0110612 +0.0135812 0.0295776 0.00935764 0.00530153 0.0136921 0.00645618 0.00677527 +0.018981 0.00559285 0.0423402 0.012537 0.0196257 0.0107362 0.0244728 +0.0169689 0.00800423 0.0106661 0.00580486 0.00123392 0.0318564 0.00313052 +0.00918496 0.0148799 0.0215053 0.0103284 0.0101435 0.0159162 0.0265488 +0.0149968 0.0144774 0.0127121 0.0210075 0.0136251 0.0246422 0.0150687 +0.0125131 0.0238336 0.0144661 0.00459801 0.0176529 0.0196158 0.00860441 +0.02399 0.0125216 0.0132359 0.0217819 0.0122651 0.0233058 0.00750471 +0.0162637 0.00563749 0.0107775 0.021111 0.0161979 0.00453912 0.0148774 +0.000913515 0.0250208 0.0255661 0.0349255 0.0140773 0.0264259 0.00978363 +0.0128433 0.017953 0.0123747 0.000980419 0.0202137 0.0111122 0.0122572 +0.0150218 0.0198538 0.00786684 0.0152549 0.00976639 0.00464054 0.0141998 +0.00772205 0.016834 0.0153422 0.00997133 0.00674112 0.0190689 0.0255067 +0.0107735 0.0116028 0.0145695 0.0243072 0.0254179 0.00474025 0.00489552 +0.0260339 0.025168 0.0067304 0.0217401 0.00904745 0.0146951 0.0182503 +0.0392981 0.00691688 0.00454291 0.0212321 0.00856008 0.00406878 0.0208133 +0.0184339 0.0295088 0.0299841 0.0114197 0.00718674 0.00452769 0.0230214 +0.00951422 0.0362591 0.011827 0.0228309 0.0272509 0.0168917 0.0301141 +0.0192356 0.0161379 0.0236251 0.0141769 0.0320988 0.0151104 0.0143148 +0.0313421 0.0272517 0.0313192 0.0226451 0.0218267 0.0183534 0.00742306 +0.0236084 0.0220338 0.00740086 0.0283414 0.0325231 0.0465779 0.027643 +0.0240922 0.0164632 0.0113228 0.0164433 0.0194295 0.0161885 0.0152107 +0.0173802 0.024051 0.0108911 0.0118482 0.0144843 0.0158265 0.0159634 +0.0105952 0.0106542 0.0124575 0.0159426 0.0126567 0.00726532 0.0130271 +0.011397 0.00576796 0.0219027 0.0120067 0.0112131 0.0217665 0.028283 +0.00556188 0.0172272 0.0156255 0.00790093 0.00810658 0.0129488 0.0178136 +0.0131554 0.0221222 0.00680469 0.0248362 0.019694 0.00703206 0.0339999 +0.0136595 0.00676699 0.0151537 0.0263812 0.0226784 0.00493732 0.0295971 +0.0212905 0.0360165 0.0220007 0.0306554 0.0132068 0.0143121 0.0110527 +0.00200652 0.0119865 0.029585 0.0195924 0.00423938 0.0292942 0.0235783 +0.0149287 0.0091102 0.0132163 0.00536295 0.0112099 0.0160713 0.0266621 +0.0049689 0.0151439 0.0168654 0.0132658 0.0118611 0.0180696 0.0176023 +0.00712655 0.0239444 0.00829241 0.016034 0.00839455 0.0132304 0.0193391 +0.00969501 0.0108692 0.01659 0.026616 0.029016 0.00760763 0.00869712 +0.013781 0.0124679 0.0153336 0.0169436 0.0151282 0.00582287 0.0252088 +0.010132 0.0144077 0.0172376 0.0138607 0.0192887 0.0162585 0.0250082 +0.0124786 0.0213438 0.0185502 0.00461736 0.0107252 0.0246183 0.0199021 +0.0213024 0.0325369 0.0128834 0.0297772 0.0139391 0.0290136 0.00977331 +0.0293352 0.0223587 0.00683776 0.00774782 0.00868099 0.0177819 0.0501341 +0.0168349 0.0122174 0.0045685 0.00933541 0.0153631 0.0120776 0.0136674 +0.0110695 0.00526424 0.0223792 0.0189218 0.0324813 0.0175627 0.0103907 +0.00722242 0.0192809 0.0222755 0.0144299 0.0189361 0.00997853 0.0065123 +0.0109085 0.00674032 0.0146737 0.0185307 0.0158343 0.0202681 0.00576984 +0.0147357 0.0204028 0.00339465 0.020232 0.00719163 0.0106671 0.0111035 +0.0214937 0.0121637 0.0168017 0.00981358 0.0179859 0.0189836 0.00543421 +0.0183689 0.0268019 0.0143586 0.0221351 0.00688864 0.0237894 0.0253554 +0.02866 0.00769269 0.015072 0.00734027 0.020403 0.0248997 0.0108569 +0.0154023 0.00941389 0.0291191 0.00872522 0.0223672 0.00639403 0.021712 +0.0246656 0.00448177 0.0050129 0.0137407 0.0122352 0.0130276 0.0181434 +0.0239518 0.0052326 0.0193361 0.0226996 0.0202401 0.0208808 0.030179 +0.00866272 0.0413012 0.0268073 0.0105023 0.0168644 0.00408668 0.00292807 +0.0134017 0.0205693 0.0173767 0.0117562 0.00719525 0.00927211 0.027002 +0.0271098 0.0216011 0.00717236 0.0138263 0.00271252 0.0143244 0.00397278 +0.0219117 0.0104727 0.0199572 0.0140881 0.00060853 0.0142593 0.0227859 +0.0109915 0.0209464 0.0273022 0.0140469 0.0104995 0.00597412 0.00458115 +0.0301041 0.00698568 0.0164327 0.0147746 0.0181867 0.0160428 0.00350695 +0.0073609 0.016644 0.0147995 0.014512 0.0058076 0.0198532 0.0114418 +0.0141326 0.0116806 0.0179014 0.0186733 0.0171869 0.0219169 0.0151714 +0.00699651 0.023865 0.0292064 0.00678898 0.0329386 0.0143645 0.0170765 +0.0206896 0.0111348 0.0100621 0.0115056 0.015144 0.00661284 0.00584966 +0.0215877 0.0121954 0.0291166 0.0302916 0.0354529 0.0102541 0.00448918 +0.0112287 0.0154816 0.00960475 0.035809 0.0276429 0.0209137 0.0209784 +300.821; +#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 278 253 xtract~ peak_spectrum; +#X obj 255 277 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 279 224 tabreceive~ mag_spectrum; +#X msg 453 223 list \$1; +#X obj 453 178 samplerate~; +#X obj 58 71 noise~; +#X obj 113 70 osc~ 440; +#X obj 453 198 / 1024; +#X obj 278 277 xtract~ harmonic_spectrum; +#X obj 278 307 print~; +#X obj 453 151 loadbang; +#X connect 0 0 2 0; +#X connect 4 0 12 0; +#X connect 5 0 13 0; +#X connect 6 0 4 0; +#X connect 7 0 4 1; +#X connect 8 0 11 0; +#X connect 9 0 0 0; +#X connect 10 0 0 0; +#X connect 11 0 7 0; +#X connect 12 0 13 0; +#X connect 14 0 8 0; Added: trunk/examples/puredata/regression-test.pd =================================================================== --- trunk/examples/puredata/regression-test.pd (rev 0) +++ trunk/examples/puredata/regression-test.pd 2007-09-03 14:31:58 UTC (rev 88) @@ -0,0 +1,84 @@ +#N canvas 534 223 894 462 10; +#X obj 168 31 noise~; +#X obj 168 61 xtract~ spectrum; +#X obj 72 106 xtract~ irregularity_j; +#X obj 95 142 xtract~ irregularity_k; +#X obj 112 206 xtract~ tristimulus_1; +#X obj 145 269 xtract~ tristimulus_2; +#X obj 166 327 xtract~ tristimulus_3; +#X obj 315 87 xtract~ spectral_mean; +#X obj 311 140 xtract~ spectral_variance; +#X obj 326 194 xtract~ spectral_standard_deviation; +#X obj 375 245 xtract~ spectral_kurtosis; +#X floatatom 378 281 5 0 0 0 - - -; +#X floatatom 88 252 5 0 0 0 - - -; +#X floatatom 116 317 5 0 0 0 - - -; +#X floatatom 156 376 5 0 0 0 - - -; +#X floatatom 57 197 5 0 0 0 - - -; +#X floatatom 107 179 5 0 0 0 - - -; +#X floatatom 666 292 5 0 0 0 - - -; +#X obj 603 98 xtract~ mean; +#X obj 599 151 xtract~ variance; +#X obj 614 205 xtract~ standard_deviation; +#X obj 663 256 xtract~ kurtosis; +#X obj 430 365 xtract~ smoothness; +#X floatatom 436 400 5 0 0 0 - - -; +#X msg 696 129 list \$1; +#X msg 762 172 list \$1; +#X msg 728 230 list \$1; +#X msg 505 214 list \$1; +#X msg 375 168 list \$1; +#X msg 465 116 list \$1; +#X obj 611 406 xtract~ loudness; +#X floatatom 612 430 5 0 0 0 - - -; +#X obj 649 360 xtract~ inharmonicity; +#X floatatom 658 385 5 0 0 0 - - -; +#X floatatom 750 327 5 0 0 0 - - -; +#X obj 195 404 xtract~ autocorrelation; +#X obj 257 445 xtract~ bark_coefficients; +#X obj 49 437 xtract~ peak_spectrum; +#X obj 486 438 xtract~ mfcc; +#X obj 28 24 block~ 512; +#X connect 0 0 1 0; +#X connect 0 0 18 0; +#X connect 0 0 19 0; +#X connect 0 0 20 0; +#X connect 0 0 21 0; +#X connect 1 0 2 0; +#X connect 1 0 3 0; +#X connect 1 0 4 0; +#X connect 1 0 7 0; +#X connect 1 0 8 0; +#X connect 1 0 9 0; +#X connect 1 0 10 0; +#X connect 1 0 5 0; +#X connect 1 0 6 0; +#X connect 1 0 22 0; +#X connect 1 0 30 0; +#X connect 1 0 32 0; +#X connect 1 0 35 0; +#X connect 1 0 36 0; +#X connect 1 0 37 0; +#X connect 1 0 38 0; +#X connect 2 0 15 0; +#X connect 3 0 16 0; +#X connect 4 0 12 0; +#X connect 5 0 13 0; +#X connect 6 0 14 0; +#X connect 7 0 29 0; +#X connect 8 0 28 0; +#X connect 9 0 27 0; +#X connect 10 0 11 0; +#X connect 18 0 24 0; +#X connect 19 0 25 0; +#X connect 20 0 26 0; +#X connect 21 0 17 0; +#X connect 22 0 23 0; +#X connect 24 0 19 1; +#X connect 25 0 20 1; +#X connect 26 0 21 1; +#X connect 27 0 10 1; +#X connect 28 0 9 1; +#X connect 29 0 8 1; +#X connect 30 0 31 0; +#X connect 32 0 33 0; Added: trunk/examples/puredata/simple-example.pd =================================================================== --- trunk/examples/puredata/simple-example.pd (rev 0) +++ trunk/examples/puredata/simple-example.pd 2007-09-03 14:31:58 UTC (rev 88) @@ -0,0 +1,8 @@ +#N canvas 0 0 450 300 10; +#X obj 144 80 xtract~ spectrum; +#X obj 154 26 osc~ 440; +#X obj 145 129 xtract~ spectral_mean; +#X floatatom 146 184 5 0 0 0 - - -; +#X connect 0 0 2 0; +#X connect 1 0 0 0; +#X connect 2 0 3 0; Modified: trunk/examples/puredata/xtract~.c =================================================================== --- trunk/examples/puredata/xtract~.c 2007-09-02 14:28:00 UTC (rev 87) +++ trunk/examples/puredata/xtract~.c 2007-09-03 14:31:58 UTC (rev 88) @@ -27,6 +27,15 @@ #define BLOCKSIZE 1024 /* FIX: this should be dynamic - somehow */ #define NYQUIST 22050.0f +#ifndef isnan + /* FIX: should probably try to handle signalling NaNs */ + int isnan(x){ if(x == x) return 0; else return 1;} +#endif + +#ifndef isinf + int isinf(x) {if(x == 1.0 / 0. || x == -1.0 / 0.) return 1; else return 0;} +#endif + static t_class *xtract_class; /* Struct for keeping track of memory allocations */ @@ -143,7 +152,7 @@ if(n_args){ for(n = 0; n < n_args; n++){ argv_max = &fd[f].argv.max[n]; - //post("Argument %d, max: %.2f", n, *argv_max); + /*post("Argument %d, max: %.2f", n, *argv_max); */ } if(type == XTRACT_MEL_FILTER){ x->memory.argv = (size_t)(n_args * sizeof(xtract_mel_filter)); @@ -249,9 +258,10 @@ int i; - i = XTRACT_FEATURES; xtract_function_descriptor_t *fd, *d; + i = XTRACT_FEATURES; + fd = (xtract_function_descriptor_t *)xtract_make_descriptors(); post("\nxtract~: Feature List\n"); Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-09-02 14:28:00 UTC (rev 87) +++ trunk/src/scalar.c 2007-09-03 14:31:58 UTC (rev 88) @@ -28,6 +28,14 @@ #include <string.h> #include <stdio.h> +#ifndef powf + #define powf pow +#endif + +#ifndef expf + #define expf exp +#endif + int xtract_mean(const float *data, const int N, const void *argv, float *result){ int n = N; Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-09-02 14:28:00 UTC (rev 87) +++ trunk/src/vector.c 2007-09-03 14:31:58 UTC (rev 88) @@ -27,6 +27,15 @@ #include <string.h> #include <stdlib.h> +#ifndef roundf + float roundf(float f){ + if (f - (int)f >= 0.5) + return (float)((int)f + 1); + else + return (float)((int)f); + } +#endif + #ifdef XTRACT_FFT #include <fftw3.h> @@ -411,7 +420,7 @@ while(n--){ if(freqs[n]){ ratio = freqs[n] / f0; - nearest = round(ratio); + nearest = roundf(ratio); distance = fabs(nearest - ratio); if(distance > threshold) result[n] = result[M + n] = 0.f; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-03 15:03:25
|
Revision: 89 http://libxtract.svn.sourceforge.net/libxtract/?rev=89&view=rev Author: postlude Date: 2007-09-03 08:03:21 -0700 (Mon, 03 Sep 2007) Log Message: ----------- Back to C99 in CFLAGS, but at least we (should) have the C89 option if anyone can't make it work with their compiler Modified Paths: -------------- trunk/configure.in trunk/examples/simpletest/simpletest.c Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-03 14:31:58 UTC (rev 88) +++ trunk/configure.in 2007-09-03 15:03:21 UTC (rev 89) @@ -64,7 +64,7 @@ # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c89 -I/usr/local/include" +CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99 -I/usr/local/include" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, Modified: trunk/examples/simpletest/simpletest.c =================================================================== --- trunk/examples/simpletest/simpletest.c 2007-09-03 14:31:58 UTC (rev 88) +++ trunk/examples/simpletest/simpletest.c 2007-09-03 15:03:21 UTC (rev 89) @@ -1,25 +1,27 @@ -/* xtract~ - PD library for feature extraction -Copyright (C) 2006 Jamie Bullock +/* 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. + */ -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. -*/ - #include "xtract/libxtract.h" #include <stdio.h> -int main() { +int main(void) { float mean = 0, vector[] = {1, 2, 3}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-04 19:07:57
|
Revision: 90 http://libxtract.svn.sourceforge.net/libxtract/?rev=90&view=rev Author: postlude Date: 2007-09-04 12:07:55 -0700 (Tue, 04 Sep 2007) Log Message: ----------- Added basic SWIG wrapper generator (use ./configure --enable-swig etc) Modified Paths: -------------- trunk/ChangeLog trunk/Makefile.am trunk/autogen.sh trunk/configure.in trunk/src/scalar.c Added Paths: ----------- trunk/bootstrap trunk/swig/ trunk/swig/Makefile.am trunk/swig/test.py trunk/swig/xtract.i Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-09-03 15:03:21 UTC (rev 89) +++ trunk/ChangeLog 2007-09-04 19:07:55 UTC (rev 90) @@ -1,3 +1,7 @@ +2007-09-04 Jamie Bullock <ja...@po...> + * version 0.4.8 + * Added cursory SWIG Python wrapper generator + 2007-04-20 Jamie Bullock <ja...@po...> * version 0.4.7 * Added MSP example Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-09-03 15:03:21 UTC (rev 89) +++ trunk/Makefile.am 2007-09-04 19:07:55 UTC (rev 90) @@ -1,7 +1,14 @@ -MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ +MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ py-compile -SUBDIRS = src xtract examples @DOXYGEN@ +if BUILD_SWIG +SWIG_DIR = swig +endif +SUBDIRS = src xtract examples $(SWIG_DIR) @DOXYGEN@ + pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libxtract.pc +ACLOCAL_AMFLAGS = -I m4 + +EXTRA_DIST = bootstrap autogen.sh README TODO Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-09-03 15:03:21 UTC (rev 89) +++ trunk/autogen.sh 2007-09-04 19:07:55 UTC (rev 90) @@ -8,11 +8,11 @@ case `uname -s` in Linux) LIBTOOLIZE=libtoolize - ACLOCALARGS='' + ACLOCALARGS='-I m4' ;; Darwin) LIBTOOLIZE=glibtoolize - ACLOCALARGS='-I /usr/share/aclocal' + ACLOCALARGS='-I /usr/share/aclocal -I m4' ;; *) echo error: unrecognized OS exit 1 Added: trunk/bootstrap =================================================================== --- trunk/bootstrap (rev 0) +++ trunk/bootstrap 2007-09-04 19:07:55 UTC (rev 90) @@ -0,0 +1,4 @@ +#!/bin/sh + +autoreconf --force --install -I config -I m4 + Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-03 15:03:21 UTC (rev 89) +++ trunk/configure.in 2007-09-04 19:07:55 UTC (rev 90) @@ -4,13 +4,13 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 7) +m4_define(libxtract_fix_version, 8) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) PACKAGE=libxtract -AC_INIT(libxtract, libxtract_version, bu...@po...) +AC_INIT(libxtract, libxtract_version, lib...@li...) AC_DEFINE(LIBXTRACT_VERSION, libxtract_version, [LibXtract Version]) AM_INIT_AUTOMAKE($PACKAGE, $LIBXTRACT_VERSION) AM_CONFIG_HEADER(config.h) @@ -64,7 +64,7 @@ # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99 -I/usr/local/include" +CFLAGS="$CFLAGS -pedantic -ansi -fno-strict-aliasing -Wall -std=c99 -I/usr/local/include" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, @@ -124,6 +124,7 @@ AM_CONDITIONAL(BUILD_PD_EXAMPLE, test "x${pd_example}" = 'xtrue') + dnl Enable debugging (no) AC_ARG_ENABLE(debug, [ --enable-debug[[=value]] compile with debug [[default=no]]], @@ -135,6 +136,25 @@ CFLAGS="$CFLAGS -O0 -ggdb -g" fi +AC_ARG_ENABLE(swig, + [ --enable-swig Generate swig bindings], + [case "${enableval}" in + yes) swig=true ;; + no) swig=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-swig) ;; + esac],[swig=false]) + + +dnl SWIG stuff +if [[ "$swig" = "true" ]] ; then + AC_PROG_SWIG(1.3.21) + AM_PATH_PYTHON + SWIG_PYTHON + AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) +fi + +AM_CONDITIONAL(BUILD_SWIG, test "x${swig}" = 'xtrue') + dnl ------------------------------------------ dnl ---- do some magic to gues the host opsys dnl ---- taken from libvorbis configure.in @@ -212,7 +232,7 @@ AC_CONFIG_FILES([doc/documentation.doxygen libxtract.pc]) -AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile) +AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile swig/Makefile) echo echo "**************************************************************" @@ -240,7 +260,11 @@ else echo "PD external: no" fi - +if test "$swig" == "true"; then + echo "SWIG Python bindings: yes" +else + echo "SWIG Python bindings: no" +fi echo echo "**************************************************************" echo Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-09-03 15:03:21 UTC (rev 89) +++ trunk/src/scalar.c 2007-09-04 19:07:55 UTC (rev 90) @@ -39,10 +39,12 @@ int xtract_mean(const float *data, const int N, const void *argv, float *result){ int n = N; + + *result = 0.f; while(n--) *result += data[n]; - + *result /= N; return XTRACT_SUCCESS; Added: trunk/swig/Makefile.am =================================================================== --- trunk/swig/Makefile.am (rev 0) +++ trunk/swig/Makefile.am 2007-09-04 19:07:55 UTC (rev 90) @@ -0,0 +1,18 @@ +MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so + +BUILT_SOURCES = $(srcdir)/xtract_wrap.c +SWIG_SOURCES = xtract.i + +pkgpython_PYTHON = xtract.py +pkgpyexec_LTLIBRARIES = _xtract.la +_xtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) +_xtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src +_xtract_la_LDFLAGS = -module -lxtract +_xtract_la_LIBADD = ../src/libxtract.la + +xtract_wrap.c : $(SWIG_SOURCES) + $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $< + +clean-local: + -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc + Added: trunk/swig/test.py =================================================================== --- trunk/swig/test.py (rev 0) +++ trunk/swig/test.py 2007-09-04 19:07:55 UTC (rev 90) @@ -0,0 +1,18 @@ +#!/usr/bin/python + +import xtract + +len = 5 + +a = xtract.new_floatArray(len) + +for i in range(0, len): + xtract.floatArray_setitem(a, i, 2*i) + +retval,result = xtract.xtract_mean(a,len,None) + +print result + + + + Added: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i (rev 0) +++ trunk/swig/xtract.i 2007-09-04 19:07:55 UTC (rev 90) @@ -0,0 +1,12 @@ +%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" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-10-04 14:29:35
|
Revision: 100 http://libxtract.svn.sourceforge.net/libxtract/?rev=100&view=rev Author: postlude Date: 2007-10-04 07:29:30 -0700 (Thu, 04 Oct 2007) Log Message: ----------- Incremented FIX revision number and updated ChangeLog Modified Paths: -------------- trunk/ChangeLog trunk/configure.in Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-10-03 13:43:16 UTC (rev 99) +++ trunk/ChangeLog 2007-10-04 14:29:30 UTC (rev 100) @@ -1,3 +1,7 @@ +2007-10-04 Dan Stowell + * version 0.4.9 + * Fixed and tidied MFCC functions + 2007-09-04 Jamie Bullock <ja...@po...> * version 0.4.8 * Added cursory SWIG Python wrapper generator Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-10-03 13:43:16 UTC (rev 99) +++ trunk/configure.in 2007-10-04 14:29:30 UTC (rev 100) @@ -4,7 +4,7 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 8) +m4_define(libxtract_fix_version, 9) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-12-27 20:37:22
|
Revision: 109 http://libxtract.svn.sourceforge.net/libxtract/?rev=109&view=rev Author: postlude Date: 2007-12-27 12:37:15 -0800 (Thu, 27 Dec 2007) Log Message: ----------- Added l-norm/spectral flux Modified Paths: -------------- trunk/src/delta.c trunk/src/descriptors.c trunk/src/libxtract.c trunk/xtract/libxtract.h trunk/xtract/xtract_delta.h Modified: trunk/src/delta.c =================================================================== --- trunk/src/delta.c 2007-12-27 17:51:07 UTC (rev 108) +++ trunk/src/delta.c 2007-12-27 20:37:15 UTC (rev 109) @@ -20,13 +20,50 @@ /* xtract_delta.c: defines functions that extract a feature as a single value from more than one input vector */ +#include <math.h> + #include "xtract/libxtract.h" int xtract_flux(const float *data, const int N, const void *argv , float *result){ + return xtract_lnorm(data, N, argv, result); - return XTRACT_FEATURE_NOT_IMPLEMENTED; +} +int xtract_lnorm(const float *data, const int N, const void *argv , float *result){ + + int feature, + n, + type; + + float order, + temp = 0.f; + + order = *(float *)argv; + type = (int)*(float *)argv+1; + + order = order > 0 ? order : 1.f; + + switch(type){ + + case XTRACT_POSITIVE_SLOPE: + for(n = 0; n < N; n++){ + temp = powf(data[n], order); + if(data[n] > 0) + *result += temp; + } + break; + default: + for(n = 0; n < N; n++) + *result += powf(data[n], order); + break; + + } + + *result = powf(*result, 1.f / order); + + return XTRACT_SUCCESS; + } int xtract_attack_time(const float *data, const int N, const void *argv , float *result){ @@ -41,9 +78,21 @@ } -int xtract_delta_feature(const float *data, const int N, const void *argv, float *result){ +int xtract_difference_vector(const float *data, const int N, const void *argv, float *result){ - return XTRACT_FEATURE_NOT_IMPLEMENTED; + float *frame1, + *frame2; + int n; + + n = N >> 1; + + frame1 = data; + frame2 = data + n; + + while(n--) + result[n] = frame1[n] - frame2[n]; + + return XTRACT_SUCCESS; + } - Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2007-12-27 17:51:07 UTC (rev 108) +++ trunk/src/descriptors.c 2007-12-27 20:37:15 UTC (rev 109) @@ -197,6 +197,8 @@ /* argc = 2 */; case XTRACT_ROLLOFF: case XTRACT_PEAK_SPECTRUM: + case XTRACT_FLUX: + case XTRACT_LNORM: *argv_donor = XTRACT_ANY; *(argv_donor + 1) = XTRACT_ANY; break; @@ -301,6 +303,8 @@ case XTRACT_ASDF: case XTRACT_ZCR: case XTRACT_RMS_AMPLITUDE: + case XTRACT_FLUX: + case XTRACT_LNORM: *data_format = XTRACT_AUDIO_SAMPLES; break; case XTRACT_TONALITY: @@ -316,10 +320,9 @@ case XTRACT_SHARPNESS: *data_format = XTRACT_BARK_COEFFS; break; - case XTRACT_FLUX: case XTRACT_ATTACK_TIME: case XTRACT_DECAY_TIME: - case XTRACT_DELTA_FEATURE: + case XTRACT_DIFFERENCE_VECTOR: default: *data_format = XTRACT_NO_DATA; break; @@ -350,8 +353,9 @@ case XTRACT_IRREGULARITY_J: case XTRACT_ATTACK_TIME: case XTRACT_DECAY_TIME: - case XTRACT_DELTA_FEATURE: + case XTRACT_DIFFERENCE_VECTOR: case XTRACT_FLUX: + case XTRACT_LNORM: case XTRACT_F0: case XTRACT_FAILSAFE_F0: case XTRACT_MFCC: @@ -798,6 +802,13 @@ "Extract the spectral flux of an audio spectrum"); strcpy(author, ""); break; + case XTRACT_LNORM: + strcpy(name, "L-norm"); + strcpy(p_name, "L-norm"); + strcpy(desc, "Extract the L-norm of a vector"); + strcpy(p_desc, "Extract the L-norm of a vector"); + strcpy(author, ""); + break; case XTRACT_ATTACK_TIME: strcpy(name, "attack_time"); strcpy(p_name, "Attack Time"); @@ -812,11 +823,11 @@ strcpy(p_desc, "Extract the decay time of an audio signal"); strcpy(author, ""); break; - case XTRACT_DELTA_FEATURE: - strcpy(name, "delta_feature"); - strcpy(p_name, "Delta Feature"); - strcpy(desc, "Extract the time derivative of a feature"); - strcpy(p_desc, "Extract the time derivative of a feature"); + case XTRACT_DIFFERENCE_VECTOR: + strcpy(name, "difference_vector"); + strcpy(p_name, "Difference vector"); + strcpy(desc, "Extract the difference between two vectors"); + strcpy(p_desc, "Extract the difference between two vectors"); strcpy(author, ""); break; case XTRACT_AUTOCORRELATION_FFT: @@ -897,6 +908,8 @@ case XTRACT_NOISINESS: case XTRACT_CREST: case XTRACT_ROLLOFF: + case XTRACT_FLUX: + case XTRACT_LNORM: *argc = 2; *argv_type = XTRACT_FLOAT; break; @@ -936,10 +949,9 @@ 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_DIFFERENCE_VECTOR: case XTRACT_AUTOCORRELATION_FFT: case XTRACT_DCT: case XTRACT_AUTOCORRELATION: @@ -995,6 +1007,8 @@ case XTRACT_HPS: case XTRACT_F0: case XTRACT_FAILSAFE_F0: + case XTRACT_FLUX: + case XTRACT_LNORM: case XTRACT_NONZERO_COUNT: *is_scalar = XTRACT_TRUE; break; @@ -1035,6 +1049,8 @@ case XTRACT_LOWEST_VALUE: case XTRACT_HIGHEST_VALUE: case XTRACT_SUM: + case XTRACT_FLUX: + case XTRACT_LNORM: case XTRACT_NONZERO_COUNT: *result_unit = XTRACT_ANY; *result_min = XTRACT_ANY; Modified: trunk/src/libxtract.c =================================================================== --- trunk/src/libxtract.c 2007-12-27 17:51:07 UTC (rev 108) +++ trunk/src/libxtract.c 2007-12-27 20:37:15 UTC (rev 109) @@ -65,10 +65,11 @@ xtract_f0, xtract_failsafe_f0, /* xtract_delta.h */ + xtract_lnorm, xtract_flux, xtract_attack_time, xtract_decay_time, - xtract_delta_feature, + xtract_difference_vector, /* xtract_vector.h */ xtract_autocorrelation, xtract_amdf, Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-12-27 17:51:07 UTC (rev 108) +++ trunk/xtract/libxtract.h 2007-12-27 20:37:15 UTC (rev 109) @@ -67,7 +67,7 @@ * @{ */ -#define XTRACT_FEATURES 56 +#define XTRACT_FEATURES 57 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ enum xtract_features_ { @@ -111,10 +111,11 @@ XTRACT_HPS, XTRACT_F0, XTRACT_FAILSAFE_F0, + XTRACT_LNORM, XTRACT_FLUX, XTRACT_ATTACK_TIME, XTRACT_DECAY_TIME, - XTRACT_DELTA_FEATURE, + XTRACT_DIFFERENCE_VECTOR, XTRACT_AUTOCORRELATION, XTRACT_AMDF, XTRACT_ASDF, @@ -148,6 +149,11 @@ XTRACT_EQUAL_AREA }; +enum xtract_lnorm_filter_types_ { + XTRACT_POSITIVE_SLOPE, + XTRACT_NEGATIVE_SLOPE +}; + /** \brief Enumeration of return codes */ enum xtract_return_codes_ { XTRACT_SUCCESS, Modified: trunk/xtract/xtract_delta.h =================================================================== --- trunk/xtract/xtract_delta.h 2007-12-27 17:51:07 UTC (rev 108) +++ trunk/xtract/xtract_delta.h 2007-12-27 20:37:15 UTC (rev 109) @@ -29,8 +29,21 @@ #include "xtract_types.h" -/* \brief Extract spectral flux as defined by Gaël Richard (2006)*/ +/* \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 + * + * \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 + * \param *argv: a pointer to an array of floats, the first representing the "norm order". The second argument represents the filter type determining what values we consider from the difference vector as given in the enumeration xtract_lnorm_filter_types_ (libxtract.h) + * \param *result: a pointer to a float representing the flux + * + */ +int xtract_lnorm(const float *data, const int N, const void *argv , float *result); /*xtract_frame_tracker *xf */ /** \brief Extract attack Time */ @@ -42,8 +55,15 @@ /* xtract_amp_tracker *xa */ -/** \brief A generic function to calculate the delta of a feature over a given period (in frames) */ -int xtract_delta_feature(const float *data, const int N, const void *argv, float *result); +/** \brief Extract the difference between two vectors + * + * \param *data a pointer to an array representing two distinct vectors, e.g. two successive magnitude spectra. + * \param N the size of the array pointed to by *data + * \param *argv a pointer to NULL + * \param *result a pointer to an array of size N / 2 representing the difference between the two input vectors. + * + * */ +int xtract_difference_vector(const float *data, const int N, const void *argv, float *result); /*xtract_frame_tracker *xf */ /*float frames*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-12-29 18:35:38
|
Revision: 112 http://libxtract.svn.sourceforge.net/libxtract/?rev=112&view=rev Author: postlude Date: 2007-12-29 10:35:35 -0800 (Sat, 29 Dec 2007) Log Message: ----------- - added bark coefficients PD example - Fixed Java bindings compile problem Modified Paths: -------------- trunk/examples/puredata/regression-test.pd trunk/swig/java/Makefile.am trunk/swig/python/test.py Added Paths: ----------- trunk/examples/puredata/bark-example.pd Added: trunk/examples/puredata/bark-example.pd =================================================================== --- trunk/examples/puredata/bark-example.pd (rev 0) +++ trunk/examples/puredata/bark-example.pd 2007-12-29 18:35:35 UTC (rev 112) @@ -0,0 +1,52 @@ +#N canvas 191 188 450 625 10; +#N canvas 0 0 450 300 graph1 0; +#X array bark 26 float 5; +#A 0 0 0 0 0 0 0 0.00450555 0 0 0 0.0906432 0 0 0.154719 0 0.0683638 +0.0384251 0.0569213 0.0220149 0.0976565 0.064886 0.067408 0.0374335 +0.000314513 4.48489e-05 0; +#X coords 0 1 25 -1 200 140 1; +#X restore 236 -233 graph; +#X obj 273 104 xtract~ spectrum 64; +#X obj 272 73 xtract~ windowed 64; +#X obj 272 136 tabsend~ mags; +#N canvas 0 0 450 300 graph2 0; +#X array mags 32 float 5; +#A 0 0.00450555 0.0906432 0.154719 0.0683638 0.0384251 0.0569213 0.0220149 +0.0423353 0.0553211 0.018837 0.046049 0.0530074 0.0144005 0.0165512 +0.0167357 0.00365258 0.000494011 0.000160456 7.35776e-05 3.51928e-05 +3.1222e-05 1.40643e-05 1.18581e-05 8.65756e-06 7.31448e-06 6.333e-06 +2.75085e-06 4.85414e-06 3.08083e-06 2.56348e-06 3.22329e-06 1.50987e-08 +; +#X coords 0 1 31 -1 200 140 1; +#X restore 16 -232 graph; +#N canvas 3 50 450 300 bark 0; +#X obj 364 19 block~ 32; +#X obj 144 160 tabsend~ bark; +#X obj 145 93 tabreceive~ mags; +#X obj 145 118 xtract~ bark_coefficients 32; +#X connect 2 0 3 0; +#X connect 3 0 1 0; +#X restore 271 167 pd bark; +#N canvas 0 0 450 300 graph3 0; +#X array waveform 67 float 5; +#A 0 -0.304942 0 0.304942 0.578981 0.795978 0.938463 0.999999 0.985604 +0.910237 0.795681 0.666471 0.545664 0.451213 0.393581 0.37492 0.389832 +0.427409 0.474038 0.516335 0.543621 0.549513 0.532424 0.495019 0.442906 +0.382948 0.321642 0.2639 0.212453 0.167896 0.129229 0.094662 0.062379 +0.0310556 8.38604e-07 -0.031054 -0.0623773 -0.0946602 -0.129227 -0.167893 +-0.212451 -0.263897 -0.321639 -0.382945 -0.442903 -0.495017 -0.532422 +-0.549513 -0.543622 -0.516337 -0.474041 -0.427411 -0.389833 -0.37492 +-0.393579 -0.451209 -0.545658 -0.666465 -0.795674 -0.910232 -0.985601 +-1 -0.938469 -0.795988 -0.578994 -0.304958 -1.67721e-05 0.304926; +#X coords 0 1 66 -1 200 140 1; +#X restore 17 -56 graph; +#X obj 23 135 loadbang; +#X obj 271 47 tabosc4~ waveform; +#X obj 270 21 sig~ 2000; +#X msg 23 165 \; waveform sinesum 64 0.8 0.3 0.3 0.3 0.1 \; waveform +normalize 1; +#X connect 1 0 3 0; +#X connect 2 0 1 0; +#X connect 7 0 10 0; +#X connect 8 0 2 0; +#X connect 9 0 8 0; Modified: trunk/examples/puredata/regression-test.pd =================================================================== --- trunk/examples/puredata/regression-test.pd 2007-12-29 17:33:17 UTC (rev 111) +++ trunk/examples/puredata/regression-test.pd 2007-12-29 18:35:35 UTC (rev 112) @@ -1,4 +1,4 @@ -#N canvas 534 223 894 462 10; +#N canvas 520 223 894 462 10; #X obj 168 31 noise~; #X obj 168 61 xtract~ spectrum; #X obj 72 106 xtract~ irregularity_j; @@ -38,7 +38,7 @@ #X obj 257 445 xtract~ bark_coefficients; #X obj 49 437 xtract~ peak_spectrum; #X obj 486 438 xtract~ mfcc; -#X obj 28 24 block~ 512; +#X obj 28 24 block~ 1024; #X connect 0 0 1 0; #X connect 0 0 18 0; #X connect 0 0 19 0; Modified: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am 2007-12-29 17:33:17 UTC (rev 111) +++ trunk/swig/java/Makefile.am 2007-12-29 18:35:35 UTC (rev 112) @@ -1,17 +1,81 @@ + javasources = \ - xtractJNI.java \ - xtract.java \ floatArray.java \ SWIGTYPE_p_float.java \ - SWIGTYPE_p_void.java - + SWIGTYPE_p_int.java \ + SWIGTYPE_p_p_float.java \ + SWIGTYPE_p_unit_.java \ + SWIGTYPE_p_void.java \ + xtract_bool_t.java \ + xtractConstants.java \ + xtract_feature_init_.java \ + xtract_features_.java \ + xtract_feature_types_.java \ + xtract_function_descriptor_t_algo.java \ + xtract_function_descriptor_t_argv.java \ + xtract_function_descriptor_t_data.java \ + xtract_function_descriptor_t.java \ + xtract_function_descriptor_t_result.java \ + xtract_function_descriptor_t_result_scalar.java \ + xtract_function_descriptor_t_result_vector.java \ + xtract.java \ + xtractJNI.java \ + xtract_lnorm_filter_types_.java \ + xtract_mel_filter.java \ + xtract_mfcc_types_.java \ + xtract_return_codes_.java \ + xtract_spectrum_.java \ + xtract_type_t.java \ + xtract_unit_t.java \ + xtract_vector_t.java \ + xtract_window_types_.java + javaclasses = \ - xtractJNI.class \ - xtract.class \ floatArray.class \ SWIGTYPE_p_float.class \ - SWIGTYPE_p_void.class + SWIGTYPE_p_int.class \ + SWIGTYPE_p_p_float.class \ + SWIGTYPE_p_unit_.class \ + SWIGTYPE_p_void.class \ + xtract_bool_t.class \ + xtractConstants.class \ + xtract_feature_init_.class \ + xtract_features_.class \ + xtract_feature_types_.class \ + xtract_function_descriptor_t_algo.class \ + xtract_function_descriptor_t_argv.class \ + xtract_function_descriptor_t_data.class \ + xtract_function_descriptor_t.class \ + xtract_function_descriptor_t_result.class \ + xtract_function_descriptor_t_result_scalar.class \ + xtract_function_descriptor_t_result_vector.class \ + xtract.class \ + xtractJNI.class \ + xtract_lnorm_filter_types_.class \ + xtract_mel_filter.class \ + xtract_mfcc_types_.class \ + xtract_return_codes_.class \ + xtract_spectrum_.class \ + xtract_type_t.class \ + xtract_unit_t.class \ + xtract_vector_t.class \ + xtract_window_types_.class + +#javasources = \ +# xtractJNI.java \ +# xtract.java \ +# floatArray.java \ +# SWIGTYPE_p_float.java \ +# SWIGTYPE_p_void.java + +#javaclasses = \ +# xtractJNI.class \ +# xtract.class \ +# floatArray.class \ +# SWIGTYPE_p_float.class \ +# SWIGTYPE_p_void.class + MAINTAINERCLEANFILES = $(javasources) Makefile.in BUILT_SOURCES = $(srcdir)/xtract_wrap.c Modified: trunk/swig/python/test.py =================================================================== --- trunk/swig/python/test.py 2007-12-29 17:33:17 UTC (rev 111) +++ trunk/swig/python/test.py 2007-12-29 18:35:35 UTC (rev 112) @@ -34,4 +34,16 @@ for i in range(len): print result[i] + +print 'Computing windowed subframes...' + +for i in range(0, len): + a[i] = 1.0 + +window = xtract.xtract_init_window(len / 2, xtract.XTRACT_HANN) +xtract.xtract_features_from_subframes(a, len, xtract.XTRACT_WINDOWED, window, result) + +for i in range(len): + print result[i] + print '\nFinished!\n' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2008-01-01 16:17:49
|
Revision: 113 http://libxtract.svn.sourceforge.net/libxtract/?rev=113&view=rev Author: postlude Date: 2008-01-01 08:17:44 -0800 (Tue, 01 Jan 2008) Log Message: ----------- - Improvements to SWIG bindings generation script - Fixed omission in xtract_bark_coefficients that was causing the output to be complete b/s! This fixed bark_coeffs and loudness feature which depends on it - Changes to descriptor API: added is_delta and id. id corresponds to value in xtract_features_ enum and is useful for programmatic conversions between id and name string. Modified Paths: -------------- trunk/src/descriptors.c trunk/src/fini.c trunk/src/init.c trunk/src/vector.c trunk/swig/java/Makefile.am trunk/swig/python/test.py trunk/swig/xtract.i trunk/xtract/libxtract.h Modified: trunk/src/descriptors.c =================================================================== --- trunk/src/descriptors.c 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/src/descriptors.c 2008-01-01 16:17:44 UTC (rev 113) @@ -24,7 +24,7 @@ #include <string.h> #define XTRACT -void *xtract_make_descriptors(){ +xtract_function_descriptor_t *xtract_make_descriptors(void){ int f , F; char *name, *p_name, *desc, *p_desc, *author; @@ -45,6 +45,7 @@ while(f--){ d = &fd[f]; + d->id = f; argc = &d->argc; argv_type = &d->argv.type; @@ -502,7 +503,7 @@ strcpy(author, ""); break; case XTRACT_ROLLOFF: - strcpy(name, "spectral_rolloff"); + strcpy(name, "rolloff"); strcpy(p_name, "Spectral Rolloff"); strcpy(desc, "Extract the rolloff point of a spectrum"); @@ -1250,7 +1251,7 @@ return fd; } -int xtract_free_descriptors(void *fd){ +int xtract_free_descriptors(xtract_function_descriptor_t *fd){ if (fd != NULL) { free(fd); Modified: trunk/src/fini.c =================================================================== --- trunk/src/fini.c 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/src/fini.c 2008-01-01 16:17:44 UTC (rev 113) @@ -22,7 +22,8 @@ #ifdef XTRACT_FFT #include <fftw3.h> -#include "xtract_globals_private.h" +//#include "xtract_globals_private.h" +#include "xtract/libxtract.h" #endif #ifdef __GNUC__ @@ -32,15 +33,8 @@ #endif { #ifdef XTRACT_FFT - if(fft_plans.spectrum_plan != NULL) - fftwf_destroy_plan(fft_plans.spectrum_plan); - if(fft_plans.autocorrelation_fft_plan_1 != NULL) - fftwf_destroy_plan(fft_plans.autocorrelation_fft_plan_1); - if(fft_plans.autocorrelation_fft_plan_2 != NULL) - fftwf_destroy_plan(fft_plans.autocorrelation_fft_plan_2); - if(fft_plans.dct_plan != NULL) - fftwf_destroy_plan(fft_plans.dct_plan); - fftwf_cleanup(); +xtract_free_fft(); +fftwf_cleanup(); #endif } Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/src/init.c 2008-01-01 16:17:44 UTC (rev 113) @@ -203,6 +203,18 @@ } +void xtract_free_fft(void){ + if(fft_plans.spectrum_plan != NULL) + fftwf_destroy_plan(fft_plans.spectrum_plan); + if(fft_plans.autocorrelation_fft_plan_1 != NULL) + fftwf_destroy_plan(fft_plans.autocorrelation_fft_plan_1); + if(fft_plans.autocorrelation_fft_plan_2 != NULL) + fftwf_destroy_plan(fft_plans.autocorrelation_fft_plan_2); + if(fft_plans.dct_plan != NULL) + fftwf_destroy_plan(fft_plans.dct_plan); +// fftwf_cleanup(); +} + #endif int xtract_init_bark(int N, float sr, int *band_limits){ Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/src/vector.c 2008-01-01 16:17:44 UTC (rev 113) @@ -368,6 +368,7 @@ limits = (int *)argv; for(band = 0; band < XTRACT_BARK_BANDS - 1; band++){ + result[band] = 0.f; for(n = limits[band]; n < limits[band + 1]; n++) result[band] += data[n]; } Modified: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/swig/java/Makefile.am 2008-01-01 16:17:44 UTC (rev 113) @@ -1,6 +1,7 @@ javasources = \ floatArray.java \ + intArray.java \ SWIGTYPE_p_float.java \ SWIGTYPE_p_int.java \ SWIGTYPE_p_p_float.java \ @@ -32,6 +33,7 @@ javaclasses = \ floatArray.class \ + intArray.class \ SWIGTYPE_p_float.class \ SWIGTYPE_p_int.class \ SWIGTYPE_p_p_float.class \ Modified: trunk/swig/python/test.py =================================================================== --- trunk/swig/python/test.py 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/swig/python/test.py 2008-01-01 16:17:44 UTC (rev 113) @@ -16,9 +16,17 @@ a[i] = 2 * i temp.append(str(a[i])) -print 'The mean of ' + ', '.join(temp) + ' is: %.2f' % \ - xtract.xtract_mean(a,len,None)[1] +mean = xtract.xtract_mean(a,len,None)[1] +print 'The mean of ' + ', '.join(temp) + ' is: %.2f' % mean + +argv = xtract.floatArray(1) +argv[0] = mean + +variance = xtract.xtract_variance(a, len, argv)[1] + +print 'The variance is %.2f' % variance + print 'Computing spectrum...' argv = xtract.floatArray(1) Modified: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/swig/xtract.i 2008-01-01 16:17:44 UTC (rev 113) @@ -6,10 +6,85 @@ #include "xtract/xtract_scalar.h" #include "xtract/xtract_vector.h" #include "xtract/xtract_helper.h" +#include "xtract/xtract_macros.h" +#include "xtract/xtract_delta.h" #include "xtract/libxtract.h" %} +/* Ensure filterbank gets freed */ +/** FIX: This doesn't work, or I'm not using properly. For now just add an explicit call to destroy_filterbank() in the target code */ +%newobject create_filterbank; +%delobject destroy_filterbank; + + +/* Helper functions */ +%inline %{ + + xtract_function_descriptor_t + *get_descriptor(xtract_function_descriptor_t *fd, int i){ + + return &fd[i]; + } + + /* Return a pointer to memory allocated for a mel filterbank */ + xtract_mel_filter *create_filterbank(int n_filters, int blocksize){ + + float **filters; + xtract_mel_filter *mf; + int n, N; + + N = blocksize; + + mf = malloc(sizeof(xtract_mel_filter)); + mf->n_filters = n_filters; + + filters = (float **)malloc(n_filters * sizeof(float *)); + + for(n = 0; n < n_filters; n++) + filters[n] = (float *)malloc(N * sizeof(float)); + + mf->filters = filters; + + return mf; + + } + + /* Free a mel filterbank */ + void destroy_filterbank(xtract_mel_filter *filterbank){ + + int i = filterbank->n_filters; + float **filters; + + filters = filterbank->filters; + + while(i--) + free(filters[i]); + + free(filters); + + free(filterbank); + + } + + /* Eventually this should be deprecated */ +/* void destroy_filterbank_explicit(float **filterbank, int n_filters){ + + int i = n_filters; + + while(i--) + free(filterbank[i]); + + free(filterbank); + } +*/ + + + +%} + + %array_class(float, floatArray); +%array_class(int, intArray); %apply float *OUTPUT { float *result }; /* %apply float *INPUT { float *data }; */ @@ -17,8 +92,25 @@ %include "xtract/xtract_scalar.h" +/* We have to put xtract_delta declarations inline because it contains a mixture of vector and scalar functions */ +%inline %{ + + int xtract_flux(const float *data, const int N, const void *argv , float *result); + int xtract_lnorm(const float *data, const int N, const void *argv , float *result); + +%} + %clear float *result; +%inline %{ + + int xtract_difference_vector(const float *data, const int N, const void *argv, float *result); + +%} + %include "xtract/xtract_vector.h" %include "xtract/xtract_helper.h" +%include "xtract/xtract_macros.h" %include "xtract/libxtract.h" + + Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-12-29 18:35:35 UTC (rev 112) +++ trunk/xtract/libxtract.h 2008-01-01 16:17:44 UTC (rev 113) @@ -249,6 +249,8 @@ /** \brief Data structure containing useful information about functions provided by LibXtract. */ typedef struct _xtract_function_descriptor { + int id; + struct { char name[XTRACT_MAX_NAME_LENGTH]; char p_name[XTRACT_MAX_NAME_LENGTH]; /* pretty name */ @@ -379,6 +381,12 @@ */ int xtract_init_fft(int N, int feature_name); +/** \brief Free memory used for fft plans + * + * This function should be used to explicitly free memory allocated for ffts by xtract_init_fft(). It is primarily intended for use if a new FFT needs to be taken with a different blocksize. If only one fft size is required then there is no need to call this function since it will be called when the program exits. + * */ +void xtract_free_fft(void); + /** \brief Make a window of a given type and return a pointer to it * * \param N: the size of the window @@ -395,10 +403,10 @@ void xtract_free_window(float *window); /* \brief A function to build an array of function descriptors */ -void *xtract_make_descriptors(); +xtract_function_descriptor_t *xtract_make_descriptors(); /* \brief A function to free an array of function descriptors */ -int xtract_free_descriptors(void *fd); +int xtract_free_descriptors(xtract_function_descriptor_t *fd); /* Free functions */ /** @} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-05 14:32:22
|
Revision: 91 http://libxtract.svn.sourceforge.net/libxtract/?rev=91&view=rev Author: postlude Date: 2007-09-05 07:32:17 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Added java bindings. Everything seems to work OK, except test.java won't compile. Some kind of path error, but I can't work out how to fix it. Modified Paths: -------------- trunk/configure.in trunk/src/scalar.c Added Paths: ----------- trunk/swig/Makefile.am trunk/swig/java/ trunk/swig/java/Makefile.am trunk/swig/java/test.java trunk/swig/python/ trunk/swig/python/Makefile.am trunk/swig/python/test.py trunk/swig/python/xtract.i trunk/swig/xtract.i Removed Paths: ------------- trunk/swig/Makefile.am trunk/swig/test.py trunk/swig/xtract.i Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/configure.in 2007-09-05 14:32:17 UTC (rev 91) @@ -85,6 +85,19 @@ echo ]) +dnl If --enable-swig, make with java bindings +AC_ARG_WITH(java, + [ --with-java If --enable-swig - make with java bindings (default=no) ], + [with_java=true]) + +AM_CONDITIONAL(BUILD_JAVA, test "x${with_java}" = 'xtrue') + +dnl If --enable-swig, make with java bindings +AC_ARG_WITH(python, + [ --with-python If --enable-swig - make with python bindings (default=no) ], [with_python=true]) + +AM_CONDITIONAL(BUILD_PYTHON, test "x${with_python}" = 'xtrue') + dnl Are we building with fftw? if [[ "$fft" = "true" ]] ; then LDFLAGS="$LDFLAGS -lfftw3f" @@ -148,11 +161,27 @@ 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 + AC_PROG_JAVAC + AC_JNI_INCLUDE_DIR + + for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS + do + CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" + done + dnl AC_PROG_JAVAH + dnl AC_PATH_PROG(JAVAH,javah) +fi + +if [[ "$with_python" = "true" ]] ; then AM_PATH_PYTHON SWIG_PYTHON - AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) fi + AM_CONDITIONAL(BUILD_SWIG, test "x${swig}" = 'xtrue') dnl ------------------------------------------ @@ -232,7 +261,8 @@ AC_CONFIG_FILES([doc/documentation.doxygen libxtract.pc]) -AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile swig/Makefile) +dnl There must be a better way to do this... +AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile swig/Makefile swig/python/Makefile swig/java/Makefile) echo echo "**************************************************************" @@ -261,10 +291,15 @@ echo "PD external: no" fi if test "$swig" == "true"; then - echo "SWIG Python bindings: yes" + echo "SWIG bindings: yes" else - echo "SWIG Python bindings: no" + echo "SWIG bindings: no" fi +if test "$with_java" == "true"; then + echo "with JAVA module: yes" +else + echo "with JAVA module: no" +fi echo echo "**************************************************************" echo Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/src/scalar.c 2007-09-05 14:32:17 UTC (rev 91) @@ -36,6 +36,10 @@ #define expf exp #endif +int test(void){ + printf("Hello world"); +} + int xtract_mean(const float *data, const int N, const void *argv, float *result){ int n = N; Deleted: trunk/swig/Makefile.am =================================================================== --- trunk/swig/Makefile.am 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/swig/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -1,18 +0,0 @@ -MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so - -BUILT_SOURCES = $(srcdir)/xtract_wrap.c -SWIG_SOURCES = xtract.i - -pkgpython_PYTHON = xtract.py -pkgpyexec_LTLIBRARIES = _xtract.la -_xtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) -_xtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src -_xtract_la_LDFLAGS = -module -lxtract -_xtract_la_LIBADD = ../src/libxtract.la - -xtract_wrap.c : $(SWIG_SOURCES) - $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $< - -clean-local: - -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc - Added: trunk/swig/Makefile.am =================================================================== --- trunk/swig/Makefile.am (rev 0) +++ trunk/swig/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,11 @@ +MAINTAINERCLEANFILES = Makefile.in + +if BUILD_JAVA +JAVA_BUILD_DIR = java +endif + +if BUILD_PYTHON +PYTHON_BUILD_DIR = python +endif + +SUBDIRS = $(JAVA_BUILD_DIR) $(PYTHON_BUILD_DIR) Added: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am (rev 0) +++ trunk/swig/java/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,69 @@ +SWIG_JAVA_DIR = $(top_srcdir)/swig/java + +SWIG_CMD = $(SWIG) -I$(SWIG_JAVA_DIR) -I$(top_srcdir) -java + +swigjavafiles = \ + xtractJNI.java \ + xtract.java \ + floatArray.java \ + SWIGTYPE_p_float.java \ + SWIGTYPE_p_void.java + +swigcfiles = xtractjavac_wrap.c + +swiggenfiles = $(swigjavafiles) $(swigcfiles) + +javafiles = $(swigjavafiles) + +# Note : the order of these is important since there is no formal +# dependency checking. +javaclasses = \ + xtractJNI.class \ + xtract.class \ + floatArray.class \ + SWIGTYPE_p_float.class \ + SWIGTYPE_p_void.class + +$(swiggenfiles): ../xtract.i + $(SWIG_CMD) -package xtract.core -o xtractjavac_wrap.c ../xtract.i + +# Must have "exec" in the name. +execjavawrapperdir = ${libdir} + +libxtract = $(top_builddir)/src/libxtract$(LIB_TAG).la + +AM_CPPFLAGS = -I$(top_srcdir)/include $(INCLTDL) $(JAVAINCCMD) + +nodist_xtractjavac_wrap_la_SOURCES = xtractjavac_wrap.c + +xtractjavac_wrap_la_LDFLAGS = \ + -rpath $(execjavawrapperdir) \ + -module \ + -avoid-version \ + -no-undefined \ + $(libxtract) + +.java.class: + $(JAVAC) $(AM_JAVACFLAGS) $(JAVACFLAGS) $(swigjavafiles) -d . -classpath . + cp xtract/core/$@ . + +noinst_DATA = jar-stamp +# +jar-stamp: $(javaclasses) $(javafiles) + $(mkdir_p) xtract/core + $(mkdir_p) xtract/core/src + cp $(javafiles) xtract/core/src + touch jar-stamp +# +execjavawrapper_LTLIBRARIES = xtractjavac_wrap.la + +install-exec-hook: + ( cd $(DESTDIR)$(execjavawrapperdir) ; \ + rm -f *.a *.la ) + +clean-local: + rm -rf xtract + +CLEANFILES = $(javaclasses) jar-stamp + +MAINTAINERCLEANFILES = $(swiggenfiles) Makefile.in Added: trunk/swig/java/test.java =================================================================== --- trunk/swig/java/test.java (rev 0) +++ trunk/swig/java/test.java 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,23 @@ + +import xtract.core.*; + +public class test { + public static void main(String argv[]) { +// System.loadLibrary("xtract"); + + int len = 5; + int retval = 0; + float result[]; + floatArray a = new floatArray(len); + SWIGTYPE_p_void myvoid = null; + + result = new float[1]; + + for (int i = 0; i < len; i++) + a.setitem(i, i * 2); + + retval = xtract.xtract_mean(a.cast(), len, myvoid, result); + + System.out.println(result); + } +} Copied: trunk/swig/python/Makefile.am (from rev 90, trunk/swig/Makefile.am) =================================================================== --- trunk/swig/python/Makefile.am (rev 0) +++ trunk/swig/python/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,18 @@ +MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so + +BUILT_SOURCES = $(srcdir)/xtract_wrap.c +SWIG_SOURCES = ../xtract.i + +pkgpython_PYTHON = xtract.py +pkgpyexec_LTLIBRARIES = _xtract.la +_xtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) +_xtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src +_xtract_la_LDFLAGS = -module -lxtract +_xtract_la_LIBADD = $(top_srcdir)/src/libxtract.la + +xtract_wrap.c : $(SWIG_SOURCES) + $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $< + +clean-local: + -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc + Copied: trunk/swig/python/test.py (from rev 90, trunk/swig/test.py) =================================================================== --- trunk/swig/python/test.py (rev 0) +++ trunk/swig/python/test.py 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,15 @@ +#!/usr/bin/python + +import xtract + +len = 5 + +a = xtract.floatArray(len) + +for i in range(0, len): + a[i] = 2 * i + +retval,result = xtract.xtract_mean(a,len,None) + +print result + Copied: trunk/swig/python/xtract.i (from rev 90, trunk/swig/xtract.i) =================================================================== --- trunk/swig/python/xtract.i (rev 0) +++ trunk/swig/python/xtract.i 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,12 @@ +%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" Deleted: trunk/swig/test.py =================================================================== --- trunk/swig/test.py 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/swig/test.py 2007-09-05 14:32:17 UTC (rev 91) @@ -1,18 +0,0 @@ -#!/usr/bin/python - -import xtract - -len = 5 - -a = xtract.new_floatArray(len) - -for i in range(0, len): - xtract.floatArray_setitem(a, i, 2*i) - -retval,result = xtract.xtract_mean(a,len,None) - -print result - - - - Deleted: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/swig/xtract.i 2007-09-05 14:32:17 UTC (rev 91) @@ -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" Added: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i (rev 0) +++ trunk/swig/xtract.i 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,13 @@ +%module xtract +%include carrays.i +%include typemaps.i + +%{ +#include "xtract/xtract_scalar.h" +%} + +%array_class(float, floatArray); +%apply float *OUTPUT { float *result }; +/* %apply float *INPUT { float *data }; */ + +%include "xtract/xtract_scalar.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-05 14:50:55
|
Revision: 92 http://libxtract.svn.sourceforge.net/libxtract/?rev=92&view=rev Author: postlude Date: 2007-09-05 07:50:37 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Added m4 macros Added Paths: ----------- trunk/m4/ trunk/m4/ac_jni_include_dir.m4 trunk/m4/ac_pkg_swig.m4 trunk/m4/ac_prog_javac.m4 trunk/m4/ac_prog_javac_works.m4 trunk/m4/ac_python_devel.m4 trunk/m4/swig_multi_module_support.m4 trunk/m4/swig_python.m4 Added: trunk/m4/ac_jni_include_dir.m4 =================================================================== --- trunk/m4/ac_jni_include_dir.m4 (rev 0) +++ trunk/m4/ac_jni_include_dir.m4 2007-09-05 14:50:37 UTC (rev 92) @@ -0,0 +1,112 @@ +##### http://autoconf-archive.cryp.to/ac_jni_include_dir.html +# +# SYNOPSIS +# +# AC_JNI_INCLUDE_DIR +# +# DESCRIPTION +# +# AC_JNI_INCLUDE_DIR finds include directories needed for compiling +# programs using the JNI interface. +# +# JNI include directories are usually in the java distribution This +# is deduced from the value of JAVAC. When this macro completes, a +# list of directories is left in the variable JNI_INCLUDE_DIRS. +# +# Example usage follows: +# +# AC_JNI_INCLUDE_DIR +# +# for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS +# do +# CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR" +# done +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVAC=yourcompiler before calling +# AC_JNI_INCLUDE_DIR +# +# - at the configure level, setenv JAVAC +# +# Note: This macro can work with the autoconf M4 macros for Java +# programs. This particular macro is not part of the original set of +# macros. +# +# LAST MODIFICATION +# +# 2006-05-27 +# +# COPYLEFT +# +# Copyright (c) 2006 Don Anderson <dd...@sl...> +# +# Copying and distribution of this file, with or without +# modification, are permitted in any medium without royalty provided +# the copyright notice and this notice are preserved. + +AC_DEFUN([AC_JNI_INCLUDE_DIR],[ + +JNI_INCLUDE_DIRS="" + +test "x$JAVAC" = x && AC_MSG_ERROR(['\$JAVAC' undefined]) +AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, no) +test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path]) + +_ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC") +_JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` +case "$host_os" in + darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` + _JINC="$_JTOPDIR/Headers";; + *) _JINC="$_JTOPDIR/include";; +esac +if test -f "$_JINC/jni.h"; then + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC" +else + _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` + if test -f "$_JTOPDIR/include/jni.h"; then + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include" + else + AC_MSG_ERROR([cannot find java include files]) + fi +fi + +# get the likely subdirectories for system specific java includes +case "$host_os" in +bsdi*) _JNI_INC_SUBDIRS="bsdos";; +linux*) _JNI_INC_SUBDIRS="linux genunix";; +osf*) _JNI_INC_SUBDIRS="alpha";; +solaris*) _JNI_INC_SUBDIRS="solaris";; +mingw*) _JNI_INC_SUBDIRS="win32";; +cygwin*) _JNI_INC_SUBDIRS="win32";; +*) _JNI_INC_SUBDIRS="genunix";; +esac + +# add any subdirectories that are present +for JINCSUBDIR in $_JNI_INC_SUBDIRS +do + if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR" + fi +done +]) + +# _ACJNI_FOLLOW_SYMLINKS <path> +# Follows symbolic links on <path>, +# finally setting variable _ACJNI_FOLLOWED +# -------------------- +AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[ +# find the include directory relative to the javac executable +_cur="$1" +while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do + AC_MSG_CHECKING(symlink for $_cur) + _slink=`ls -ld "$_cur" | sed 's/.* -> //'` + case "$_slink" in + /*) _cur="$_slink";; + # 'X' avoids triggering unwanted echo options. + *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; + esac + AC_MSG_RESULT($_cur) +done +_ACJNI_FOLLOWED="$_cur" +])# _ACJNI Added: trunk/m4/ac_pkg_swig.m4 =================================================================== --- trunk/m4/ac_pkg_swig.m4 (rev 0) +++ trunk/m4/ac_pkg_swig.m4 2007-09-05 14:50:37 UTC (rev 92) @@ -0,0 +1,125 @@ +##### http://autoconf-archive.cryp.to/ac_pkg_swig.html +# +# SYNOPSIS +# +# AC_PROG_SWIG([major.minor.micro]) +# +# DESCRIPTION +# +# This macro searches for a SWIG installation on your system. If +# found you should call SWIG via $(SWIG). You can use the optional +# first argument to check if the version of the available SWIG is +# greater than or equal to the value of the argument. It should have +# the format: N[.N[.N]] (N is a number between 0 and 999. Only the +# first N is mandatory.) +# +# If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks +# that the swig package is this version number or higher. +# +# In configure.in, use as: +# +# AC_PROG_SWIG(1.3.17) +# SWIG_ENABLE_CXX +# SWIG_MULTI_MODULE_SUPPORT +# SWIG_PYTHON +# +# LAST MODIFICATION +# +# 2006-10-22 +# +# COPYLEFT +# +# Copyright (c) 2006 Sebastian Huber <seb...@we...> +# Copyright (c) 2006 Alan W. Irwin <ir...@be...> +# Copyright (c) 2006 Rafael Laboissiere <ra...@la...> +# Copyright (c) 2006 Andrew Collier <col...@uk...> +# +# 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# As a special exception, the respective Autoconf Macro's copyright +# owner gives unlimited permission to copy, distribute and modify the +# configure scripts that are the output of Autoconf when processing +# the Macro. You need not follow the terms of the GNU General Public +# License when using or distributing such scripts, even though +# portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the +# Autoconf Macro released by the Autoconf Macro Archive. When you +# make and distribute a modified version of the Autoconf Macro, you +# may extend this special exception to the GPL to apply to your +# modified version as well. + +AC_DEFUN([AC_PROG_SWIG],[ + AC_PATH_PROG([SWIG],[swig]) + if test -z "$SWIG" ; then + AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false' + elif test -n "$1" ; then + AC_MSG_CHECKING([for SWIG version]) + [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + AC_MSG_RESULT([$swig_version]) + if test -n "$swig_version" ; then + # Calculate the required version number components + [required=$1] + [required_major=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_major" ; then + [required_major=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_minor=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_minor" ; then + [required_minor=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_patch=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_patch" ; then + [required_patch=0] + fi + # Calculate the available version number components + [available=$swig_version] + [available_major=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_major" ; then + [available_major=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_minor=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_minor" ; then + [available_minor=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_patch=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_patch" ; then + [available_patch=0] + fi + if test $available_major -ne $required_major \ + -o $available_minor -ne $required_minor \ + -o $available_patch -lt $required_patch ; then + AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false' + else + AC_MSG_NOTICE([SWIG executable is '$SWIG']) + SWIG_LIB=`$SWIG -swiglib` + AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB']) + fi + else + AC_MSG_WARN([cannot determine SWIG version]) + SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false' + fi + fi + AC_SUBST([SWIG_LIB]) +]) Added: trunk/m4/ac_prog_javac.m4 =================================================================== --- trunk/m4/ac_prog_javac.m4 (rev 0) +++ trunk/m4/ac_prog_javac.m4 2007-09-05 14:50:37 UTC (rev 92) @@ -0,0 +1,84 @@ +##### http://autoconf-archive.cryp.to/ac_prog_javac.html +# +# SYNOPSIS +# +# AC_PROG_JAVAC +# +# DESCRIPTION +# +# AC_PROG_JAVAC tests an existing Java compiler. It uses the +# environment variable JAVAC then tests in sequence various common +# Java compilers. For political reasons, it starts with the free +# ones. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVAC=yourcompiler before calling +# AC_PROG_JAVAC +# +# - at the configure level, setenv JAVAC +# +# You can use the JAVAC variable in your Makefile.in, with @JAVAC@. +# +# *Warning*: its success or failure can depend on a proper setting of +# the CLASSPATH env. variable. +# +# TODO: allow to exclude compilers (rationale: most Java programs +# cannot compile with some compilers like guavac). +# +# Note: This is part of the set of autoconf M4 macros for Java +# programs. It is VERY IMPORTANT that you download the whole set, +# some macros depend on other. Unfortunately, the autoconf archive +# does not support the concept of set of macros, so I had to break it +# for submission. The general documentation, as well as the sample +# configure.in, is included in the AC_PROG_JAVA macro. +# +# LAST MODIFICATION +# +# 2000-07-19 +# +# COPYLEFT +# +# Copyright (c) 2000 Stephane Bortzmeyer <bor...@pa...> +# +# 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# As a special exception, the respective Autoconf Macro's copyright +# owner gives unlimited permission to copy, distribute and modify the +# configure scripts that are the output of Autoconf when processing +# the Macro. You need not follow the terms of the GNU General Public +# License when using or distributing such scripts, even though +# portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the +# Autoconf Macro released by the Autoconf Macro Archive. When you +# make and distribute a modified version of the Autoconf Macro, you +# may extend this special exception to the GPL to apply to your +# modified version as well. + +AC_DEFUN([AC_PROG_JAVAC],[ +AC_REQUIRE([AC_EXEEXT])dnl +if test "x$JAVAPREFIX" = x; then + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT) +else + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT, $JAVAPREFIX) +fi +test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) +AC_PROG_JAVAC_WORKS +AC_PROVIDE([$0])dnl +]) Added: trunk/m4/ac_prog_javac_works.m4 =================================================================== --- trunk/m4/ac_prog_javac_works.m4 (rev 0) +++ trunk/m4/ac_prog_javac_works.m4 2007-09-05 14:50:37 UTC (rev 92) @@ -0,0 +1,75 @@ +##### http://autoconf-archive.cryp.to/ac_prog_javac_works.html +# +# SYNOPSIS +# +# AC_PROG_JAVAC_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java +# programs. It is VERY IMPORTANT that you download the whole set, +# some macros depend on other. Unfortunately, the autoconf archive +# does not support the concept of set of macros, so I had to break it +# for submission. The general documentation, as well as the sample +# configure.in, is included in the AC_PROG_JAVA macro. +# +# LAST MODIFICATION +# +# 2000-07-19 +# +# COPYLEFT +# +# Copyright (c) 2000 Stephane Bortzmeyer <bor...@pa...> +# +# 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# As a special exception, the respective Autoconf Macro's copyright +# owner gives unlimited permission to copy, distribute and modify the +# configure scripts that are the output of Autoconf when processing +# the Macro. You need not follow the terms of the GNU General Public +# License when using or distributing such scripts, even though +# portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the +# Autoconf Macro released by the Autoconf Macro Archive. When you +# make and distribute a modified version of the Autoconf Macro, you +# may extend this special exception to the GPL to apply to your +# modified version as well. + +AC_DEFUN([AC_PROG_JAVAC_WORKS],[ +AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then + ac_cv_prog_javac_works=yes +else + AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) + echo "configure: failed program was:" >&AC_FD_CC + cat $JAVA_TEST >&AC_FD_CC +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +]) Added: trunk/m4/ac_python_devel.m4 =================================================================== --- trunk/m4/ac_python_devel.m4 (rev 0) +++ trunk/m4/ac_python_devel.m4 2007-09-05 14:50:37 UTC (rev 92) @@ -0,0 +1,269 @@ +##### http://autoconf-archive.cryp.to/ac_python_devel.html +# +# SYNOPSIS +# +# AC_PYTHON_DEVEL([version]) +# +# DESCRIPTION +# +# Note: Defines as a precious variable "PYTHON_VERSION". Don't +# override it in your configure.ac. +# +# This macro checks for Python and tries to get the include path to +# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and +# $(PYTHON_LDFLAGS) output variables. It also exports +# $(PYTHON_EXTRA_LIBS) and $(PYTHON_EXTRA_LDFLAGS) for embedding +# Python in your code. +# +# You can search for some particular version of Python by passing a +# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". +# Please note that you *have* to pass also an operator along with the +# version to match, and pay special attention to the single quotes +# surrounding the version number. Don't use "PYTHON_VERSION" for +# this: that environment variable is declared as precious and thus +# reserved for the end-user. +# +# This macro should work for all versions of Python >= 2.1.0. As an +# end user, you can disable the check for the python version by +# setting the PYTHON_NOVERSIONCHECK environment variable to something +# else than the empty string. +# +# If you need to use this macro for an older Python version, please +# contact the authors. We're always open for feedback. +# +# LAST MODIFICATION +# +# 2006-10-22 +# +# COPYLEFT +# +# Copyright (c) 2006 Sebastian Huber <seb...@we...> +# Copyright (c) 2006 Alan W. Irwin <ir...@be...> +# Copyright (c) 2006 Rafael Laboissiere <ra...@la...> +# Copyright (c) 2006 Andrew Collier <col...@uk...> +# Copyright (c) 2006 Matteo Settenvini <ma...@me...> +# Copyright (c) 2006 Horst Knorr <hk_...@kn...> +# +# 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# As a special exception, the respective Autoconf Macro's copyright +# owner gives unlimited permission to copy, distribute and modify the +# configure scripts that are the output of Autoconf when processing +# the Macro. You need not follow the terms of the GNU General Public +# License when using or distributing such scripts, even though +# portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the +# Autoconf Macro released by the Autoconf Macro Archive. When you +# make and distribute a modified version of the Autoconf Macro, you +# may extend this special exception to the GPL to apply to your +# modified version as well. + +AC_DEFUN([AC_PYTHON_DEVEL],[ + # + # Allow the use of a (user set) custom python version + # + AC_ARG_VAR([PYTHON_VERSION],[The installed Python + version to use, for example '2.3'. This string + will be appended to the Python interpreter + canonical name.]) + + AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) + if test -z "$PYTHON"; then + AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) + PYTHON_VERSION="" + fi + + # + # Check for a version of Python >= 2.1.0 + # + AC_MSG_CHECKING([for a version of Python >= '2.1.0']) + ac_supports_python_ver=`$PYTHON -c "import sys, string; \ + ver = string.split(sys.version)[[0]]; \ + print ver >= '2.1.0'"` + if test "$ac_supports_python_ver" != "True"; then + if test -z "$PYTHON_NOVERSIONCHECK"; then + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([ +This version of the AC@&t@_PYTHON_DEVEL macro +doesn't work properly with versions of Python before +2.1.0. You may need to re-run configure, setting the +variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, +PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. +Moreover, to disable this check, set PYTHON_NOVERSIONCHECK +to something else than an empty string. +]) + else + AC_MSG_RESULT([skip at user request]) + fi + else + AC_MSG_RESULT([yes]) + fi + + # + # if the macro parameter ``version'' is set, honour it + # + if test -n "$1"; then + AC_MSG_CHECKING([for a version of Python $1]) + ac_supports_python_ver=`$PYTHON -c "import sys, string; \ + ver = string.split(sys.version)[[0]]; \ + print ver $1"` + if test "$ac_supports_python_ver" = "True"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([this package requires Python $1. +If you have it installed, but it isn't the default Python +interpreter in your system path, please pass the PYTHON_VERSION +variable to configure. See ``configure --help'' for reference. +]) + PYTHON_VERSION="" + fi + fi + + # + # Check if you have distutils, else fail + # + AC_MSG_CHECKING([for the distutils Python package]) + ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` + if test -z "$ac_distutils_result"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot import Python module "distutils". +Please check your Python installation. The error was: +$ac_distutils_result]) + PYTHON_VERSION="" + fi + + # + # Check for Python include path + # + AC_MSG_CHECKING([for Python include path]) + if test -z "$PYTHON_CPPFLAGS"; then + python_path=`$PYTHON -c "import distutils.sysconfig; \ + print distutils.sysconfig.get_python_inc();"` + if test -n "${python_path}"; then + python_path="-I$python_path" + fi + PYTHON_CPPFLAGS=$python_path + fi + AC_MSG_RESULT([$PYTHON_CPPFLAGS]) + AC_SUBST([PYTHON_CPPFLAGS]) + + # + # Check for Python library path + # + AC_MSG_CHECKING([for Python library path]) + if test -z "$PYTHON_LDFLAGS"; then + # (makes two attempts to ensure we've got a version number + # from the interpreter) + py_version=`$PYTHON -c "from distutils.sysconfig import *; \ + from string import join; \ + print join(get_config_vars('VERSION'))"` + if test "$py_version" == "[None]"; then + if test -n "$PYTHON_VERSION"; then + py_version=$PYTHON_VERSION + else + py_version=`$PYTHON -c "import sys; \ + print sys.version[[:3]]"` + fi + fi + + PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \ + from string import join; \ + print '-L' + get_python_lib(0,1), \ + '-lpython';"`$py_version + fi + AC_MSG_RESULT([$PYTHON_LDFLAGS]) + AC_SUBST([PYTHON_LDFLAGS]) + + # + # Check for site packages + # + AC_MSG_CHECKING([for Python site-packages path]) + if test -z "$PYTHON_SITE_PKG"; then + PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ + print distutils.sysconfig.get_python_lib(0,0);"` + fi + AC_MSG_RESULT([$PYTHON_SITE_PKG]) + AC_SUBST([PYTHON_SITE_PKG]) + + # + # libraries which must be linked in when embedding + # + AC_MSG_CHECKING(python extra libraries) + if test -z "$PYTHON_EXTRA_LIBS"; then + PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ + conf = distutils.sysconfig.get_config_var; \ + print conf('LOCALMODLIBS'), conf('LIBS')"` + fi + AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) + AC_SUBST(PYTHON_EXTRA_LIBS) + + # + # linking flags needed when embedding + # + AC_MSG_CHECKING(python extra linking flags) + if test -z "$PYTHON_EXTRA_LDFLAGS"; then + PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ + conf = distutils.sysconfig.get_config_var; \ + print conf('LINKFORSHARED')"` + fi + AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) + AC_SUBST(PYTHON_EXTRA_LDFLAGS) + + # + # final check to see if everything compiles alright + # + AC_MSG_CHECKING([consistency of all components of python development environment]) + AC_LANG_PUSH([C]) + # save current global flags + LIBS="$ac_save_LIBS $PYTHON_LDFLAGS" + CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" + AC_TRY_LINK([ + #include <Python.h> + ],[ + Py_Initialize(); + ],[pythonexists=yes],[pythonexists=no]) + + AC_MSG_RESULT([$pythonexists]) + + if test ! "$pythonexists" = "yes"; then + AC_MSG_ERROR([ + Could not link test program to Python. Maybe the main Python library has been + installed in some non-standard library path. If so, pass it to configure, + via the LDFLAGS environment variable. + Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" + ============================================================================ + ERROR! + You probably have to install the development version of the Python package + for your distribution. The exact name of this package varies among them. + ============================================================================ + ]) + PYTHON_VERSION="" + fi + AC_LANG_POP + # turn back to default flags + CPPFLAGS="$ac_save_CPPFLAGS" + LIBS="$ac_save_LIBS" + + # + # all done! + # +]) Added: trunk/m4/swig_multi_module_support.m4 =================================================================== --- trunk/m4/swig_multi_module_support.m4 (rev 0) +++ trunk/m4/swig_multi_module_support.m4 2007-09-05 14:50:37 UTC (rev 92) @@ -0,0 +1,59 @@ +##### http://autoconf-archive.cryp.to/swig_multi_module_support.html +# +# SYNOPSIS +# +# SWIG_MULTI_MODULE_SUPPORT +# +# DESCRIPTION +# +# Enable support for multiple modules. This effects all invocations +# of $(SWIG). You have to link all generated modules against the +# appropriate SWIG runtime library. If you want to build Python +# modules for example, use the SWIG_PYTHON macro and link the modules +# against $(SWIG_PYTHON_LIBS). +# +# LAST MODIFICATION +# +# 2006-10-22 +# +# COPYLEFT +# +# Copyright (c) 2006 Sebastian Huber <seb...@we...> +# Copyright (c) 2006 Alan W. Irwin <ir...@be...> +# Copyright (c) 2006 Rafael Laboissiere <ra...@la...> +# Copyright (c) 2006 Andrew Collier <col...@uk...> +# +# 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# As a special exception, the respective Autoconf Macro's copyright +# owner gives unlimited permission to copy, distribute and modify the +# configure scripts that are the output of Autoconf when processing +# the Macro. You need not follow the terms of the GNU General Public +# License when using or distributing such scripts, even though +# portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the +# Autoconf Macro released by the Autoconf Macro Archive. When you +# make and distribute a modified version of the Autoconf Macro, you +# may extend this special exception to the GPL to apply to your +# modified version as well. + +AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[ + AC_REQUIRE([AC_PROG_SWIG]) + SWIG="$SWIG -noruntime" +]) Added: trunk/m4/swig_python.m4 =================================================================== --- trunk/m4/swig_python.m4 (rev 0) +++ trunk/m4/swig_python.m4 2007-09-05 14:50:37 UTC (rev 92) @@ -0,0 +1,67 @@ +##### http://autoconf-archive.cryp.to/swig_python.html +# +# SYNOPSIS +# +# SWIG_PYTHON([use-shadow-classes = {no, yes}]) +# +# DESCRIPTION +# +# Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS), and +# $(SWIG_PYTHON_OPT) output variables. +# +# $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate +# code for Python. Shadow classes are enabled unless the value of the +# optional first argument is exactly 'no'. If you need multi module +# support (provided by the SWIG_MULTI_MODULE_SUPPORT macro) use +# $(SWIG_PYTHON_LIBS) to link against the appropriate library. It +# contains the SWIG Python runtime library that is needed by the type +# check system for example. +# +# LAST MODIFICATION +# +# 2006-10-22 +# +# COPYLEFT +# +# Copyright (c) 2006 Sebastian Huber <seb...@we...> +# Copyright (c) 2006 Alan W. Irwin <ir...@be...> +# Copyright (c) 2006 Rafael Laboissiere <ra...@la...> +# Copyright (c) 2006 Andrew Collier <col...@uk...> +# +# 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# As a special exception, the respective Autoconf Macro's copyright +# owner gives unlimited permission to copy, distribute and modify the +# configure scripts that are the output of Autoconf when processing +# the Macro. You need not follow the terms of the GNU General Public +# License when using or distributing such scripts, even though +# portions of the text of the Macro appear in them. The GNU General +# Public License (GPL) does govern all other use of the material that +# constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the +# Autoconf Macro released by the Autoconf Macro Archive. When you +# make and distribute a modified version of the Autoconf Macro, you +# may extend this special exception to the GPL to apply to your +# modified version as well. + +AC_DEFUN([SWIG_PYTHON],[ + AC_REQUIRE([AC_PROG_SWIG]) + AC_REQUIRE([AC_PYTHON_DEVEL]) + test "x$1" != "xno" || swig_shadow=" -noproxy" + AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow]) + AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS]) +]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-05 17:44:31
|
Revision: 93 http://libxtract.svn.sourceforge.net/libxtract/?rev=93&view=rev Author: postlude Date: 2007-09-05 10:44:23 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Updated README and minor buld tweaks for OS X (That will probably break the Linux build (sigh)). Modified Paths: -------------- trunk/README trunk/configure.in trunk/swig/java/Makefile.am trunk/swig/java/test.java Modified: trunk/README =================================================================== --- trunk/README 2007-09-05 14:50:37 UTC (rev 92) +++ trunk/README 2007-09-05 17:44:23 UTC (rev 93) @@ -36,6 +36,54 @@ --enable-fft (to enable functions that require fftw3) --enable-simpletest (to build the simpletest example) +Building the Python bindings +---------------------------- + +To build the python bindings, add to your configure flags: + +--enable-swig --with-python + +This requres additional dependencies to be resolved: + +swig >= 1.3 +python (with development files) >= 2.5 + +It might work with earlier versions of Python, but this has not been tested. + +If you do not have the 'standard' version of Python on OS X, you might need to tell the configure script where the python library is e.g.: + +./configure --your-flags LDFLAGS="-L/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/" + +to find your Python library type: + +locate libpython + +Building the Java bindings +-------------------------- + +To build the java bindings, add to your configure flags: + +--enable-swig --with-java + +This requres additional dependencies to be resolved: + +swig >= 1.3 +java (with development files) >= 2.0 + +It might work with other versions of Java, but this has not been tested. + +On OS X, you will probably need to set your CLASSPATH environment variable before running ./configure + +export CLASSPATH=/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar + +On OS X, you also probably need to tell the configure script where to find your Java (JNI) headers. + +./configure --flags CFLAGS="-I/System/Library/Frameworks/JavaVM.framework/Headers" + +To find out where your headers are: + +locate jni.h + Disclaimer ---------- Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-05 14:50:37 UTC (rev 92) +++ trunk/configure.in 2007-09-05 17:44:23 UTC (rev 93) @@ -98,22 +98,7 @@ AM_CONDITIONAL(BUILD_PYTHON, test "x${with_python}" = 'xtrue') -dnl Are we building with fftw? -if [[ "$fft" = "true" ]] ; then - LDFLAGS="$LDFLAGS -lfftw3f" - AC_DEFINE([BUILD_FFT], [1], [Build the fft functions]) - AC_CHECK_HEADER(fftw3.h, [have_fftw3_hdr=yes ], [ - have_pd_hdr=no - echo - echo "no fftw3.h header found. try with option --with-fftw3-dir=/path/to/fftw3/header" - echo - exit - ]) -fi -AM_CONDITIONAL(BUILD_FFT, test "x${fft}" = 'xtrue') - - dnl are we building the simpletest example if [[ "$simpletest" = "true" ]] ; then AC_DEFINE([BUILD_SIMPLETEST], [1], [Build the simpletest example]) @@ -166,12 +151,16 @@ if [[ "$with_java" = "true" ]] ; then AC_PROG_JAVAC - AC_JNI_INCLUDE_DIR + if test "$JAVAC" = "javac" + then + AC_JNI_INCLUDE_DIR + - for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS - do - CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" - done + for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS + do + CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" + done + fi dnl AC_PROG_JAVAH dnl AC_PATH_PROG(JAVAH,javah) fi @@ -184,6 +173,22 @@ AM_CONDITIONAL(BUILD_SWIG, test "x${swig}" = 'xtrue') +dnl Are we building with fftw? +if [[ "$fft" = "true" ]] ; then + LDFLAGS="$LDFLAGS -lfftw3f" + AC_DEFINE([BUILD_FFT], [1], [Build the fft functions]) + AC_CHECK_HEADER(fftw3.h, [have_fftw3_hdr=yes ], [ + have_pd_hdr=no + echo + echo "no fftw3.h header found. try with option --with-fftw3-dir=/path/to/fftw3/header" + echo + exit + ]) +fi + +AM_CONDITIONAL(BUILD_FFT, test "x${fft}" = 'xtrue') + + dnl ------------------------------------------ dnl ---- do some magic to gues the host opsys dnl ---- taken from libvorbis configure.in Modified: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am 2007-09-05 14:50:37 UTC (rev 92) +++ trunk/swig/java/Makefile.am 2007-09-05 17:44:23 UTC (rev 93) @@ -44,15 +44,15 @@ $(libxtract) .java.class: - $(JAVAC) $(AM_JAVACFLAGS) $(JAVACFLAGS) $(swigjavafiles) -d . -classpath . - cp xtract/core/$@ . + $(JAVAC) $(AM_JAVACFLAGS) $(JAVACFLAGS) $(swigjavafiles) noinst_DATA = jar-stamp # jar-stamp: $(javaclasses) $(javafiles) - $(mkdir_p) xtract/core - $(mkdir_p) xtract/core/src + mkdir -p xtract/core + mkdir -p xtract/core/src cp $(javafiles) xtract/core/src + cp $(javaclasses) xtract/core touch jar-stamp # execjavawrapper_LTLIBRARIES = xtractjavac_wrap.la Modified: trunk/swig/java/test.java =================================================================== --- trunk/swig/java/test.java 2007-09-05 14:50:37 UTC (rev 92) +++ trunk/swig/java/test.java 2007-09-05 17:44:23 UTC (rev 93) @@ -1,5 +1,5 @@ -import xtract.core.*; +import jxtract.core.*; public class test { public static void main(String argv[]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-06 14:05:48
|
Revision: 95 http://libxtract.svn.sourceforge.net/libxtract/?rev=95&view=rev Author: postlude Date: 2007-09-06 07:05:37 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Java bindings (with simple test) now working. Unified Python and Java bindings tests. Modified Paths: -------------- trunk/configure.in trunk/src/scalar.c trunk/swig/java/Makefile.am trunk/swig/java/test.java trunk/swig/python/test.py trunk/xtract/xtract_scalar.h Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/configure.in 2007-09-06 14:05:37 UTC (rev 95) @@ -85,6 +85,15 @@ echo ]) +dnl set a specific java compiler +AC_ARG_WITH(javac, + [ --with-javac=compiler set a specific java compiler (determined automatically if not set) ], + [JAVAC="$withval" + echo + echo "JAVAC is set to $withval" + echo + ]) + dnl If --enable-swig, make with java bindings AC_ARG_WITH(java, [ --with-java If --enable-swig - make with java bindings (default=no) ], @@ -150,12 +159,14 @@ fi if [[ "$with_java" = "true" ]] ; then - AC_PROG_JAVAC + if test "$JAVAC" = "" + then + AC_PROG_JAVAC + fi if test "$JAVAC" = "javac" then AC_JNI_INCLUDE_DIR - for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS do CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/src/scalar.c 2007-09-06 14:05:37 UTC (rev 95) @@ -36,7 +36,7 @@ #define expf exp #endif -int test(void){ +void test(void){ printf("Hello world"); } Modified: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/swig/java/Makefile.am 2007-09-06 14:05:37 UTC (rev 95) @@ -1,22 +1,10 @@ -SWIG_JAVA_DIR = $(top_srcdir)/swig/java - -SWIG_CMD = $(SWIG) -I$(SWIG_JAVA_DIR) -I$(top_srcdir) -java - -swigjavafiles = \ +javasources = \ xtractJNI.java \ xtract.java \ floatArray.java \ SWIGTYPE_p_float.java \ SWIGTYPE_p_void.java -swigcfiles = xtractjavac_wrap.c - -swiggenfiles = $(swigjavafiles) $(swigcfiles) - -javafiles = $(swigjavafiles) - -# Note : the order of these is important since there is no formal -# dependency checking. javaclasses = \ xtractJNI.class \ xtract.class \ @@ -24,46 +12,29 @@ SWIGTYPE_p_float.class \ SWIGTYPE_p_void.class -$(swiggenfiles): ../xtract.i - $(SWIG_CMD) -package xtract.core -o xtractjavac_wrap.c ../xtract.i +MAINTAINERCLEANFILES = $(javasources) Makefile.in -# Must have "exec" in the name. -execjavawrapperdir = ${libdir} +BUILT_SOURCES = $(srcdir)/xtract_wrap.c +SWIG_SOURCES = ../xtract.i -libxtract = $(top_builddir)/src/libxtract$(LIB_TAG).la +lib_LTLIBRARIES = libjxtract.la +libjxtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) +libjxtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src +ibjxtract_la_LDFLAGS = -module -lxtract +libjxtract_la_LIBADD = $(top_srcdir)/src/libxtract.la -AM_CPPFLAGS = -I$(top_srcdir)/include $(INCLTDL) $(JAVAINCCMD) +SWIG_JAVA_OPT = -java -package xtract.core -nodist_xtractjavac_wrap_la_SOURCES = xtractjavac_wrap.c - -xtractjavac_wrap_la_LDFLAGS = \ - -rpath $(execjavawrapperdir) \ - -module \ - -avoid-version \ - -no-undefined \ - $(libxtract) - -.java.class: - $(JAVAC) $(AM_JAVACFLAGS) $(JAVACFLAGS) $(swigjavafiles) - -noinst_DATA = jar-stamp -# -jar-stamp: $(javaclasses) $(javafiles) +xtract_wrap.c : $(SWIG_SOURCES) + $(SWIG) $(SWIG_JAVA_OPT) -I$(top_srcdir) -o $@ $< + $(JAVAC) $(javasources) mkdir -p xtract/core mkdir -p xtract/core/src - cp $(javafiles) xtract/core/src - cp $(javaclasses) xtract/core - touch jar-stamp -# -execjavawrapper_LTLIBRARIES = xtractjavac_wrap.la + mv $(javasources) xtract/core/src + mv $(javaclasses) xtract/core + $(JAVAC) test.java -install-exec-hook: - ( cd $(DESTDIR)$(execjavawrapperdir) ; \ - rm -f *.a *.la ) - clean-local: - rm -rf xtract + -rm -f libjxtract.so xtract_wrap.c $(javasources) $(javaclasses) test.class + -rm -rf xtract -CLEANFILES = $(javaclasses) jar-stamp - -MAINTAINERCLEANFILES = $(swiggenfiles) Makefile.in Modified: trunk/swig/java/test.java =================================================================== --- trunk/swig/java/test.java 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/swig/java/test.java 2007-09-06 14:05:37 UTC (rev 95) @@ -3,8 +3,17 @@ public class test { public static void main(String argv[]) { -// System.loadLibrary("xtract"); + try { + System.loadLibrary("jxtract"); + } + catch (UnsatisfiedLinkError e) { + System.out.println("Failed to load the library \"jxtract\""); + System.out.println(e.toString()); + } + + System.out.println("\nRunning libxtract Java bindings test...\n"); + int len = 5; int retval = 0; float result[]; @@ -13,11 +22,20 @@ result = new float[1]; - for (int i = 0; i < len; i++) + System.out.print("The mean of: "); + + for (int i = 0; i < len; i++){ + System.out.print(i * 2 + ", "); a.setitem(i, i * 2); + } + System.out.print("is: "); + retval = xtract.xtract_mean(a.cast(), len, myvoid, result); - System.out.println(result); + System.out.print(result[0] + "\n"); + + System.out.println("\nFinished!\n\n"); + } } Modified: trunk/swig/python/test.py =================================================================== --- trunk/swig/python/test.py 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/swig/python/test.py 2007-09-06 14:05:37 UTC (rev 95) @@ -1,15 +1,22 @@ #!/usr/bin/python -import xtract +try: + import xtract +except ImportError: + print 'Failed to load the library "jxtract"' +print '\nRunning libxtract Python bindings test...\n' + len = 5 a = xtract.floatArray(len) +temp = [] for i in range(0, len): a[i] = 2 * i + temp.append(str(a[i])) -retval,result = xtract.xtract_mean(a,len,None) +print 'The mean of ' + ', '.join(temp) + ' is: %.2f' % \ + xtract.xtract_mean(a,len,None)[1] -print result - +print '\nFinished!\n' Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/xtract/xtract_scalar.h 2007-09-06 14:05:37 UTC (rev 95) @@ -34,6 +34,8 @@ * @{ */ +void test(void); + /** \brief Extract the mean of an input vector * * \param *data: a pointer to the first element This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-09-24 08:23:28
|
Revision: 96 http://libxtract.svn.sourceforge.net/libxtract/?rev=96&view=rev Author: postlude Date: 2007-09-24 01:23:26 -0700 (Mon, 24 Sep 2007) Log Message: ----------- Made xtract_loudness() more permissive, so it doesn't crash if N > BARK_BANDS Modified Paths: -------------- trunk/src/scalar.c trunk/swig/java/Makefile.am Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-09-06 14:05:37 UTC (rev 95) +++ trunk/src/scalar.c 2007-09-24 08:23:26 UTC (rev 96) @@ -419,8 +419,10 @@ int n = N, rv; - if(n > XTRACT_BARK_BANDS) + if(n > XTRACT_BARK_BANDS){ + n = XTRACT_BARK_BANDS; rv = XTRACT_BAD_VECTOR_SIZE; + } else rv = XTRACT_SUCCESS; Modified: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am 2007-09-06 14:05:37 UTC (rev 95) +++ trunk/swig/java/Makefile.am 2007-09-24 08:23:26 UTC (rev 96) @@ -20,7 +20,7 @@ lib_LTLIBRARIES = libjxtract.la libjxtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) libjxtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src -ibjxtract_la_LDFLAGS = -module -lxtract +libjxtract_la_LDFLAGS = -module -lxtract libjxtract_la_LIBADD = $(top_srcdir)/src/libxtract.la SWIG_JAVA_OPT = -java -package xtract.core This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pos...@us...> - 2007-10-06 16:36:04
|
Revision: 101 http://libxtract.svn.sourceforge.net/libxtract/?rev=101&view=rev Author: postlude Date: 2007-10-06 09:36:00 -0700 (Sat, 06 Oct 2007) Log Message: ----------- Removed fftw_plan from xtraction functions. Created new init function xtract_init_fft() for creating plans, which have global scope. Updated examples to reflect the change. New configure option: --with-fft_optimisation (0 = FFTW_ESTIMATE, 1 = FFTW_MEASURE, 2 = FFTW_PATIENT). Modified Paths: -------------- trunk/ChangeLog trunk/TODO trunk/configure.in trunk/examples/MSP/xtract~.c trunk/examples/puredata/simple-example.pd trunk/examples/puredata/xtract/f0.pd trunk/examples/puredata/xtract/xtract-help.pd trunk/examples/puredata/xtract~.c trunk/src/Makefile.am trunk/src/init.c trunk/src/vector.c trunk/src/xtract_macros_private.h trunk/xtract/libxtract.h trunk/xtract/xtract_delta.h trunk/xtract/xtract_vector.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/ChangeLog 2007-10-06 16:36:00 UTC (rev 101) @@ -1,3 +1,14 @@ +2007-10-06 Jamie Bullock <ja...@po...> + * version 0.5.0 + * Removed fftw_plan creation from inner loop of functions that use fft + * Added new init function xtract_init_fft() for initialisation of + fft_plan out-of-place. The actual plans have global scope, and are + freed by the library destructor. + * Updated Max/MSP and PD examples too reflect the above change + * Made the fft optimistation level a compile-time option through + --with-fft-optimisation flag (0 = lowest, 2 = highest). + * Minor fixes. + 2007-10-04 Dan Stowell * version 0.4.9 * Fixed and tidied MFCC functions Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/TODO 2007-10-06 16:36:00 UTC (rev 101) @@ -12,3 +12,4 @@ 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() Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/configure.in 2007-10-06 16:36:00 UTC (rev 101) @@ -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, 4) +m4_define(libxtract_minor_version, 5) # 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) @@ -85,6 +85,16 @@ echo ]) +dnl Set FFT optimisation level +AC_ARG_WITH(fft_optimisation, + [ --with-fft_optimisation=level set fft optimistaion level (default=1)], + [ + FFT_OPTIMISATION="$withval" + echo + echo "fft optimisation level is $withval" + echo + ]) + dnl set a specific java compiler AC_ARG_WITH(javac, [ --with-javac=compiler set a specific java compiler (determined automatically if not set) ], @@ -140,7 +150,7 @@ if test "$with_debug" = "yes" then AC_DEFINE(DEBUG,1,[Define to enable debug]) - CFLAGS="$CFLAGS -O0 -ggdb -g" + CFLAGS="$CFLAGS -O0 -ggdb -g -Werror" fi AC_ARG_ENABLE(swig, @@ -188,6 +198,13 @@ if [[ "$fft" = "true" ]] ; then LDFLAGS="$LDFLAGS -lfftw3f" AC_DEFINE([BUILD_FFT], [1], [Build the fft functions]) + if test "$FFT_OPTIMISATION" = "" + then + AC_DEFINE([XTRACT_FFT_OPTIMISATION_LEVEL], [1], [fft optimisation 1]) + else + # AC_SUBST(OPTIMISATION_LEVEL, "$FFT_OPTIMISATION") + AC_DEFINE_UNQUOTED(XTRACT_FFT_OPTIMISATION_LEVEL, ${FFT_OPTIMISATION}) + fi AC_CHECK_HEADER(fftw3.h, [have_fftw3_hdr=yes ], [ have_pd_hdr=no echo Modified: trunk/examples/MSP/xtract~.c =================================================================== --- trunk/examples/MSP/xtract~.c 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/examples/MSP/xtract~.c 2007-10-06 16:36:00 UTC (rev 101) @@ -40,6 +40,9 @@ void *outlet; /*Float outlet */ t_float f; t_int feature; + t_symbol *feature_name; + t_int init_blocksize; + t_int done_init; t_int feature_type; tracked_memory memory; void *argv; @@ -75,6 +78,11 @@ if(x->feature == XTRACT_PEAK_SPECTRUM) N >>= 1; + if(N != x->init_blocksize && x->done_init){ + post("xtract~ %s: Blocksize mismatch, try specifying the blocksize as a second argument", x->feature_name->s_name); + return (w+5); + } + n = N; temp_in = (float *)getbytes(N * sizeof(float)); @@ -114,14 +122,12 @@ t_symbol *tmp; t_xtract_tilde *x = (t_xtract_tilde *)newobject(xtract_tilde_class); xtract_mel_filter *mf; - t_int n, N, f, F, n_args, type, blocksize; + t_int n, N, f, F, n_args, type; t_float *argv_max; xtract_function_descriptor_t *fd; char *p_name, *p_desc, *author; int year; - - blocksize = BLOCKSIZE; /* Default */ tmp = NULL; p_name = p_desc = author = NULL; @@ -129,16 +135,17 @@ f = F = XTRACT_FEATURES; - /* N = BLOCKSIZE;*/ + N = BLOCKSIZE; x->argv = NULL; + x->done_init = 0; if(argc) tmp = argv[0].a_w.w_sym; /*atom_getsymbol(argv); */ if(argc > 1) - blocksize = (t_int)argv[1].a_w.w_long; + N = (t_int)argv[1].a_w.w_long; - N = blocksize; + x->init_blocksize = N; /* get function descriptors */ fd = (xtract_function_descriptor_t *)xtract_make_descriptors(); @@ -214,6 +221,14 @@ else if(x->feature == XTRACT_BARK_COEFFICIENTS) xtract_init_bark(N, NYQUIST, x->argv); + /* Initialise fft_plan if required */ + if(x->feature == XTRACT_AUTOCORRELATION_FFT || + x->feature == XTRACT_SPECTRUM || + x->feature == XTRACT_DCT){ + xtract_init_fft(N, x->feature); + x->done_init = 1; + } + if(x->feature == XTRACT_AUTOCORRELATION || x->feature == XTRACT_AUTOCORRELATION_FFT || x->feature == XTRACT_MFCC || x->feature == XTRACT_AMDF || Modified: trunk/examples/puredata/simple-example.pd =================================================================== --- trunk/examples/puredata/simple-example.pd 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/examples/puredata/simple-example.pd 2007-10-06 16:36:00 UTC (rev 101) @@ -1,8 +1,26 @@ -#N canvas 0 0 450 300 10; +#N canvas 5 48 450 300 10; +#X obj 154 42 osc~ 440; +#X floatatom 154 180 8 0 0 0 - - -; +#N canvas 619 86 450 300 spectral_mean 1; #X obj 144 80 xtract~ spectrum; -#X obj 154 26 osc~ 440; -#X obj 145 129 xtract~ spectral_mean; -#X floatatom 146 184 5 0 0 0 - - -; +#X obj 346 21 block~ 1024; +#X obj 145 47 inlet~; +#X obj 145 190 outlet; +#X obj 145 129 xtract~ spectral_centroid; +#X msg 269 57 list \$1; +#X msg 270 11 44100; +#X obj 270 33 / 1024; +#X obj 67 130 print~; +#X obj 73 104 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X connect 0 0 4 0; +#X connect 0 0 8 0; +#X connect 2 0 0 0; +#X connect 4 0 3 0; +#X connect 5 0 0 1; +#X connect 6 0 7 0; +#X connect 7 0 5 0; +#X connect 9 0 8 0; +#X restore 154 115 pd spectral_mean; #X connect 0 0 2 0; -#X connect 1 0 0 0; -#X connect 2 0 3 0; +#X connect 2 0 1 0; Modified: trunk/examples/puredata/xtract/f0.pd =================================================================== --- trunk/examples/puredata/xtract/f0.pd 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/examples/puredata/xtract/f0.pd 2007-10-06 16:36:00 UTC (rev 101) @@ -53,7 +53,7 @@ #X connect 4 0 3 0; #X connect 4 0 1 1; #X restore 587 66 pd noise; -#N canvas 135 136 496 580 pda 0; +#N canvas 554 114 496 580 pda 0; #X obj 99 100 xtract~ f0; #X obj 197 6 inlet~; #X msg 361 203 list \$1; @@ -79,7 +79,6 @@ #X msg 60 48 list \$1; #X obj 274 59 r \$0-window-gen; #X obj 274 80 a_hann 2048; -#X obj 147 195 xtract~ spectrum; #X obj 148 222 xtract~ peak_spectrum; #X obj 149 315 xtract~ lowest_value; #X obj 150 243 a_blockswap~ 2048; @@ -87,15 +86,16 @@ #X obj 358 150 / 2048; #X msg 358 171 \$1 10; #X obj 356 105 r \$0-peak-args; +#X obj 147 195 xtract~ spectrum 2048; #X connect 0 0 2 0; #X connect 0 0 8 0; #X connect 0 0 9 0; #X connect 0 0 11 0; #X connect 1 0 19 0; -#X connect 2 0 27 1; -#X connect 3 0 25 0; +#X connect 2 0 26 1; +#X connect 3 0 32 0; #X connect 4 0 22 0; -#X connect 7 0 27 0; +#X connect 7 0 26 0; #X connect 8 0 9 1; #X connect 9 0 12 0; #X connect 10 0 12 0; @@ -112,14 +112,14 @@ #X connect 22 0 0 1; #X connect 23 0 24 0; #X connect 24 0 3 1; -#X connect 25 0 26 0; -#X connect 26 0 28 0; -#X connect 27 0 10 0; -#X connect 28 0 5 0; +#X connect 25 0 27 0; +#X connect 26 0 10 0; +#X connect 27 0 5 0; +#X connect 28 0 29 0; #X connect 29 0 30 0; -#X connect 30 0 31 0; -#X connect 31 0 26 1; -#X connect 32 0 29 0; +#X connect 30 0 25 1; +#X connect 31 0 28 0; +#X connect 32 0 25 0; #X restore 357 262 pd pda; #N canvas 0 0 596 417 d_saw 0; #X obj 382 176 phasor~; @@ -250,14 +250,14 @@ #X obj 11 -226 cnv 15 500 200 empty empty PDA_comparison 20 12 0 14 -261681 -66577 0; #X obj 34 -94 hsl 128 15 2 2.05 0 0 \$0-inharmonicity empty fm-inharmonicity --2 -6 0 8 -225271 -1 -1 800 1; +-2 -6 0 8 -225271 -1 -1 0 1; #X obj 34 -50 hsl 128 15 0 0.5 0 0 \$0-noisiness empty noisiness -2 -6 0 8 -225271 -1 -1 0 1; #X obj 33 -135 hsl 128 15 30 3000 0 0 \$0-fund empty f0 -2 -6 0 8 -225271 --1 -1 300 1; +-1 -1 0 1; #X obj 32 -172 tgl 15 0 \$0-sine empty sine 0 -6 0 8 -225280 -1 -1 0 1; -#X obj 73 -172 tgl 15 0 \$0-fm empty fm 0 -6 0 8 -225280 -1 -1 1 1 +#X obj 73 -172 tgl 15 0 \$0-fm empty fm 0 -6 0 8 -225280 -1 -1 0 1 ; #X obj 110 -172 tgl 15 0 \$0-saw empty saw 0 -6 0 8 -225280 -1 -1 0 1; Modified: trunk/examples/puredata/xtract/xtract-help.pd =================================================================== --- trunk/examples/puredata/xtract/xtract-help.pd 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/examples/puredata/xtract/xtract-help.pd 2007-10-06 16:36:00 UTC (rev 101) @@ -6,34 +6,37 @@ \, for a full explanation of the library and the functions it provides. Only the operation of the PD external will be explained here along with a few use case scenarios.; -#X text 20 148 [xtract~] must always be called with one argument \, -in the following form: [xtract~ <feature>] \, where <feature> is a -feature supported by the LibXtract library. A complete list of features -may be obtained by sending the external a |help( message:; -#X obj 27 262 xtract~; -#X msg 27 233 help; -#X text 26 298 Other than this help message \, the data sent to the +#X obj 27 299 xtract~; +#X msg 27 270 help; +#X text 27 328 Other than this help message \, the data sent to the left inlet should always be a 'signal' (i.e. audio rate). This is the data from a which a given feature will be extracted.; -#X obj 182 490 xtract~ mean; -#X floatatom 132 586 10 0 0 0 - - -; -#X floatatom 253 523 5 0 0 0 - - -; -#X msg 182 522 list \$1; -#X obj 132 556 xtract~ variance; -#X obj 181 466 phasor~ 0.1; -#X text 39 641 Below are some possible use cases (click to open):; -#X text 26 352 The outlet may be a scalar (control rate) \, or a vector +#X obj 183 520 xtract~ mean; +#X floatatom 133 616 10 0 0 0 - - -; +#X floatatom 254 553 5 0 0 0 - - -; +#X msg 183 552 list \$1; +#X obj 133 586 xtract~ variance; +#X obj 182 496 phasor~ 0.1; +#X text 40 671 Below are some possible use cases (click to open):; +#X text 27 382 The outlet may be a scalar (control rate) \, or a vector (audio rate) \, depending on the nature of the feature that is being extracted.; -#X obj 42 665 f0; -#X obj 83 665 mfcc; -#X text 27 405 Any additional arguments that need to be passed to the +#X obj 43 695 f0; +#X obj 84 695 mfcc; +#X text 28 435 Any additional arguments that need to be passed to the feature extraction function must be provided as a list to the right inlet \, e.g.; -#X connect 5 0 4 0; -#X connect 7 0 9 0; -#X connect 7 0 10 0; -#X connect 10 0 11 1; -#X connect 11 0 8 0; -#X connect 12 0 7 0; -#X connect 12 0 11 0; +#X text 24 231 A complete list of features may be obtained by sending +the external a |help( message:; +#X text 20 148 [xtract~] must always be called with one argument \, +in the following form: [xtract~ <feature>] \, where <feature> is a +feature supported by the LibXtract library.; +#X text 21 198 An optional second argument can be used to explicitly +set the blocksize for FFT-based features; +#X connect 4 0 3 0; +#X connect 6 0 8 0; +#X connect 6 0 9 0; +#X connect 9 0 10 1; +#X connect 10 0 7 0; +#X connect 11 0 6 0; +#X connect 11 0 10 0; Modified: trunk/examples/puredata/xtract~.c =================================================================== --- trunk/examples/puredata/xtract~.c 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/examples/puredata/xtract~.c 2007-10-06 16:36:00 UTC (rev 101) @@ -48,6 +48,9 @@ t_float f; t_int feature; t_int feature_type; + t_symbol *feature_name; + t_int init_blocksize; + t_int done_init; tracked_memory memory; void *argv; } t_xtract_tilde; @@ -72,6 +75,7 @@ } static t_int *xtract_perform_vector(t_int *w) { + t_sample *in = (t_sample *)(w[1]); t_sample *out = (t_sample *)(w[2]); t_float *tmp_in, *tmp_out; @@ -79,6 +83,11 @@ t_int N = (t_int)(w[4]), n; t_int return_code = 0; + if(N != x->init_blocksize && x->done_init){ + error("xtract~ %s: Blocksize mismatch, try specifying the blocksize as a second argument", x->feature_name->s_name); + return (w+5); + } + n = N; tmp_in = copybytes(in, N * sizeof(t_float)); @@ -112,7 +121,6 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { - t_symbol *tmp; t_xtract_tilde *x = (t_xtract_tilde *)pd_new(xtract_class); xtract_mel_filter *mf; t_int n, N, f, F, n_args, type; @@ -130,16 +138,22 @@ N = BLOCKSIZE; x->argv = NULL; + x->done_init = 0; - tmp = atom_getsymbol(argv); + if(argc) + x->feature_name = atom_getsymbol(argv); + if(argc > 1) + N = atom_getint(&argv[1]); + x->init_blocksize = N; + /* get function descriptors */ fd = (xtract_function_descriptor_t *)xtract_make_descriptors(); /* iterate over descriptors */ while(f--){ /* map creation arg to feature */ - if(tmp == gensym(fd[f].algo.name)){ + if(x->feature_name == gensym(fd[f].algo.name)){ x->feature = f; break; } @@ -170,7 +184,6 @@ x->memory.argv = 0; } - p_name = fd[f].algo.p_name; p_desc = fd[f].algo.p_desc; author = fd[f].algo.author; @@ -203,10 +216,21 @@ mf->filters[n] = (float *)getbytes(N * sizeof(float)); xtract_init_mfcc(N, NYQUIST, XTRACT_EQUAL_GAIN, 80.0f, - 18000.0f, mf->n_filters, mf->filters); + 18000.0f, mf->n_filters, mf->filters); + x->done_init = 1; } - else if(x->feature == XTRACT_BARK_COEFFICIENTS) + else if(x->feature == XTRACT_BARK_COEFFICIENTS){ xtract_init_bark(N, NYQUIST, x->argv); + x->done_init = 1; + } + + /* Initialise fft_plan if required */ + if(x->feature == XTRACT_AUTOCORRELATION_FFT || + x->feature == XTRACT_SPECTRUM || + x->feature == XTRACT_DCT){ + xtract_init_fft(N, x->feature); + x->done_init = 1; + } if(x->feature == XTRACT_AUTOCORRELATION || x->feature == XTRACT_AUTOCORRELATION_FFT || Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/src/Makefile.am 2007-10-06 16:36:00 UTC (rev 101) @@ -1,6 +1,6 @@ MAINTAINERCLEANFILES = Makefile.in -SOURCES = libxtract.c descriptors.c scalar.c vector.c delta.c init.c +SOURCES = libxtract.c descriptors.c scalar.c vector.c delta.c init.c fini.c if BUILD_FFT FFT_DEFINE = -DXTRACT_FFT Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/src/init.c 2007-10-06 16:36:00 UTC (rev 101) @@ -20,10 +20,24 @@ /* init.c: defines functions that extract a feature as a single value from an input vector */ -#include "xtract/libxtract.h" +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <math.h> #include <stdlib.h> +#include "xtract/libxtract.h" +#include "xtract_globals_private.h" + +#ifdef XTRACT_FFT +#include <fftw3.h> + +#ifndef XTRACT_FFT_OPTIMISATION_LEVEL +/* This should never happen */ +#define XTRACT_FFT_OPTIMISATION_LEVEL 1 +#endif + int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables){ int n, i, k, *fft_peak, M, next_peak; @@ -113,6 +127,10 @@ fft_tables[n][k] = 0.f; } + + /* Initialise the fft_plan for the DCT */ + xtract_init_fft(freq_bands, XTRACT_MFCC); + free(mel_peak); free(lin_peak); free(height_norm); @@ -122,6 +140,69 @@ } +int xtract_init_fft(int N, int feature_name){ + + float *input, *output; + int optimisation; + + input = output = NULL; + + fprintf(stderr, "Optimisation level: %d\n", XTRACT_FFT_OPTIMISATION_LEVEL); + + if(XTRACT_FFT_OPTIMISATION_LEVEL == 0) + optimisation = FFTW_ESTIMATE; + else if(XTRACT_FFT_OPTIMISATION_LEVEL == 1) + optimisation = FFTW_MEASURE; + else if(XTRACT_FFT_OPTIMISATION_LEVEL == 2) + optimisation = FFTW_PATIENT; + else + optimisation = FFTW_MEASURE; /* The default */ + + if(feature_name == XTRACT_AUTOCORRELATION_FFT) + N <<= 1; + + input = malloc(N * sizeof(float)); + output = malloc(N * sizeof(float)); + + switch(feature_name){ + case XTRACT_SPECTRUM: + if(spectrum_plan != NULL) + fftwf_destroy_plan(spectrum_plan); + spectrum_plan = + fftwf_plan_r2r_1d(N, input, output, FFTW_R2HC, optimisation); + break; + case XTRACT_AUTOCORRELATION_FFT: + if(autocorrelation_fft_plan_1 != NULL) + fftwf_destroy_plan(autocorrelation_fft_plan_1); + if(autocorrelation_fft_plan_2 != NULL) + fftwf_destroy_plan(autocorrelation_fft_plan_2); + autocorrelation_fft_plan_1 = + fftwf_plan_r2r_1d(N, input, output, FFTW_R2HC, optimisation); + autocorrelation_fft_plan_2 = + fftwf_plan_r2r_1d(N, input, output, FFTW_HC2R, optimisation); + break; + case XTRACT_DCT: + if(dct_plan != NULL) + fftwf_destroy_plan(dct_plan); + dct_plan = + fftwf_plan_r2r_1d(N, input, output, FFTW_REDFT00, optimisation); + case XTRACT_MFCC: + if(dct_plan != NULL) + fftwf_destroy_plan(dct_plan); + dct_plan = + fftwf_plan_r2r_1d(N, output, output, FFTW_REDFT00, optimisation); + break; + } + + free(input); + free(output); + + return XTRACT_SUCCESS; + +} + +#endif + int xtract_init_bark(int N, float sr, int *band_limits){ 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)*/ @@ -134,3 +215,4 @@ return XTRACT_SUCCESS; } + Modified: trunk/src/vector.c =================================================================== --- trunk/src/vector.c 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/src/vector.c 2007-10-06 16:36:00 UTC (rev 101) @@ -21,12 +21,13 @@ /* xtract_vector.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 <string.h> #include <stdlib.h> +#include "xtract/libxtract.h" +#include "xtract_macros_private.h" + #ifndef roundf float roundf(float f){ if (f - (int)f >= 0.5) @@ -39,17 +40,20 @@ #ifdef XTRACT_FFT #include <fftw3.h> +#include "xtract_globals_private.h" +#include "xtract_macros_private.h" int xtract_spectrum(const float *data, const int N, const void *argv, float *result){ float *input, *rfft, q, temp; size_t bytes; - int n , NxN, M, vector, withDC; - fftwf_plan plan; + int n , NxN, M, vector, withDC, argc; + //fftwf_plan plan; + vector = argc = withDC = 0; + M = N >> 1; NxN = XTRACT_SQ(N); - withDC = 0; rfft = (float *)fftwf_malloc(N * sizeof(float)); input = (float *)malloc(bytes = N * sizeof(float)); @@ -61,10 +65,17 @@ XTRACT_CHECK_q; - plan = fftwf_plan_r2r_1d(N, input, rfft, FFTW_R2HC, FFTW_ESTIMATE); - - fftwf_execute(plan); + if(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; + } + fftwf_execute_r2r(spectrum_plan, input, rfft); + switch(vector){ case XTRACT_LOG_MAGNITUDE_SPECTRUM: @@ -152,11 +163,10 @@ } else { /* The Nyquist */ - result[M - 1] = XTRACT_SQ(rfft[M]); + result[M - 1] = (float)XTRACT_SQ(rfft[M]); result[N - 1] = q * M; } - fftwf_destroy_plan(plan); fftwf_free(rfft); free(input); @@ -167,7 +177,7 @@ float *freq, *time; int n, M; - fftwf_plan plan; + //fftwf_plan plan; M = N << 1; @@ -176,9 +186,10 @@ time = (float *)calloc(M, sizeof(float)); time = memcpy(time, data, N * sizeof(float)); - plan = fftwf_plan_r2r_1d(M, time, freq, FFTW_R2HC, FFTW_ESTIMATE); + fftwf_execute_r2r(autocorrelation_fft_plan_1, time, freq); + //plan = fftwf_plan_r2r_1d(M, time, freq, FFTW_R2HC, FFTW_ESTIMATE); - fftwf_execute(plan); + //fftwf_execute(plan); for(n = 1; n < N; n++){ freq[n] = XTRACT_SQ(freq[n]) + XTRACT_SQ(freq[M - n]); @@ -188,9 +199,11 @@ freq[0] = XTRACT_SQ(freq[0]); freq[N] = XTRACT_SQ(freq[N]); - plan = fftwf_plan_r2r_1d(M, freq, time, FFTW_HC2R, FFTW_ESTIMATE); + //plan = fftwf_plan_r2r_1d(M, freq, time, FFTW_HC2R, FFTW_ESTIMATE); - fftwf_execute(plan); + //fftwf_execute(plan); + + fftwf_execute_r2r(autocorrelation_fft_plan_2, freq, time); /* Normalisation factor */ M = M * N; @@ -199,7 +212,7 @@ result[n] = time[n] / (float)M; /* result[n] = time[n+1] / (float)M; */ - fftwf_destroy_plan(plan); + //fftwf_destroy_plan(plan); fftwf_free(freq); free(time); @@ -228,13 +241,14 @@ int xtract_dct(const float *data, const int N, const void *argv, float *result){ - fftwf_plan plan; + //fftwf_plan plan; - plan = - fftwf_plan_r2r_1d(N, (float *) data, result, FFTW_REDFT00, FFTW_ESTIMATE); + //plan = + // fftwf_plan_r2r_1d(N, (float *) data, result, FFTW_REDFT00, FFTW_ESTIMATE); - fftwf_execute(plan); - fftwf_destroy_plan(plan); + fftwf_execute_r2r(dct_plan, (float *)data, result); + //fftwf_execute(plan); + //fftwf_destroy_plan(plan); return XTRACT_SUCCESS; } @@ -363,8 +377,10 @@ XTRACT_CHECK_q; - input = (float *)malloc(bytes = N * sizeof(float)); + input = (float *)calloc(N, sizeof(float)); + bytes = N * sizeof(float); + if(input != NULL) input = memcpy(input, data, bytes); else Modified: trunk/src/xtract_macros_private.h =================================================================== --- trunk/src/xtract_macros_private.h 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/src/xtract_macros_private.h 2007-10-06 16:36:00 UTC (rev 101) @@ -49,9 +49,6 @@ (= SR_LOWER_LIMIT / FFT_BANDS_MAX*/ #define XTRACT_SPEC_BW_MAX 12000.0 /* SR_UPPER_LIMIT / FFT_BANDS_MIN */ #define XTRACT_SPEC_BW_DEF 43.066 /* SR_DEFAULT / FFT_BANDS_DEF */ +#define XTRACT_ARRAY_ELEMENTS(_array) (sizeof(_array)/sizeof(_array[0])) -#ifdef __cplusplus -} #endif - -#endif Modified: trunk/xtract/libxtract.h =================================================================== --- trunk/xtract/libxtract.h 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/xtract/libxtract.h 2007-10-06 16:36:00 UTC (rev 101) @@ -261,7 +261,7 @@ * * \param N: the number of elements to be processed * - * \param *argv: an abitrary number of additional arguments, used to pass additional parameters to the function being called + * \param *argv: an abitrary number of additional arguments, used to pass additional parameters to the function being called. All arguments are compulsary! * * \param *result: a pointer to the first element in the result * @@ -326,6 +326,17 @@ */ int xtract_init_bark(int N, float sr, int *band_limits); +/** \brief An initialisation function for functions using FFT + * + * This function initialises global data structures used by functions requiring FFT functionality. It can be called multiple times with different feature names. Calling it more than once with the same feature name is not a valid operation and will result in a memory leak. + * + * \param N: the size of the FFT + * \param feature_name: the name of the feature the FFT is being used for, + * e.g. XTRACT_DCT + * + */ +int xtract_init_fft(int N, int feature_name); + /* \brief A function to build an array of function descriptors */ void *xtract_make_descriptors(); Modified: trunk/xtract/xtract_delta.h =================================================================== --- trunk/xtract/xtract_delta.h 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/xtract/xtract_delta.h 2007-10-06 16:36:00 UTC (rev 101) @@ -47,8 +47,6 @@ /*xtract_frame_tracker *xf */ /*float frames*/ - - #ifdef __cplusplus } #endif Modified: trunk/xtract/xtract_vector.h =================================================================== --- trunk/xtract/xtract_vector.h 2007-10-04 14:29:30 UTC (rev 100) +++ trunk/xtract/xtract_vector.h 2007-10-06 16:36:00 UTC (rev 101) @@ -38,7 +38,7 @@ * * \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). An optional 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 *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. */ 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-10-08 10:32:17
|
Revision: 102 http://libxtract.svn.sourceforge.net/libxtract/?rev=102&view=rev Author: postlude Date: 2007-10-08 03:32:16 -0700 (Mon, 08 Oct 2007) Log Message: ----------- Committed missing files needed for new out-of-place fftw plan creation Added Paths: ----------- trunk/examples/puredata/xtract/a_blockswap~.pd trunk/src/fini.c trunk/src/xtract_globals_private.h Added: trunk/examples/puredata/xtract/a_blockswap~.pd =================================================================== --- trunk/examples/puredata/xtract/a_blockswap~.pd (rev 0) +++ trunk/examples/puredata/xtract/a_blockswap~.pd 2007-10-08 10:32:16 UTC (rev 102) @@ -0,0 +1,29 @@ +#N canvas 670 208 475 328 10; +#X obj 70 159 samplerate~; +#X obj 70 223 phasor~; +#X msg 163 159 0.5; +#X obj 23 10 inlet~; +#X obj 23 34 tabsend~ input; +#X obj 385 4 table input; +#X obj 76 272 tabread~ input; +#X obj 75 299 outlet~; +#X obj 70 194 / \$1; +#X obj 141 78 loadbang; +#X text 232 72 Clone of zexy blockswap~; +#X text 232 90 First argument gives block size; +#X msg 209 158 \; input resize \$1; +#X obj 141 109 t b b b; +#X obj 75 249 *~ \$1; +#X obj 209 135 f \$1; +#X connect 0 0 8 0; +#X connect 1 0 14 0; +#X connect 2 0 1 1; +#X connect 3 0 4 0; +#X connect 6 0 7 0; +#X connect 8 0 1 0; +#X connect 9 0 13 0; +#X connect 13 0 0 0; +#X connect 13 1 2 0; +#X connect 13 2 15 0; +#X connect 14 0 6 0; +#X connect 15 0 12 0; Added: trunk/src/fini.c =================================================================== --- trunk/src/fini.c (rev 0) +++ trunk/src/fini.c 2007-10-08 10:32:16 UTC (rev 102) @@ -0,0 +1,48 @@ +/* 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. + */ + +/* fini.c: Contains library destructor routine */ + +#ifdef XTRACT_FFT +#include <fftw3.h> +#include "xtract_globals_private.h" +#endif + +#ifdef __GNUC__ +__attribute__((destructor)) void fini() +#else +void _fini() +#endif +{ +#ifdef XTRACT_FFT + if(spectrum_plan != NULL) + fftwf_destroy_plan(spectrum_plan); + if(autocorrelation_fft_plan_1 != NULL) + fftwf_destroy_plan(autocorrelation_fft_plan_1); + if(autocorrelation_fft_plan_2 != NULL) + fftwf_destroy_plan(autocorrelation_fft_plan_2); + if(dct_plan != NULL) + fftwf_destroy_plan(dct_plan); + fftwf_cleanup(); +#endif +} + + + Added: trunk/src/xtract_globals_private.h =================================================================== --- trunk/src/xtract_globals_private.h (rev 0) +++ trunk/src/xtract_globals_private.h 2007-10-08 10:32:16 UTC (rev 102) @@ -0,0 +1,36 @@ +/* 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_globals_private.h: declares private global variables */ + +#ifndef XTRACT_GLOBALS_PRIVATE_H +#define XTRACT_GLOBALS_PRIVATE_H + +#ifdef XTRACT_FFT +#include <fftw3.h> + +fftwf_plan spectrum_plan, + autocorrelation_fft_plan_1, + autocorrelation_fft_plan_2, + dct_plan; +#endif + +#endif + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2007-10-09 13:48:00
|
Revision: 103 http://libxtract.svn.sourceforge.net/libxtract/?rev=103&view=rev Author: danstowell Date: 2007-10-09 06:47:58 -0700 (Tue, 09 Oct 2007) Log Message: ----------- Fixed bug in xtract_init_mfcc() - iteration to decide filter peak positions only filled in freq_bands+1 values, when it should fill in freq_bands+2 Modified Paths: -------------- trunk/ChangeLog trunk/src/init.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-10-08 10:32:16 UTC (rev 102) +++ trunk/ChangeLog 2007-10-09 13:47:58 UTC (rev 103) @@ -1,3 +1,7 @@ +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 + 2007-10-06 Jamie Bullock <ja...@po...> * version 0.5.0 * Removed fftw_plan creation from inner loop of functions that use fft Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2007-10-08 10:32:16 UTC (rev 102) +++ trunk/src/init.c 2007-10-09 13:47:58 UTC (rev 103) @@ -69,15 +69,15 @@ fft_peak[0] = lin_peak[0] / nyquist * M; - for (n = 1; n <= freq_bands; n++){ - /*roll out peak locations - mel, linear and linear on fft window scale */ + for (n = 1; n < freq_bands + 2; n++){ + //roll out peak locations - mel, linear and linear on fft window scale mel_peak[n] = mel_peak[n - 1] + freq_bw_mel; lin_peak[n] = 700 * (exp(mel_peak[n] / 1127) -1); fft_peak[n] = lin_peak[n] / nyquist * M; } for (n = 0; n < freq_bands; n++){ - /*roll out normalised gain of each peak*/ + //roll out normalised gain of each peak if (style == XTRACT_EQUAL_GAIN){ height = 1; norm_fact = norm; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |