aboutsummaryrefslogtreecommitdiff
path: root/examples/simpletest
diff options
context:
space:
mode:
authorJamie Bullock <jamie@jamiebullock.com>2014-06-06 09:55:01 +0100
committerJamie Bullock <jamie@jamiebullock.com>2014-06-06 09:55:01 +0100
commite028f0d8204722f01495ec28edadbb4bdf1b6f1b (patch)
treeebe19aef151d7f34755163db7c83edd64cdb45b3 /examples/simpletest
parent0c54ec464079b450e07abe57be680ab88249b76a (diff)
downloadLibXtract-e028f0d8204722f01495ec28edadbb4bdf1b6f1b.tar.gz
LibXtract-e028f0d8204722f01495ec28edadbb4bdf1b6f1b.tar.bz2
LibXtract-e028f0d8204722f01495ec28edadbb4bdf1b6f1b.zip
Add new helper function xtract_smoothed(), e.g. can be used to extract smoothed spectrum
Diffstat (limited to 'examples/simpletest')
-rw-r--r--examples/simpletest/simpletest.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/examples/simpletest/simpletest.cpp b/examples/simpletest/simpletest.cpp
index 40bcfeb..a0ae8d4 100644
--- a/examples/simpletest/simpletest.cpp
+++ b/examples/simpletest/simpletest.cpp
@@ -31,6 +31,7 @@
#include "xtract/libxtract.h"
#include "xtract/xtract_stateful.h"
#include "xtract/xtract_scalar.h"
+#include "xtract/xtract_helper.h"
#include "WaveFile.h"
#ifndef M_PI
@@ -50,7 +51,7 @@ waveform_type;
#define BLOCKSIZE 512
#define MAVG_COUNT 10
-#define HALF_BLOCKSIZE BLOCKSIZE >> 1
+#define HALF_BLOCKSIZE (BLOCKSIZE >> 1)
#define SAMPLERATE 44100
#define PERIOD 102
#define MFCC_FREQ_BANDS 13
@@ -202,7 +203,6 @@ int main(void)
xtract_free_fft();
xtract[XTRACT_SPECTRAL_CENTROID](spectrum, BLOCKSIZE, NULL, &centroid);
-// printf("\nSpectral Centroid: %f\t", centroid);
argd[1] = 10.0; /* peak threshold as % of maximum peak */
xtract[XTRACT_PEAK_SPECTRUM](spectrum, BLOCKSIZE / 2, argd, peaks);
@@ -250,6 +250,13 @@ int main(void)
xtract_features_from_subframes(subframes_windowed, BLOCKSIZE, XTRACT_SPECTRUM, argd, subframes_spectrum);
xtract_free_fft();
+ argd[0] = 0.5; /* smoothing factor */
+
+ /* smooth the amplitude components of the first and second spectra */
+ xtract_smoothed(subframes_spectrum, HALF_BLOCKSIZE >> 1, argd, subframes_spectrum);
+ xtract_smoothed(subframes_spectrum + HALF_BLOCKSIZE, HALF_BLOCKSIZE >> 1, argd, subframes_spectrum + HALF_BLOCKSIZE);
+
+ /* difference between the two spectra */
xtract_difference_vector(subframes_spectrum, BLOCKSIZE, NULL, difference);
argd[0] = .25; /* norm order */