From 0cb66a03e133428a6778de2abec3df4c6cedea59 Mon Sep 17 00:00:00 2001 From: Tom Schouten Date: Tue, 18 Feb 2003 13:18:54 +0000 Subject: creb update svn path=/trunk/externals/creb/; revision=419 --- CHANGES.LOG | 3 + Makefile | 2 +- Makefile.config | 8 +-- Makefile.config_darwin | 8 +-- Makefile.pd_darwin | 2 +- README | 1 + README.darwin | 1 - abs/fblock.pd | 5 +- abs/tblock.pd | 26 ++++++++ doc/bwin~.pd | 53 ++++++++++++++++ doc/cheby~.pd | 2 +- doc/fdn~.pd | 4 +- doc/reference.txt | 9 ++- modules/Makefile | 2 +- modules/cheby.c | 2 +- modules/fdn.c | 1 + modules/window.c | 168 +++++++++++++++++++++++++++++++++++++++++++++++++ system/setup.c | 2 + 18 files changed, 277 insertions(+), 22 deletions(-) create mode 100644 CHANGES.LOG create mode 100644 abs/tblock.pd create mode 100644 doc/bwin~.pd create mode 100644 modules/window.c diff --git a/CHANGES.LOG b/CHANGES.LOG new file mode 100644 index 0000000..9cf4d9c --- /dev/null +++ b/CHANGES.LOG @@ -0,0 +1,3 @@ +0.1-0.7: the dark ages +0.8: 2002/02/18 + fixed makefiles, added window~ diff --git a/Makefile b/Makefile index d03e9f8..7156eae 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ current: make -C modules++ rm -f $(LIBNAME) - $(CPLUSPLUS) -export_dynamic -shared -o $(LIBNAME) system/*.o modules/*.o modules++/*.o -lm + $(CXX) -export_dynamic -shared -o $(LIBNAME) system/*.o modules/*.o modules++/*.o -lm strip --strip-unneeded $(LIBNAME) clean: diff --git a/Makefile.config b/Makefile.config index a57eeb5..dbbe56b 100644 --- a/Makefile.config +++ b/Makefile.config @@ -1,6 +1,6 @@ PD_DIR = /home/tom/pd/distro/pd/src CREB_DIR = /home/tom/pd/extlib -CREB_VERSION = 0.7 +CREB_VERSION = 0.8 DEFS = -DPD -DCREB_VERSION=\"$(CREB_VERSION)\" #-DHAVE_ABS_TILDE @@ -11,11 +11,11 @@ LINUXCFLAGS = $(DEFS) -O2 -funroll-loops -fomit-frame-pointer \ LINUXINCLUDE = -I$(PD_DIR) -I../include -I../include/dspi -CC = gcc -CPLUSPLUS = g++ +#CC = gcc +#CXX = g++ .c.o: $(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c .cc.o: - $(CPLUSPLUS) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.cc + $(CXX) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.cc diff --git a/Makefile.config_darwin b/Makefile.config_darwin index b9c49eb..705d134 100644 --- a/Makefile.config_darwin +++ b/Makefile.config_darwin @@ -1,7 +1,7 @@ PD_DIR = /usr/local/pd/src PD_EXECUTABLE = /usr/local/pd/bin/pd -CREB_VERSION = 0.5 +CREB_VERSION = 0.8 LIBNAME = creb.pd_darwin @@ -15,11 +15,11 @@ INCLUDE = -I$(PD_DIR) -I../include -I../include/dspi LIBFLAGS = -bundle -bundle_loader $(PD_EXECUTABLE) -CC = gcc -CPLUSPLUS = g++ +#CC = gcc +#CXX = g++ .c.o: $(CC) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.c .cc.o: - $(CPLUSPLUS) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.cc + $(CXX) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.cc diff --git a/Makefile.pd_darwin b/Makefile.pd_darwin index 7dad28d..bcdaa83 100644 --- a/Makefile.pd_darwin +++ b/Makefile.pd_darwin @@ -7,7 +7,7 @@ current: make -C modules++ rm -f $(LIBNAME) - $(CPLUSPLUS) $(LIBFLAGS) -o $(LIBNAME) system/*.o modules/*.o modules++/*.o -lm + $(CXX) $(LIBFLAGS) -o $(LIBNAME) system/*.o modules/*.o modules++/*.o -lm # strip --strip-unneeded $(LIBNAME) clean: diff --git a/README b/README index 5fc874d..8f2bb32 100644 --- a/README +++ b/README @@ -42,3 +42,4 @@ the darwin makefiles) Enjoy, Tom + diff --git a/README.darwin b/README.darwin index b685304..0edef42 100644 --- a/README.darwin +++ b/README.darwin @@ -1,6 +1,5 @@ Create a symbolic link to Makefile.config_darwin: - mv Makefile.config Makefile.config_linux ln -s Makefile.config_darwin Makefile.config Make the file using the pd_darwin file: diff --git a/abs/fblock.pd b/abs/fblock.pd index dbbf41e..b75a8b2 100644 --- a/abs/fblock.pd +++ b/abs/fblock.pd @@ -1,4 +1,4 @@ -#N canvas 73 29 617 246 10; +#N canvas 290 132 617 246 10; #X obj 36 36 inlet; #X obj 101 35 inlet; #X obj 42 196 outlet; @@ -12,8 +12,7 @@ #X text 201 119 main usage is to compute block synchronous frequencies ; #X text 200 134 for spectral domain processing; -#X text 201 49 out = left + right * (sys samplerate / sys blocksize) -; +#X text 201 49 out = left + right * (sys samplerate / blocksize); #X connect 0 0 5 0; #X connect 1 0 7 0; #X connect 3 0 4 0; diff --git a/abs/tblock.pd b/abs/tblock.pd new file mode 100644 index 0000000..1682b49 --- /dev/null +++ b/abs/tblock.pd @@ -0,0 +1,26 @@ +#N canvas 506 229 617 246 10; +#X obj 36 36 inlet; +#X obj 101 35 inlet; +#X obj 42 196 outlet; +#X obj 144 99 samplerate~; +#X obj 59 158 +; +#X text 222 78 right inlet is also "active"; +#X text 222 133 for spectral domain processing; +#X text 222 34 tblock: compute block relative time delays; +#X text 223 48 out = left + right * (blocksize / sys_samplerate); +#X obj 104 115 /; +#X obj 101 92 * \$1; +#X obj 103 59 t b f b; +#X text 223 118 main usage is to compute block synchronous time delays +; +#X obj 95 141 * 1000; +#X connect 0 0 4 0; +#X connect 1 0 11 0; +#X connect 3 0 9 1; +#X connect 4 0 2 0; +#X connect 9 0 13 0; +#X connect 10 0 9 0; +#X connect 11 0 4 0; +#X connect 11 1 10 0; +#X connect 11 2 3 0; +#X connect 13 0 4 1; diff --git a/doc/bwin~.pd b/doc/bwin~.pd new file mode 100644 index 0000000..7f630d8 --- /dev/null +++ b/doc/bwin~.pd @@ -0,0 +1,53 @@ +#N canvas 62 558 450 300 10; +#N canvas 409 279 692 500 windowing 1; +#X obj 62 441 outlet~; +#X obj 62 65 inlet~; +#X obj 62 142 bfft~; +#X obj 62 365 ibfft~; +#X floatatom 85 173 5 0 0; +#X obj 62 199 vol~; +#X text 60 6 bwin~ multiplies a signal block with a window; +#X text 211 310 after maximizing the spectrum is multiplied by a pink +noise envelope; +#X obj 62 250 dist~ 1; +#X text 211 105 apply analysis window; +#X text 211 172 set drive; +#X text 212 251 soft clip spectral data; +#X text 212 133 transform block to freq domain; +#X text 210 360 transform block back to time domain; +#X text 212 401 undo analysis window + apply synthesis window; +#X text 212 39 this example is a poor man's spectral maximizer using +bwin~ bfft~ bifft~ and dist~; +#X obj 62 225 bwin~ bfft_blue; +#X obj 62 327 bwin~ bfft_pink; +#X obj 62 401 bwin~ hann/hamming; +#X obj 62 106 bwin~ hamming; +#X msg 344 207 type bfft_db/octave \$1; +#X floatatom 517 172 5 0 0; +#X msg 345 277 type bfft_db/octave \$1; +#X obj 545 427 block~ 16384 2; +#X floatatom 519 244 5 0 0; +#X connect 1 0 19 0; +#X connect 2 0 5 0; +#X connect 3 0 18 0; +#X connect 4 0 5 1; +#X connect 5 0 16 0; +#X connect 8 0 17 0; +#X connect 16 0 8 0; +#X connect 17 0 3 0; +#X connect 18 0 0 0; +#X connect 19 0 2 0; +#X connect 20 0 16 0; +#X connect 21 0 20 0; +#X connect 22 0 17 0; +#X connect 24 0 22 0; +#X restore 53 88 pd windowing; +#X obj 41 219 dac~; +#X obj 53 150 vol~; +#X floatatom 76 124 5 0 0; +#X obj 53 41 adc~ 7; +#X connect 0 0 2 0; +#X connect 2 0 1 0; +#X connect 2 0 1 1; +#X connect 3 0 2 1; +#X connect 4 0 0 0; diff --git a/doc/cheby~.pd b/doc/cheby~.pd index 30bb77e..1cf1f94 100644 --- a/doc/cheby~.pd +++ b/doc/cheby~.pd @@ -17,7 +17,7 @@ #X msg 226 150 coef 2 \$1; #X msg 305 150 coef 3 \$1; #X msg 384 150 coef 4 \$1; -#X text 96 3 chebychev waveshaper; +#X text 96 3 chebyshev waveshaper; #X text 207 229 creation argument: order of polynomial; #X text 135 47 coef n x sets coefficient of nth order cheby poly to x; diff --git a/doc/fdn~.pd b/doc/fdn~.pd index 32bee94..3903d63 100644 --- a/doc/fdn~.pd +++ b/doc/fdn~.pd @@ -17,7 +17,6 @@ #X msg 360 271 linear 32 1000 1005; #X msg 12 465 reset; #X obj 142 463 fdn~ 64 40000; -#X msg 358 351 exponential 64 10 1000; #X msg 358 327 exponential 32 10 5000; #X msg 360 292 linear 32 100 2015; #X msg 361 224 linear 8 75 100; @@ -34,6 +33,7 @@ memory in ms>; #X text 361 170 ; #X text 359 430 inlets: low/high frequency reverb time (60dB time) ; +#X msg 358 351 exponential 64 1000 10; #X connect 0 0 2 0; #X connect 0 1 2 1; #X connect 1 0 0 2; @@ -58,4 +58,4 @@ memory in ms>; #X connect 19 0 16 0; #X connect 20 0 16 0; #X connect 21 0 16 0; -#X connect 22 0 16 0; +#X connect 31 0 16 0; diff --git a/doc/reference.txt b/doc/reference.txt index b167b72..9518d84 100644 --- a/doc/reference.txt +++ b/doc/reference.txt @@ -12,6 +12,7 @@ fblock block relative frequency conversion inv inverse pdynwav~ phasor~ + dynwav~ scale7 arbitrary 7 tone scale +tblock block relative time conversion vols~ volume for a stereo signal vol~ volume for a mono signal @@ -27,7 +28,9 @@ tilde externs abs~ absolute value bdiag~ block diagonal state space system (spectral processor) bfft~ reordered fft -cheby~ chebychev polynomial waveshaper +bwin~ several windowing functions and spectral envelopes +biquadseries~ biquad second order sections (i.e. butterworth) +cheby~ chebyshev polynomial waveshaper diag~ diagonal state space system (spectral processor) dist~ several distortions & waveshaping functions dwt~ discrete wavelet transform @@ -36,6 +39,7 @@ dynwav~ dynamic wavetable: use a signal block as wavetable ead~ exp. attack decay eadsr~ exp. attack decay sustain release ear~ exp. attack release +filterortho~ several biquad filters, orthogonal implementation fdn~ a feedback delay network junction~ a circulant lossless signal junction lattice~ lattice filter @@ -47,5 +51,4 @@ ramp~ generates an integer ramp statwav~ a tabread4~ clone with 8 point interpolation tabreadmix~ a tabread~ clone with overlap add (for smooth time stretch) xfm~ coupled frequency modulation -biquadseries~ biquad second order sections (i.e. butterworth) -filterortho~ several biquad filters, orthogonal implementation + diff --git a/modules/Makefile b/modules/Makefile index 17a4893..b5e6093 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -3,7 +3,7 @@ include ../Makefile.config current: ead.o ear.o eadsr.o dist.o tabreadmix.o xfm.o qmult.o qnorm.o \ cheby.o abs.o ramp.o dwt.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 + junction.o fdn.o window.o clean: diff --git a/modules/cheby.c b/modules/cheby.c index 2c32d68..6774028 100644 --- a/modules/cheby.c +++ b/modules/cheby.c @@ -1,5 +1,5 @@ /* - * cheby.c - chebychev polynomial evaluation + * cheby.c - chebyshev polynomial evaluation * Copyright (c) 2000-2003 by Tom Schouten * * This program is free software; you can redistribute it and/or modify diff --git a/modules/fdn.c b/modules/fdn.c index 7842508..22fcc40 100644 --- a/modules/fdn.c +++ b/modules/fdn.c @@ -30,6 +30,7 @@ check filtering code #include "extlib_util.h" #include #include +#include #define FDN_MIN_DECAY_TIME .01f diff --git a/modules/window.c b/modules/window.c new file mode 100644 index 0000000..777c8c5 --- /dev/null +++ b/modules/window.c @@ -0,0 +1,168 @@ +/* + * window.c - window generation abstraction + * Copyright (c) 2000-2003 by Tom Schouten + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "m_pd.h" +#include +#include + + +static t_class *window_class; + +typedef struct _window +{ + t_object x_obj; + t_float x_f; + t_float *x_window; + t_int x_size; + t_symbol *x_type; + t_float x_typearg; + +} t_window; + +static t_int *window_perform(t_int *w) +{ + t_window *x = (t_window *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + t_float *window = x->x_window; + int n = (int)(w[4]); + while (n--) + { + *out++ = (*in++) * (*window++); + } + return (w+5); +} + +static void window_size(t_window *x, t_int n) +{ + if (x->x_size != n){ + if (x->x_window) free(x->x_window); + x->x_window = malloc(sizeof(float)*n); + x->x_size = n; + } +} + + +static void window_type(t_window *x, t_symbol *s, t_float f) +{ + int i; + float a = 0; + float a_inc = 2 * M_PI / (float)(x->x_size); + if (!s) s = gensym("hamming"); + if (s == gensym("hamming")){ + for (i=0; ix_size; i++){ + float c = cos(a); + x->x_window[i] = (0.54 - 0.46 * c); + a += a_inc; + } + } + else if (s == gensym("hann")){ + for (i=0; ix_size; i++){ + float c = cos(a); + x->x_window[i] = (0.5 - 0.5 * c); + a += a_inc; + } + } + else if (s == gensym("hann/hamming")){ + for (i=0; ix_size; i++) { + float c = cos(a); + x->x_window[i] = (0.5 - 0.5 * c) / (0.54 - 0.46 * c); + a += a_inc; + } + } + else if (s == gensym("bfft_pink")){ + x->x_window[0] = 1.0f; //DC + x->x_window[1] = 1.0f / sqrt((double)(x->x_size>>1)); //NY + for (i=2; ix_size; i+=2) { + double freq = (double)(i>>1); + float amp = sqrt(1.0 / freq); + x->x_window[i] = amp; + x->x_window[i+1] = amp; + } + } + else if (s == gensym("bfft_blue")){ + x->x_window[0] = 1.0f; //DC + x->x_window[1] = sqrt((double)(x->x_size>>1)); //NY + for (i=2; ix_size; i+=2) { + double freq = (double)(i>>1); + float amp = sqrt(freq); + x->x_window[i] = amp; + x->x_window[i+1] = amp; + } + } + else if (s == gensym("bfft_db/octave")){ + float power = f/6.0; + x->x_window[0] = 1.0f; //DC + x->x_window[1] = pow((double)(x->x_size>>1), power); //NY + for (i=2; ix_size; i+=2) { + double freq = (double)(i>>1); + float amp = pow(freq, power); + x->x_window[i] = amp; + x->x_window[i+1] = amp; + } + } + + + /* default is no window */ + else{ + post("bwin~: unknown window type, using rectangular"); + for (i=0; ix_size; i++) x->x_window[i] = 1.0f; + } + + x->x_type = s; + x->x_typearg = f; + +} + +static void window_dsp(t_window *x, t_signal **sp) +{ + int n = sp[0]->s_n; + if (x->x_size != n){ + window_size(x, n); + window_type(x, x->x_type, x->x_typearg); + } + + dsp_add(window_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, n); +} + +static void window_free(t_window *x) +{ + free(x->x_window); +} + + +static void *window_new(t_symbol *s) +{ + t_window *x = (t_window *)pd_new(window_class); + outlet_new(&x->x_obj, &s_signal); + x->x_window = 0; + window_size(x, 64); + window_type(x, s, 0); + return (x); +} + +void window_tilde_setup(void) +{ + window_class = class_new(gensym("bwin~"), (t_newmethod)window_new, (t_method)window_free, + sizeof(t_window), 0, A_DEFSYMBOL, A_NULL); + CLASS_MAINSIGNALIN(window_class, t_window, x_f); + class_addmethod(window_class, (t_method)window_dsp, gensym("dsp"), A_NULL); + class_addmethod(window_class, (t_method)window_type, gensym("type"), A_SYMBOL, A_DEFFLOAT, A_NULL); +} + diff --git a/system/setup.c b/system/setup.c index 7274349..396fcec 100644 --- a/system/setup.c +++ b/system/setup.c @@ -27,6 +27,7 @@ void ffpoly_setup(void); void fwarp_setup(void); void junction_tilde_setup(void); void fdn_tilde_setup(void); +void window_tilde_setup(void); void creb_setup(void) { @@ -54,6 +55,7 @@ void creb_setup(void) lattice_tilde_setup(); junction_tilde_setup(); fdn_tilde_setup(); + window_tilde_setup(); /* setup other objects */ ratio_setup(); -- cgit v1.2.1