aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2006-12-09 15:21:35 +0000
committerJamie Bullock <jamie@postlude.co.uk>2006-12-09 15:21:35 +0000
commit9636bf2fdb2cdb27483b47d9ab6b238a25d374d5 (patch)
tree483aae427b64d66fcf3e06328f5ba6d60625eed8 /examples
parent8c199a3c2e5107a51f048d48bc581c9961d70373 (diff)
downloadLibXtract-9636bf2fdb2cdb27483b47d9ab6b238a25d374d5.tar.gz
LibXtract-9636bf2fdb2cdb27483b47d9ab6b238a25d374d5.tar.bz2
LibXtract-9636bf2fdb2cdb27483b47d9ab6b238a25d374d5.zip
Implemented xtract_harmonics
Diffstat (limited to 'examples')
-rw-r--r--examples/puredata/xtract~.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c
index 958f8fc..05dc5e0 100644
--- a/examples/puredata/xtract~.c
+++ b/examples/puredata/xtract~.c
@@ -39,10 +39,14 @@ static t_int *xtract_perform(t_int *w) {
t_sample *in = (t_sample *)(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;
- xtract[x->feature]((float *)in, N, x->argv, &result);
+ return_code = xtract[x->feature]((float *)in, N, x->argv, &result);
+ if(return_code == FEATURE_NOT_IMPLEMENTED)
+ pd_error(x, "Feature not implemented");
+
outlet_float(x->x_obj.ob_outlet, result);
return (w+4);
}
@@ -53,11 +57,15 @@ static t_int *xtract_perform_vector(t_int *w) {
t_float *tmp_in, *tmp_out;
t_xtract_tilde *x = (t_xtract_tilde *)(w[3]);
t_int N = (t_int)(w[4]), n;
+ t_int return_code = 0;
tmp_in = copybytes(in, N * sizeof(t_float));
tmp_out = getbytes(N * sizeof(t_float));
- xtract[x->feature](tmp_in, N, x->argv, tmp_out);
+ return_code = xtract[x->feature](tmp_in, N, x->argv, tmp_out);
+
+ if(return_code == FEATURE_NOT_IMPLEMENTED)
+ pd_error(x, "Feature not implemented");
n = N;
@@ -158,6 +166,10 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) {
80.0f, f->n_filters, f->filters);
}
else if(tmp == gensym("dct")) x->feature = DCT;
+ else if(tmp == gensym("harmonics")){
+ x->feature = HARMONICS;
+ x->argv = getbytes(3 * sizeof(t_float));
+ }
else if(tmp == gensym("bark_coefficients")){
x->feature = BARK_COEFFICIENTS;
x->argv = (t_int *)getbytes(BARK_BANDS * sizeof(t_int));
@@ -173,7 +185,8 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) {
if(x->feature == AUTOCORRELATION || x->feature == AUTOCORRELATION_FFT ||
x->feature == MFCC || x->feature == AMDF || x->feature == ASDF||
x->feature == DCT || x->feature == BARK_COEFFICIENTS ||
- x->feature == MAGNITUDE_SPECTRUM || x->feature == PEAKS)
+ x->feature == MAGNITUDE_SPECTRUM || x->feature == PEAKS ||
+ x->feature == HARMONICS)
x->feature_type = VECTOR;
else if (x->feature == FLUX || x->feature == ATTACK_TIME ||