aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.config.in2
-rw-r--r--configure.ac2
-rw-r--r--modules++/blosc~.cc6
-rw-r--r--modules/Makefile3
-rw-r--r--modules/extlib_util.h20
-rw-r--r--modules/tabreadmix~.c85
6 files changed, 96 insertions, 22 deletions
diff --git a/Makefile.config.in b/Makefile.config.in
index 204525c..62213a3 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -6,7 +6,7 @@ prefix=@prefix@
CREB_VERSION = 0.9.2
DEFS = -DPD -DCREB_VERSION=\"$(CREB_VERSION)\"
-CFLAGS = $(DEFS) -O2 -funroll-loops -fomit-frame-pointer \
+CFLAGS = $(DEFS) -fPIC -O2 -funroll-loops -fomit-frame-pointer \
-Wall -W -Wstrict-prototypes \
-Wno-unused -Wno-parentheses -Wno-switch # -Wshadow
INCLUDE = -I$(PD_INCLUDE_DIR) -I../include -I../include/dspi
diff --git a/configure.ac b/configure.ac
index c3b788d..1a358a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@ if test $ARCH == Linux;
then
PD_INCLUDE_DIR=$prefix/pd/src
LIBNAME=creb.pd_linux
- LIBFLAGS="-export_dynamic -shared"
+ LIBFLAGS="-rdynamic -shared"
echo "Linux"
elif test $ARCH == Darwin;
diff --git a/modules++/blosc~.cc b/modules++/blosc~.cc
index 9028eaf..8934904 100644
--- a/modules++/blosc~.cc
+++ b/modules++/blosc~.cc
@@ -25,13 +25,11 @@
#include <stdlib.h>
#include <string.h>
+#include "../modules/extlib_util.h"
#include "DSPIcomplex.h"
#include "DSPIfilters.h"
-typedef unsigned long long u64;
-typedef unsigned long u32;
-
#define LPHASOR (8*sizeof(u32)) // the phasor logsize
@@ -471,7 +469,7 @@ static void blosc_dsp(t_blosc *x, t_signal **sp)
int n = sp[0]->s_n;
/* set sampling rate scaling for phasors */
- x->x_ctl.c_phase_inc_scale = 4.0 * (t_float)(1<<(LPHASOR-2)) / sys_getsr();
+ x->x_ctl.c_phase_inc_scale = 4.0 * ((t_float)(1<<(LPHASOR-2))) / sys_getsr();
/* setup & register the correct process routine depending on the waveform */
diff --git a/modules/Makefile b/modules/Makefile
index 91f89fa..b46ab85 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -6,9 +6,10 @@ current: ead~.o ear~.o eadsr~.o dist~.o \
bfft~.o dynwav~.o statwav~.o bdiag~.o \
diag~.o matrix~.o permut~.o lattice~.o ratio.o ffpoly.o fwarp.o \
junction~.o fdn~.o bwin~.o eblosc~.o bitsplit~.o sbosc~.o \
- blocknorm~.o resofilt~.o scrollgrid1D~.o \
+ blocknorm~.o resofilt~.o scrollgrid1D~.o \
\
dwt.o cmath.o \
+ sawtooth~.o \
\
setup.o
diff --git a/modules/extlib_util.h b/modules/extlib_util.h
index 6261e39..e0a7bb3 100644
--- a/modules/extlib_util.h
+++ b/modules/extlib_util.h
@@ -23,6 +23,25 @@
#include <math.h>
#include "m_pd.h"
+
+#define CT_NAMED_ASSERT(name,x) \
+ typedef int _GENSYM(name ## _ctassert_)[-((x)==0)]
+#define CT_ASSERT(x) CT_NAMED_ASSERT(,x)
+#define _GENSYM(x) _CONCAT(x,__COUNTER__)
+#define _CONCAT1(x,y) x##y
+#define _CONCAT(x,y) _CONCAT1(x,y)
+
+/* Only defined in pd-extended. */
+#ifndef PD_FLOAT_PRECISION
+#define PD_FLOAT_PRECISION 32
+#endif
+
+/* http://www.unix.org/version2/whatsnew/lp64_wp.html */
+typedef unsigned long long u64;
+typedef unsigned int u32;
+CT_ASSERT(sizeof(u32)==4);
+CT_ASSERT(sizeof(u64)==8);
+
/* envelope stuff */
/* exponential range for envelopes is 60dB */
@@ -70,6 +89,7 @@ typedef union
#define IS_DENORMAL(f) (((((t_flint)(f)).i[1]) & 0x7ff00000) == 0)
#endif // endif PD_FLOAT_PRECISION
+
#else // if not defined(__i386__) || defined(__x86_64__)
#define IS_DENORMAL(f) 0
#endif // end if defined(__i386__) || defined(__x86_64__)
diff --git a/modules/tabreadmix~.c b/modules/tabreadmix~.c
index 74940a2..d122eea 100644
--- a/modules/tabreadmix~.c
+++ b/modules/tabreadmix~.c
@@ -1,6 +1,9 @@
/*
* tabreadmix.c - an overlap add tabread~ clone
+ *
* Copyright (c) 2000-2003 by Tom Schouten
+ * Additional code (audiorate, wrap messages) copyright (c) 2008 by
+ * Damian Stewart, damian [at] frey [dot] co [dot] nz
*
* 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
@@ -32,8 +35,9 @@ typedef struct _tabreadmix_tilde
t_float x_f;
/* file position vars */
- int x_currpos;
- int x_prevpos;
+ t_float x_currpos;
+ t_float x_prevpos;
+ t_float x_posinc;
/* cross fader state vars */
int x_xfade_size;
@@ -42,6 +46,12 @@ typedef struct _tabreadmix_tilde
t_float x_xfade_sin;
t_float x_xfade_state_c;
t_float x_xfade_state_s;
+
+ /* wrap start and end */
+ int x_wrap_start;
+ int x_wrap_end;
+ int x_wrap_length;
+
} t_tabreadmix_tilde;
@@ -49,22 +59,23 @@ typedef struct _tabreadmix_tilde
inline void tabreadmix_tilde_wrapindices(t_tabreadmix_tilde *x)
{
- int max;
/* modulo */
- x->x_currpos %= x->x_npoints;
- x->x_prevpos %= x->x_npoints;
+ while ( x->x_currpos > x->x_wrap_end )
+ x->x_currpos -= x->x_wrap_length;
+ while ( x->x_prevpos > x->x_wrap_end )
+ x->x_prevpos -= x->x_wrap_length;
/* make sure 0<=..<x->x_npoints */
//if (x->x_currpos < 0) x->x_currpos += x->x_npoints;
//if (x->x_prevpos < 0) x->x_prevpos += x->x_npoints;
x->x_currpos += (x->x_currpos < 0) * x->x_npoints;
x->x_prevpos += (x->x_prevpos < 0) * x->x_npoints;
-
+
+
}
-
#define min(x,y) ((x)<(y)?(x):(y))
static t_int *tabreadmix_tilde_perform(t_int *w)
@@ -82,7 +93,8 @@ static t_int *tabreadmix_tilde_perform(t_int *w)
int leftover;
int newpos = (int)*pos;
- maxxindex = x->x_npoints;
+// maxxindex = x->x_npoints;
+ maxxindex = x->x_wrap_end;
if (!buf) goto zero;
if (maxxindex <= 0) goto zero;
@@ -103,14 +115,13 @@ static t_int *tabreadmix_tilde_perform(t_int *w)
/* mix and write */
newpos = (int)(*pos++);
- *out++ = currgain * buf[x->x_currpos++]
- + prevgain * buf[x->x_prevpos++];
+ *out++ = currgain * buf[(int)x->x_currpos] + prevgain * buf[(int)x->x_prevpos];
+ x->x_currpos += x->x_posinc;
+ x->x_prevpos += x->x_posinc;
/* advance oscillator */
- c = x->x_xfade_state_c * x->x_xfade_cos
- - x->x_xfade_state_s * x->x_xfade_sin;
- s = x->x_xfade_state_c * x->x_xfade_sin
- + x->x_xfade_state_s * x->x_xfade_cos;
+ c = x->x_xfade_state_c * x->x_xfade_cos - x->x_xfade_state_s * x->x_xfade_sin;
+ s = x->x_xfade_state_c * x->x_xfade_sin + x->x_xfade_state_s * x->x_xfade_cos;
x->x_xfade_state_c = c;
x->x_xfade_state_s = s;
}
@@ -145,9 +156,12 @@ static void tabreadmix_tilde_blocksize(t_tabreadmix_tilde *x, t_float size)
{
double prev_phase;
int max;
- t_float fmax = (t_float)x->x_npoints * 0.5;
+
+ t_float fmax = (t_float)x->x_wrap_length * 0.5;
if (size < 1.0) size = 1.0;
+// post( "got input size %f\n", size );
+
prev_phase = (double)x->x_xfade_phase;
prev_phase *= size;
@@ -175,6 +189,23 @@ static void tabreadmix_tilde_blocksize(t_tabreadmix_tilde *x, t_float size)
}
+void tabreadmix_tilde_wrap(t_tabreadmix_tilde *x, t_float start, t_float end )
+{
+ if ( start > end )
+ error( "tabreadmix~: wrap: start %i must be lower than end %i", (int)start, (int)end );
+ else if ( 0 > start || start > x->x_npoints )
+ error( "tabreadmix~: wrap: start %i must be between 0 and bufsize (%d)", (int)start, (int)x->x_npoints );
+ else if ( 0 > end || end > x->x_npoints )
+ error( "tabreadmix~: wrap: end %i must be between 0 and bufsize (%d)", (int)end, (int)x->x_npoints );
+ else
+ {
+ x->x_wrap_start = start;
+ x->x_wrap_end = end;
+ x->x_wrap_length = end - start;
+ }
+
+}
+
void tabreadmix_tilde_pitch(t_tabreadmix_tilde *x, t_float f)
{
if (f < 1) f = 1;
@@ -182,6 +213,15 @@ void tabreadmix_tilde_pitch(t_tabreadmix_tilde *x, t_float f)
tabreadmix_tilde_blocksize(x, sys_getsr() / f);
}
+
+void tabreadmix_tilde_audiorate(t_tabreadmix_tilde *x, t_float f)
+{
+ if ( f<0.001 ) f = 0.001;
+
+ x->x_posinc = f;
+}
+
+
void tabreadmix_tilde_chunks(t_tabreadmix_tilde *x, t_float f)
{
if (f < 1.0) f = 1.0;
@@ -197,6 +237,7 @@ void tabreadmix_tilde_bang(t_tabreadmix_tilde *x, t_float f)
void tabreadmix_tilde_set(t_tabreadmix_tilde *x, t_symbol *s)
{
t_garray *a;
+ int old_npoints = x->x_npoints;
x->x_arrayname = s;
if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
@@ -212,6 +253,14 @@ void tabreadmix_tilde_set(t_tabreadmix_tilde *x, t_symbol *s)
}
else garray_usedindsp(a);
+ // reset wrappage
+ if ( old_npoints != x->x_npoints )
+ {
+ x->x_wrap_start = 0;
+ x->x_wrap_end = x->x_npoints;
+ x->x_wrap_length = x->x_npoints;
+ }
+
/* make sure indices are inside array */
if (x->x_npoints == 0){
x->x_currpos = 0;
@@ -247,6 +296,7 @@ static void *tabreadmix_tilde_new(t_symbol *s)
x->x_xfade_size = 1024;
x->x_currpos = 0;
x->x_prevpos = 0;
+ x->x_posinc = 1.0;
x->x_xfade_state_c = 0.5;
x->x_xfade_state_s = 0.0;
tabreadmix_tilde_blocksize(x, 1024);
@@ -269,6 +319,11 @@ void tabreadmix_tilde_setup(void)
gensym("pitch"), A_FLOAT, 0);
class_addmethod(tabreadmix_tilde_class, (t_method)tabreadmix_tilde_chunks,
gensym("chunks"), A_FLOAT, 0);
+ class_addmethod(tabreadmix_tilde_class, (t_method)tabreadmix_tilde_audiorate,
+ gensym("audiorate"), A_FLOAT, 0 );
+ class_addmethod(tabreadmix_tilde_class, (t_method)tabreadmix_tilde_wrap,
+ gensym("wrap"), A_FLOAT, A_FLOAT, 0 );
class_addmethod(tabreadmix_tilde_class, (t_method)tabreadmix_tilde_bang,
gensym("bang"), 0);
+
}