From 81d751e8824f6a9b3975c1da517d1d163a2eace5 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sat, 20 Sep 2003 00:05:08 +0000 Subject: *** empty log message *** svn path=/trunk/externals/tb/; revision=1012 --- tbext/bufline~.pd | 56 ++++++++++ tbext/config-pd-linux.txt | 6 +- tbext/make-files.txt | 6 +- tbext/makefile.pd-linux | 2 +- tbext/reverse.pd | 49 +++++++++ tbext/shuf.pd | 49 +++++++++ tbext/sort.pd | 51 ++++++++++ tbext/source/fftbuf.cpp | 247 +++++++++++++++++++++++++++++++++++++++++++++ tbext/source/fftgrrev.cpp | 165 ++++++++++++++++++++++++++++++ tbext/source/fftgrshuf.cpp | 161 +++++++++++++++++++++++++++++ tbext/source/fftgrsort.cpp | 176 ++++++++++++++++++++++++++++++++ tbext/source/main.cpp | 1 + tbext/source/tbfft2.cpp | 147 +++++++++++++++++++++++++++ tbext/tbfft1.pd | 44 ++++++++ tbext/tbfft2.pd | 50 +++++++++ 15 files changed, 1203 insertions(+), 7 deletions(-) create mode 100644 tbext/bufline~.pd create mode 100644 tbext/reverse.pd create mode 100644 tbext/shuf.pd create mode 100644 tbext/sort.pd create mode 100644 tbext/source/fftbuf.cpp create mode 100644 tbext/source/fftgrrev.cpp create mode 100644 tbext/source/fftgrshuf.cpp create mode 100644 tbext/source/fftgrsort.cpp create mode 100644 tbext/source/tbfft2.cpp create mode 100644 tbext/tbfft1.pd create mode 100644 tbext/tbfft2.pd (limited to 'tbext') diff --git a/tbext/bufline~.pd b/tbext/bufline~.pd new file mode 100644 index 0000000..7fd7d59 --- /dev/null +++ b/tbext/bufline~.pd @@ -0,0 +1,56 @@ +#N canvas 221 141 714 505 10; +#N canvas 0 0 450 300 graph1 0; +#X array from1 64 float 1; +#A 0 0 0 0 0 0 0 0.0285714 0.0357143 0.0428571 0.0714286 0.0857143 +0.114286 0.128571 0.142857 0.142857 0.157143 0.171429 0.185714 0.2 +0.214286 0.242857 0.242857 0.242857 0.242857 0.242857 0.214286 0.2 +0.15 0.0714286 0.0714286 1.86265e-09 -0.0142857 -0.0285714 0 0 0 0 +0 0 0 0 -0.0142857 -0.0285714 -0.0428571 -0.0571429 -0.0571429 -0.0571429 +-0.0571429 -0.0571429 -0.0571429 -0.0571429 0.00714286 0.0714286 0.142857 +0.242857 0.314286 0.457143 0 0 0 0 0 0 0; +#X coords 0 1 63 -1 200 140 1; +#X restore 80 20 graph; +#X obj 607 14 block~ 128; +#N canvas 0 0 450 300 graph1 0; +#X array from2 64 float 1; +#A 0 0 0 0 0 0 0 0 0 0 0.0285714 0.0571429 0.0761905 0.0952381 0.114286 +0.12381 0.133333 0.142857 0.2 0.207143 0.228571 0.228571 0.257143 0.257143 +0.257143 0.242857 -0.0142857 0 0 0 0 0 0 0 0 0 -0.471429 -0.628572 +-0.685714 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; +#X coords 0 1 63 -1 200 140 1; +#X restore 335 23 graph; +#N canvas 0 0 450 300 graph1 0; +#X array to 64 float 1; +#A 0 0 0 0 0 0 0 0.00682475 0.00853045 0.0102368 0.0388103 0.0639679 +0.0852809 0.10321 0.121109 0.128353 0.139015 0.149682 0.196567 0.205455 +0.225179 0.232002 0.253755 0.253755 0.253755 0.242854 0.0403107 0.047774 +0.0358276 0.0170609 0.0170609 4.44924e-10 -0.00341237 -0.00682475 0 +0 -0.35882 -0.478471 -0.521873 0 0 0 -0.00341233 -0.00682466 -0.0102368 +-0.0136493 -0.0136493 -0.0136493 -0.0136493 -0.0136493 -0.0136493 -0.0136493 +0.00170617 0.0170609 0.0341218 0.0580107 0.0750683 0.109195 0 0 0 0 +0 0 0; +#X coords 0 1 63 -1 200 140 1; +#X restore 456 301 graph; +#X obj 144 412 tabwrite~ to; +#X obj 208 373 metro 50; +#X obj 208 349 loadbang; +#X obj 83 280 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 212 269 set from1; +#X msg 212 292 set from2; +#X msg 133 271 line 5000; +#X obj 63 385 print~; +#X obj 26 332 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 88 321 bufline~ 128; +#X msg 119 239 line 400; +#X connect 5 0 4 0; +#X connect 6 0 5 0; +#X connect 7 0 13 0; +#X connect 8 0 13 0; +#X connect 9 0 13 0; +#X connect 10 0 13 0; +#X connect 12 0 11 0; +#X connect 13 0 11 0; +#X connect 13 0 4 0; +#X connect 14 0 13 0; diff --git a/tbext/config-pd-linux.txt b/tbext/config-pd-linux.txt index e1fa248..495aad9 100755 --- a/tbext/config-pd-linux.txt +++ b/tbext/config-pd-linux.txt @@ -1,7 +1,7 @@ # config file for tbext, adapted from Thomas Grill's xsample makefile # your c++ compiler (if not g++) - CXX=icc +# CXX=icc # where does the PD installation reside? @@ -10,7 +10,7 @@ PD=/usr/lib/pd # where are the PD header files? # leave it blank if it is a system directory (like /usr/local/include), # since gcc 3.2 complains about it -PDINC=/home/tim/pd/devel_0_36/pd/src +PDINC=/home/tim/pd/pd-0.37-0/src # where do the flext libraries reside? FLEXTPATH=/usr/lib/flext @@ -28,7 +28,7 @@ HELPDIR=${PD}/doc/5.reference # additional compiler flags # (check whether they fit to your system!) -UFLAGS=-xW -tpp7 -ip -ipo_obj -g # icc +#UFLAGS=-xW -tpp7 -ip -ipo_obj -g # icc # UFLAGS=-mcpu=pentium4 -mmmx -msse2 -msse -mfpmath=sse # gcc 3.2 # define to link against shared flext library (flext version >= 0.5.0) diff --git a/tbext/make-files.txt b/tbext/make-files.txt index 273787a..e299154 100755 --- a/tbext/make-files.txt +++ b/tbext/make-files.txt @@ -1,9 +1,9 @@ # all the source files from the package SRCDIR = source SRCS= \ - main.cpp tbroute.cpp tbsig~.cpp tbsroute~.cpp tbpow~.cpp \ - tbfft1.cpp tbfft2.cpp fftbuf.cpp fftgrsort.cpp fftgrshuf.cpp \ - fftgrrev.cpp # tbg7xx.cpp tbstrg.cpp + main.cpp tbroute.cpp tbsig~.cpp tbsroute~.cpp tbssel~.cpp \ + tbpow~.cpp tbfft1.cpp tbfft2.cpp fftbuf.cpp fftgrsort.cpp \ + fftgrshuf.cpp fftgrrev.cpp # tbg7xx.cpp tbstrg.cpp #HDRS= \ diff --git a/tbext/makefile.pd-linux b/tbext/makefile.pd-linux index 25b7f3b..7948a19 100644 --- a/tbext/makefile.pd-linux +++ b/tbext/makefile.pd-linux @@ -17,7 +17,7 @@ FLEXTLIB=$(FLEXTPATH)/flext.a # compiler stuff INCLUDES=$(PDINC) FLAGS=-DFLEXT_SYS=2 -CFLAGS=${UFLAGS} -O3 -I/usr/lib/flext -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions -fno-rtti -fno-exceptions +CFLAGS=${UFLAGS} -O3 -I/home/tim/pd/externals/grill/flext/source -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions -fno-rtti -fno-exceptions LIBS=m ifdef FLEXT_SHARED diff --git a/tbext/reverse.pd b/tbext/reverse.pd new file mode 100644 index 0000000..34ac6d4 --- /dev/null +++ b/tbext/reverse.pd @@ -0,0 +1,49 @@ +#N canvas 245 106 453 369 10; +#N canvas 0 0 450 300 graph2 0; +#X array array1 63 float 1; +#A 0 0 0 0 0 0 0 0 0 -0.0142857 -0.0428571 -0.0714286 -0.0857143 -0.128571 +-0.214286 -0.285714 -0.357143 -0.4 -0.428571 -0.428571 -0.428571 -0.428571 +-0.428571 -0.414286 -0.414286 -0.4 -0.371429 -0.328571 -0.328571 -0.314286 +-0.3 -0.271429 -0.242857 -0.228571 -0.214286 -0.157143 -0.128571 -0.0714286 +-0.0571429 -0.0285715 0.0571428 0.1 0.128571 0.135714 0.142857 0.171429 +0.214286 0.228571 0.242857 0.271429 0.271429 0.3 0.3 -0.0571429 -0.0857143 +0.0214285 0.0285714 0.0571428 0.0714285 0.0714285 0.057143 0.0428573 +0.0428573 0; +#X coords 0 1 62 -1 200 140 1; +#X restore -67 3 graph; +#N canvas 0 0 450 300 graph3 0; +#X array array2 64 float 1; +#A 0 0 0 0 0 0 0 0 0 -0.0142857 -0.0428571 -0.0714286 -0.0857143 -0.128571 +-0.214286 -0.285714 -0.357143 -0.4 -0.428571 -0.428571 -0.428571 -0.428571 +-0.414286 -0.428571 -0.4 -0.414286 -0.328571 -0.371429 -0.314286 -0.328571 +-0.271429 -0.3 -0.228571 -0.242857 -0.157143 -0.214286 -0.0714286 -0.128571 +-0.0285715 -0.0571429 0.1 0.0571428 0.135714 0.128571 0.3 0.3 0.271429 +0.271429 0.242857 0.228571 0.214286 0.171429 0.142857 0.0714285 0.0714285 +0.057143 0.0571428 0.0428573 0.0428573 0.0285714 0.0214285 0 0 0 -0.0571429 +; +#X coords 0 1 63 -1 200 140 1; +#X restore 159 1 graph; +#X obj 30 234 tabplay~ array1; +#X obj -28 270 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 30 323 tabwrite~ array2; +#X floatatom 229 240 5 0 0 0 - - -; +#X obj -68 307 metro 50; +#X obj -81 275 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 267 183 block~ 128; +#X msg 229 259 grains \$1; +#X obj 209 291 hsl 128 15 -64 64 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 0 1; +#X msg 206 315 offset \$1; +#X obj 29 276 fftgrrev~ 128; +#X connect 2 0 12 0; +#X connect 3 0 2 0; +#X connect 3 0 4 0; +#X connect 5 0 9 0; +#X connect 6 0 3 0; +#X connect 7 0 6 0; +#X connect 9 0 12 0; +#X connect 10 0 11 0; +#X connect 11 0 12 0; +#X connect 12 0 4 0; diff --git a/tbext/shuf.pd b/tbext/shuf.pd new file mode 100644 index 0000000..1144ffe --- /dev/null +++ b/tbext/shuf.pd @@ -0,0 +1,49 @@ +#N canvas 245 106 453 369 10; +#N canvas 0 0 450 300 graph2 0; +#X array array1 63 float 1; +#A 0 0 0 0 0 0 0 0 0 -0.0142857 -0.0428571 -0.0714286 -0.0857143 -0.128571 +-0.214286 -0.285714 -0.357143 -0.4 -0.428571 -0.428571 -0.428571 -0.428571 +-0.428571 -0.414286 -0.414286 -0.4 -0.371429 -0.328571 -0.328571 -0.314286 +-0.3 -0.271429 -0.242857 -0.228571 -0.214286 -0.157143 -0.128571 -0.0714286 +-0.0571429 -0.0285715 0.0571428 0.1 0.128571 0.135714 0.142857 0.171429 +0.214286 0.228571 0.242857 0.271429 0.271429 0.3 0.3 -0.0571429 -0.0857143 +0.0214285 0.0285714 0.0571428 0.0714285 0.0714285 0.057143 0.0428573 +0.0428573 0; +#X coords 0 1 62 -1 200 140 1; +#X restore -67 3 graph; +#N canvas 0 0 450 300 graph3 0; +#X array array2 64 float 1; +#A 0 0 0.0214285 -0.371429 -0.0571429 -0.0857143 0.128571 0.0571428 +0.0285714 0 0.0714285 -0.314286 0.0571428 -0.128571 -0.428571 -0.214286 +0.1 -0.328571 -0.271429 -0.428571 0 0.142857 -0.157143 0.228571 0 -0.128571 +-0.428571 0 -0.228571 0 0.0428573 0 -0.0714286 -0.428571 -0.414286 +0.271429 0.057143 -0.328571 0.0714285 -0.0285715 -0.428571 -0.0142857 +-0.242857 -0.285714 -0.0714286 0.242857 -0.4 -0.3 -0.0857143 0.3 0.214286 +-0.0428571 -0.414286 0.135714 0.3 -0.214286 -0.357143 -0.0571429 0 +0 0.171429 0 0.0428573 0.271429 -0.4; +#X coords 0 1 63 -1 200 140 1; +#X restore 159 1 graph; +#X obj 30 234 tabplay~ array1; +#X obj -28 270 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 30 323 tabwrite~ array2; +#X floatatom 229 240 5 0 0 0 - - -; +#X obj -68 307 metro 50; +#X obj -81 275 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 267 183 block~ 128; +#X msg 229 259 grains \$1; +#X obj 209 291 hsl 128 15 -64 64 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 0 1; +#X msg 206 315 offset \$1; +#X obj 29 276 fftgrshuf~ 128; +#X connect 2 0 12 0; +#X connect 3 0 2 0; +#X connect 3 0 4 0; +#X connect 5 0 9 0; +#X connect 6 0 3 0; +#X connect 7 0 6 0; +#X connect 9 0 12 0; +#X connect 10 0 11 0; +#X connect 11 0 12 0; +#X connect 12 0 4 0; diff --git a/tbext/sort.pd b/tbext/sort.pd new file mode 100644 index 0000000..482cf31 --- /dev/null +++ b/tbext/sort.pd @@ -0,0 +1,51 @@ +#N canvas 245 106 453 369 10; +#N canvas 0 0 450 300 graph2 0; +#X array array1 63 float 1; +#A 0 0 0 0 0 0 0 0 0 -0.0142857 -0.0428571 -0.0714286 -0.0857143 -0.128571 +-0.214286 -0.285714 -0.357143 -0.4 -0.428571 -0.428571 -0.428571 -0.428571 +-0.428571 -0.414286 -0.414286 -0.4 -0.371429 -0.328571 -0.328571 -0.314286 +-0.3 -0.271429 -0.242857 -0.228571 -0.214286 -0.157143 -0.128571 -0.0714286 +-0.0571429 -0.0285715 0.0571428 0.1 0.128571 0.135714 0.142857 0.171429 +0.214286 0.228571 0.242857 0.271429 0.271429 0.3 0.3 -0.0571429 -0.0857143 +0.0214285 0.0285714 0.0571428 0.0714285 0.0714285 0.057143 0.0428573 +0.0428573 0; +#X coords 0 1 62 -1 200 140 1; +#X restore -67 3 graph; +#N canvas 0 0 450 300 graph3 0; +#X array array2 64 float 1; +#A 0 0 0 0 0 0 0 0 0 -0.0142857 -0.0428571 -0.0714286 -0.0857143 -0.128571 +-0.214286 -0.285714 -0.357143 -0.4 -0.428571 -0.428571 -0.428571 -0.428571 +-0.414286 -0.428571 -0.4 -0.414286 -0.328571 -0.371429 -0.314286 -0.328571 +-0.271429 -0.3 -0.228571 -0.242857 -0.157143 -0.214286 -0.0714286 -0.128571 +-0.0285715 -0.0571429 0.1 0.0571428 0.135714 0.128571 0.3 0.3 0.271429 +0.271429 0.242857 0.228571 0.214286 0.171429 0.142857 0.0714285 0.0714285 +0.057143 0.0571428 0.0428573 0.0428573 0.0285714 0.0214285 0 0 0 -0.0571429 +; +#X coords 0 1 63 -1 200 140 1; +#X restore 159 1 graph; +#X obj 30 234 tabplay~ array1; +#X obj -28 270 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 30 323 tabwrite~ array2; +#X floatatom 229 240 5 0 0 0 - - -; +#X obj -68 307 metro 50; +#X obj -81 275 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 267 183 block~ 128; +#X msg 229 259 grains \$1; +#X obj 209 291 hsl 128 15 -64 64 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 6300 1; +#X msg 206 315 offset \$1; +#X obj 29 276 fftgrsort~ 128; +#X msg 168 203 reverse; +#X connect 2 0 12 0; +#X connect 3 0 2 0; +#X connect 3 0 4 0; +#X connect 5 0 9 0; +#X connect 6 0 3 0; +#X connect 7 0 6 0; +#X connect 9 0 12 0; +#X connect 10 0 11 0; +#X connect 11 0 12 0; +#X connect 12 0 4 0; +#X connect 13 0 12 0; diff --git a/tbext/source/fftbuf.cpp b/tbext/source/fftbuf.cpp new file mode 100644 index 0000000..eff81e3 --- /dev/null +++ b/tbext/source/fftbuf.cpp @@ -0,0 +1,247 @@ +/* Copyright (c) 2003 Tim Blechmann. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "COPYING" in this distribution. */ +/* */ +/* */ +/* fftbuf~ fades between two buffers. it is intended to be used as fft */ +/* synthesis tool... */ +/* */ +/* */ +/* fftbuf~ uses the flext C++ layer for Max/MSP and PD externals. */ +/* get it at http://www.parasitaere-kapazitaeten.de/PD/ext */ +/* thanks to Thomas Grill */ +/* */ +/* */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* */ +/* */ +/* coded while listening to: Jérôme Noetinger/ErikM: What a Wonderful World */ +/* Cosmos: Tears */ +/* Burkhard Stangl/Dieb13: eh */ +/* */ + + + +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error upgrade your flext version!!!!!! +#endif + + +class fftbuf: public flext_dsp +{ + FLEXT_HEADER(fftbuf,flext_dsp); + +public: // constructor + + fftbuf(int); + ~fftbuf(); + +protected: + virtual void m_signal (int n, float *const *in, float *const *out); + bool check(buffer *); + + + void set_buf(int argc, t_atom *argv); //selects a new buffer + void set_line(int argc, t_atom *argv); //sets the time for the transformance + + template + void clear(T *); //destroys an object + + void perform(); //starts transformation + + int blknumber(); //number of blocks that a performance needs + +private: + FLEXT_CALLBACK_V(set_buf); + FLEXT_CALLBACK_V(set_line); + FLEXT_CALLBACK(perform); + + float *ins; + float *outs; + + t_symbol * bufname; + buffer * buf; + + int delay; //delay for fading from local buffer to new one + t_sample * data; // pointer to array of samples + t_sample * offset; // pointer to array of samples + + int bs; //blocksize+1 + int sr; //samplerate + int counter; +}; + + +FLEXT_LIB_DSP_1("bufline~",fftbuf,int); + +fftbuf::fftbuf(int arg): + buf(NULL),data(NULL),sr(Samplerate()),delay(0),counter(0) +{ + bs=arg+1; + AddInAnything(); + AddOutSignal(); + FLEXT_ADDMETHOD_(0,"set",set_buf); + FLEXT_ADDMETHOD_(0,"line",set_line); + FLEXT_ADDBANG(0,perform); + + + data= new t_sample[bs]; + offset= new t_sample[bs]; + ZeroSamples(data,bs); + ZeroSamples(offset,bs); +} + + +fftbuf::~fftbuf() +{ + delete data; + delete offset; +} + + +void fftbuf::m_signal(int n, t_float *const *in, t_float *const *out) +{ + outs = out[0]; + + if (counter!=0) + { + n=n/2+1; + while (--n) + data[n] = data[n] - offset[n]; + + + /* for(int i=0;i!=bs;++i) + { + data[i] = data[i] - offset[i]; + } + */ + + --counter; + } + + CopySamples(out[0],data,bs); +} + +void fftbuf::perform() +{ + counter=blknumber(); + if (counter) + { + for(int i=0;i!=bs;++i) + { + offset[i]=(data[i]-*(buf->Data()+i))/counter; + } + + } + else + { + CopySamples(data,buf->Data(),bs); + } +} + +void fftbuf::set_buf(int argc, t_atom *argv) +{ + if(argc == 0) + { + post("No buffer selected!!!"); + return; + } + if (argc == 1 && IsSymbol(argv[0])) + { + clear(buf); + bufname=GetSymbol(argv[0]); + + buf= new buffer(bufname); + + if(!buf->Ok()) + { + post("buffer %s is currently not valid",bufname); + } + } + else if ((argc == 2 && IsSymbol(argv[0]) && + (IsInt(argv[1]) || IsFloat(argv[1])))) + { + clear(buf); + bufname=GetSymbol(argv[0]); + + buf= new buffer(bufname); + + if(!buf->Ok()) + { + post("buffer %s is currently not valid",bufname); + return; + } + delay=GetInt(argv[1]); + } +} + +template +/*inline*/ void fftbuf::clear(T* buf) +{ + if (buf) + { + delete buf; + buf=NULL; + } +} + +inline bool fftbuf::check(buffer * buf) +{ +//code taken from the flext tutorial (buffer 1) by thomas grill + + if(buf->Update()) + { + // buffer parameters have been updated + if(buf->Valid()) + { + post("%s (%s) - updated buffer reference", + thisName(),GetString(thisTag())); + return true; + } + else + { + post("%s (%s) - buffer has become invalid", + thisName(),GetString(thisTag())); + return false; + } + } + else + return true; +} + +void fftbuf::set_line(int argc, t_atom *argv) +{ + if(argc==1 && (IsInt(argv[0]) || IsFloat(argv[0]))) + { + delay=GetInt(argv[0]); + } + else + post("syntax incorrect"); +} + +inline int fftbuf::blknumber() +{ + // post("%i %i %i",delay,bs,sr); + // post("computer counter: %i",delay*bs/sr*1000); + return delay*bs/sr*1000; //ms/sample +} diff --git a/tbext/source/fftgrrev.cpp b/tbext/source/fftgrrev.cpp new file mode 100644 index 0000000..e26135c --- /dev/null +++ b/tbext/source/fftgrrev.cpp @@ -0,0 +1,165 @@ +/* Copyright (c) 2003 Tim Blechmann. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "COPYING" in this distribution. */ +/* */ +/* */ +/* fftgrshuf divides the incoming fft signal into single grains and reverses */ +/* the samples in every grain */ +/* */ +/* fftgrrev uses the flext C++ layer for Max/MSP and PD externals. */ +/* get it at http://www.parasitaere-kapazitaeten.de/PD/ext */ +/* thanks to Thomas Grill */ +/* */ +/* */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* */ +/* */ +/* coded while listening to: Howard Skempton/John Tilbury: Well, well, Cornelius*/ +/* */ +/* */ + + + +#include +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error upgrade your flext version!!!!!! +#endif + +class fftgrrev: public flext_dsp +{ + FLEXT_HEADER(fftgrrev,flext_dsp); + +public: // constructor + fftgrrev(int); + +protected: + virtual void m_signal (int n, float *const *in, float *const *out); + void set_grains(t_int); + void set_offset(t_int); + void set_reverse(); + +private: + FLEXT_CALLBACK_1(set_grains,t_int) + FLEXT_CALLBACK_1(set_offset,t_int) + + t_int grains; + t_int grainsize; + t_int offset; + + t_int bs; //blocksize + t_int bs1; //bs+1 + t_int counter; + + t_sample * data; //array with data + t_sample * d1; //1. element in array with data + t_sample * dend; //1 element after the last element + + t_sample * ins; + t_sample * outs; + + bool reverse; + +}; + + +FLEXT_LIB_DSP_1("fftgrrev~",fftgrrev,int) + +fftgrrev::fftgrrev(int arg): + grains(1),offset(0),counter(1) +{ + bs=arg/2; + grainsize=bs; + bs1=bs+1; + post("blocksize: %i",bs); + + data = new t_sample[bs+1]; + + data[0]=0; + d1=data+1; + dend=data+bs+1; + + AddInSignal(); + AddOutSignal(); + FLEXT_ADDMETHOD_I(0,"grains",set_grains); + FLEXT_ADDMETHOD_I(0,"offset",set_offset); +} + +void fftgrrev::m_signal(int n, t_float * const *in, t_float *const *out) +{ + ins = in[0]; + outs = out[0]; + + + if (offset>0) + { + CopySamples(d1+bs-offset,ins,offset); + CopySamples(d1,ins+offset,bs-offset); + } + else if (offset<0) + { + CopySamples(d1-offset,ins,bs+offset); + CopySamples(d1,ins+bs+offset,-offset); + } + else + CopySamples(data,ins,bs1); + + + //grains + + counter=1; + + while (counter!=grains) + { + std::reverse(d1+grainsize*(counter-1),d1+grainsize*counter); + ++counter; + } + + std::reverse(d1+grainsize*(counter-1),dend); + + CopySamples(outs,data,bs1); +} + +void fftgrrev::set_offset(t_int o) +{ + if (o-bs<0 && o+bs>0) + { + offset=-o; + post("offset %i",o); + } + else + post("Offset out of range!"); +} + + +void fftgrrev::set_grains(t_int g) +{ + if ( (g > 0) ) + { + grains=g; + grainsize=(bs)/grains; + } +} + + + + diff --git a/tbext/source/fftgrshuf.cpp b/tbext/source/fftgrshuf.cpp new file mode 100644 index 0000000..b490dcf --- /dev/null +++ b/tbext/source/fftgrshuf.cpp @@ -0,0 +1,161 @@ +/* Copyright (c) 2003 Tim Blechmann. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "COPYING" in this distribution. */ +/* */ +/* */ +/* fftgrshuf divides the incoming fft signal into single grains and */ +/* random_shuffles the samples in every grain */ +/* */ +/* fftgrshuf uses the flext C++ layer for Max/MSP and PD externals. */ +/* get it at http://www.parasitaere-kapazitaeten.de/PD/ext */ +/* thanks to Thomas Grill */ +/* */ +/* */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* */ +/* */ +/* coded while listening to: New York Underground Orchestra: The Labyrinth */ +/* */ +/* */ + + + +#include +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error upgrade your flext version!!!!!! +#endif + +class fftgrshuf: public flext_dsp +{ + FLEXT_HEADER(fftgrshuf,flext_dsp); + +public: // constructor + fftgrshuf(int); + +protected: + virtual void m_signal (int n, float *const *in, float *const *out); + void set_grains(t_int); + void set_offset(t_int); + +private: + FLEXT_CALLBACK_1(set_grains,t_int) + FLEXT_CALLBACK_1(set_offset,t_int) + + t_int grains; + t_int grainsize; + t_int offset; + + t_int bs; //blocksize + t_int bs1; //bs+1 + t_int counter; + + t_sample * data; //array with data + t_sample * d1; //1. element in array with data + t_sample * dend; //1 element after the last element + + t_sample * ins; + t_sample * outs; + + +}; + + +FLEXT_LIB_DSP_1("fftgrshuf~",fftgrshuf,int) + +fftgrshuf::fftgrshuf(int arg): + grains(1),offset(0),counter(1) +{ + bs=arg/2; + grainsize=bs; + bs1=bs+1; + post("blocksize: %i",bs); + + data = new t_sample[bs+1]; + + data[0]=0; + d1=data+1; + dend=data+bs+1; + + AddInSignal(); + AddOutSignal(); + FLEXT_ADDMETHOD_I(0,"grains",set_grains); + FLEXT_ADDMETHOD_I(0,"offset",set_offset); +} + +void fftgrshuf::m_signal(int n, t_float * const *in, t_float *const *out) +{ + ins = in[0]; + outs = out[0]; + + + if (offset>0) + { + CopySamples(d1+bs-offset,ins,offset); + CopySamples(d1,ins+offset,bs-offset); + } + else if (offset<0) + { + CopySamples(d1-offset,ins,bs+offset); + CopySamples(d1,ins+bs+offset,-offset); + } + else + CopySamples(data,ins,bs1); + + + //grains + + counter=1; + + while (counter!=grains) + { + std::random_shuffle(d1+grainsize*(counter-1),d1+grainsize*counter); + ++counter; + } + + std::random_shuffle(d1+grainsize*(counter-1),dend); + + + CopySamples(outs,data,bs1); +} + +void fftgrshuf::set_offset(t_int o) +{ + if (o-bs<0 && o+bs>0) + { + offset=o; + post("offset %i",-o); + } + else + post("offset out of range!"); +} + + +void fftgrshuf::set_grains(t_int g) +{ + if ( (g > 0) ) + { + grains=g; + grainsize=(bs)/grains; + } +} + diff --git a/tbext/source/fftgrsort.cpp b/tbext/source/fftgrsort.cpp new file mode 100644 index 0000000..f24ed0f --- /dev/null +++ b/tbext/source/fftgrsort.cpp @@ -0,0 +1,176 @@ +/* Copyright (c) 2003 Tim Blechmann. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "COPYING" in this distribution. */ +/* */ +/* */ +/* fftgrsort divides the incoming fft signal into single grains and sorts the */ +/* samples in every grain */ +/* */ +/* fftgrsort uses the flext C++ layer for Max/MSP and PD externals. */ +/* get it at http://www.parasitaere-kapazitaeten.de/PD/ext */ +/* thanks to Thomas Grill */ +/* */ +/* */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* */ +/* */ +/* coded while listening to: William Parker: Posium Pendasem */ +/* Rowe/Lehn/Schmickler: Rabbit Run */ +/* Derek Bailey: Ballads */ +/* */ + + + +#include +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error upgrade your flext version!!!!!! +#endif + +class fftgrsort: public flext_dsp +{ + FLEXT_HEADER(fftgrsort,flext_dsp); + +public: // constructor + fftgrsort(int); + +protected: + virtual void m_signal (int n, float *const *in, float *const *out); + void set_grains(t_int); + void set_offset(t_int); + void set_reverse(); + +private: + FLEXT_CALLBACK_1(set_grains,t_int) + FLEXT_CALLBACK_1(set_offset,t_int) + FLEXT_CALLBACK(set_reverse) + + t_int grains; + t_int grainsize; + t_int offset; + + t_int bs; //blocksize + t_int bs1; //bs+1 + t_int counter; + + t_sample * data; //array with data + t_sample * d1; //1. element in array with data + t_sample * dend; //1 element after the last element + + t_sample * ins; + t_sample * outs; + + bool reverse; + +}; + + +FLEXT_LIB_DSP_1("fftgrsort~",fftgrsort,int) + +fftgrsort::fftgrsort(int arg): + grains(1),offset(0),counter(1),reverse(0) +{ + bs=arg/2; + grainsize=bs; + bs1=bs+1; + post("blocksize: %i",bs); + + data = new t_sample[bs+1]; + + data[0]=0; + d1=data+1; + dend=data+bs+1; + + AddInSignal(); + AddOutSignal(); + FLEXT_ADDMETHOD_I(0,"grains",set_grains); + FLEXT_ADDMETHOD_I(0,"offset",set_offset); + FLEXT_ADDMETHOD_(0,"reverse",set_reverse); +} + +void fftgrsort::m_signal(int n, t_float * const *in, t_float *const *out) +{ + ins = in[0]; + outs = out[0]; + + + if (offset>0) + { + CopySamples(d1+bs-offset,ins,offset); + CopySamples(d1,ins+offset,bs-offset); + } + else if (offset<0) + { + CopySamples(d1-offset,ins,bs+offset); + CopySamples(d1,ins+bs+offset,-offset); + } + else + CopySamples(data,ins,bs1); + + + //grains + + counter=1; + + while (counter!=grains) + { + std::sort(d1+grainsize*(counter-1),d1+grainsize*counter); + if (reverse) + std::reverse(d1+grainsize*(counter-1),d1+grainsize*counter); + ++counter; + } + + std::sort(d1+grainsize*(counter-1),dend); + if (reverse) + std::reverse(d1+grainsize*(counter-1),dend); + + + CopySamples(outs,data,bs1); +} + +void fftgrsort::set_offset(t_int o) +{ + if (o-bs<0 && o+bs>0) + { + offset=-o; + post("offset %i",o); + } + else + post("offset out of range!"); +} + + +void fftgrsort::set_grains(t_int g) +{ + if ( (g > 0) ) + { + grains=g; + grainsize=(bs)/grains; + } +} + +void fftgrsort::set_reverse() +{ + reverse=!reverse; +} + + diff --git a/tbext/source/main.cpp b/tbext/source/main.cpp index bd6d833..4b204f6 100644 --- a/tbext/source/main.cpp +++ b/tbext/source/main.cpp @@ -56,6 +56,7 @@ void ttbext_setup() FLEXT_SETUP(tbroute); //FLEXT_SETUP(tbstrg); FLEXT_DSP_SETUP(tbsroute); + FLEXT_DSP_SETUP(tbssel); FLEXT_DSP_SETUP(tbsig); FLEXT_DSP_SETUP(tbpow); // FLEXT_DSP_SETUP(tbg7xx); diff --git a/tbext/source/tbfft2.cpp b/tbext/source/tbfft2.cpp new file mode 100644 index 0000000..6ed71d9 --- /dev/null +++ b/tbext/source/tbfft2.cpp @@ -0,0 +1,147 @@ +/* Copyright (c) 2003 Tim Blechmann. */ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */ +/* WARRANTIES, see the file, "COPYING" in this distribution. */ +/* */ +/* */ +/* tbfft2~ transforms the fft spectrum. it reverses the order of the samples in */ +/* the fft spectrum. see the help file for further instruction... */ +/* */ +/* */ +/* tbfft2~ uses the flext C++ layer for Max/MSP and PD externals. */ +/* get it at http://www.parasitaere-kapazitaeten.de/PD/ext */ +/* thanks to Thomas Grill */ +/* */ +/* */ +/* */ +/* 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. */ +/* */ +/* See file LICENSE for further informations on licensing terms. */ +/* */ +/* 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. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* */ +/* */ +/* coded while listening to: Naked City: Heretic, Jeux Des Dames Cruelles */ +/* Bob Ostertag: Attention Span */ +/* */ +/* */ + + + +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error upgrade your flext version!!!!!! +#endif + + +class tbfft2: public flext_dsp +{ + FLEXT_HEADER(tbfft2,flext_dsp); + +public: // constructor + tbfft2(); + +protected: + virtual void m_signal (int n, float *const *in, float *const *out); + void set_freq(t_float); + void set_width(t_float); + +private: + FLEXT_CALLBACK_1(set_freq,t_float) + FLEXT_CALLBACK_1(set_width,t_float) + + t_int center; + t_int width; + + t_float pos; + t_int posi; + + float *ins; + float *outs; + float *tmps; + t_float tmp[2049]; + + t_float s; + t_float b; + + t_int n0; +}; + + +FLEXT_LIB_DSP("tbfft2~",tbfft2) + +tbfft2::tbfft2() +{ + AddInSignal(); + AddOutSignal(); + FLEXT_ADDMETHOD_F(0,"center",set_freq); + FLEXT_ADDMETHOD_F(0,"width",set_width); +} + + +void tbfft2::m_signal(int n, t_float *const *in, t_float *const *out) +{ + ins = in[0]; + outs = out[0]; + + CopySamples(tmp,ins,n); + + n0=n/2; + + if (center-width>0) + { + n=center-width; + } + else + n=0; + + while (nn0) + { + width=n0-center; + return; + } + if (center-w<0) + { + width=center; + return; + } + + width=w; +} + + diff --git a/tbext/tbfft1.pd b/tbext/tbfft1.pd new file mode 100644 index 0000000..c9ced88 --- /dev/null +++ b/tbext/tbfft1.pd @@ -0,0 +1,44 @@ +#N canvas 245 106 453 369 10; +#N canvas 0 0 450 300 graph2 0; +#X array array1 63 float 1; +#A 0 0 0 0 0 0 0 0 0 0 -1 -1.24286 -1.45714 -1.61429 -1.7 -1.82857 +-1.88571 -1.92857 -2.04286 -2.17143 -2.18571 -2.2 -2.21429 -2.27143 +-2.28571 -2.28571 -2.3 -2.31429 -2.31429 -2.32857 -0.528571 -0.528571 +-0.542857 -0.514286 -0.485714 -0.4 -0.357143 -0.314286 -0.185714 -0.114286 +-0.0142857 0.185714 0.214286 0.314286 0.342857 0.4 0.5 0.514286 0.557143 +0.571429 0.628572 0.642857 0.671429 1.14286 0.428572 0.3 0.228572 0.157143 +0.114286 0.057143 0.057143 0.0428573 0.0428573 0; +#X coords 0 1 62 -1 200 140 1; +#X restore -67 3 graph; +#N canvas 0 0 450 300 graph3 0; +#X array array2 64 float 1; +#A 0 0 0 0 0 0 0 0 0 0 -0.4 -0.585 -0.685714 -0.767857 -0.824286 -0.869286 +-0.92 -0.945 -0.154551 -0.309103 -0.445624 -0.567631 -0.678947 -0.786968 +-0.876442 -0.953638 -1.02425 -1.04246 -0.02064 -0.031224 -0.04128 -0.0648 +-0.087 -0.147857 -0.191429 -0.4 -0.357143 -0.314286 -0.185714 -0.114286 +-0.0142857 0.185714 0.214286 0.314286 0.342857 0.4 0.5 0.514286 0.557143 +0.571429 0.628572 0.642857 0.671429 1.14286 0.428572 0.3 0.228572 0.157143 +0.114286 0.057143 0.057143 0.0428573 0.0428573 0 0; +#X coords 0 1 63 -1 200 140 1; +#X restore 159 1 graph; +#X obj -20 153 tabplay~ array1; +#X obj -78 189 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj -20 242 tabwrite~ array2; +#X obj -21 195 tbfft1~; +#X obj 164 152 hsl 128 15 -0.1 0.1 0 0 empty empty empty -2 -6 0 8 +-262144 -1 -1 0 1; +#X obj 150 216 hsl 128 15 0 44100 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 1400 1; +#X msg 161 176 factor \$1; +#X msg 147 235 center \$1; +#X floatatom 272 188 5 0 0 0 - - -; +#X connect 2 0 5 0; +#X connect 3 0 2 0; +#X connect 3 0 4 0; +#X connect 5 0 4 0; +#X connect 6 0 8 0; +#X connect 6 0 10 0; +#X connect 7 0 9 0; +#X connect 8 0 5 0; +#X connect 9 0 5 0; diff --git a/tbext/tbfft2.pd b/tbext/tbfft2.pd new file mode 100644 index 0000000..044b4aa --- /dev/null +++ b/tbext/tbfft2.pd @@ -0,0 +1,50 @@ +#N canvas 245 106 453 369 10; +#N canvas 0 0 450 300 graph2 0; +#X array array1 63 float 1; +#A 0 0 0 0 0 0 0 0.0571429 0.142857 0.171429 0.228571 0.314286 0.385714 +0.457143 0.542857 0.628572 0.714286 0.757143 0.742857 0.714286 0.671429 +0.628571 0.6 0 0 0 0.00714286 0.0142857 0.0142857 0.0142857 0.0142857 +0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 +0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0285714 0.0714286 +0.121429 0.171429 0.192857 0.214286 0.257143 0.328571 0.342857 0.385714 +0.414286 0.442857 1.86265e-09 0.0142857 0.0142857 0.0142857 0.0142857 +0.0142857 0.0142857 0.0142857 0.0142857; +#X coords 0 1 62 -1 200 140 1; +#X restore -67 3 graph; +#N canvas 444 250 450 300 graph3 0; +#X array array2 64 float 1; +#A 0 0 0 0 0 0 0 0.0571429 0.142857 0.171429 0.228571 0.314286 0.385714 +0.457143 0.542857 0.628572 0.714286 0.757143 0.742857 0.714286 0.671429 +0.628571 0.6 0 0 0 0.00714286 0.0142857 0.0142857 0.0142857 0.0142857 +0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 +0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0285714 0.0714286 +0 0 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 0.0142857 +0.0142857 1.86265e-09 0.442857 0.414286 0.385714 0.342857 0.328571 +0.257143 0.214286 0.192857 0.171429; +#X coords 0 1 63 -1 200 140 1; +#X restore 148 4 graph; +#X obj -20 153 tabplay~ array1; +#X obj -78 189 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj -20 242 tabwrite~ array2; +#X obj 164 152 hsl 128 15 0 64 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 2800 1; +#X obj 150 216 hsl 128 15 0 64 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 10900 1; +#X msg 147 235 center \$1; +#X floatatom 272 188 5 0 0 0 - - -; +#X obj -21 195 tbfft2~; +#X msg 161 176 width \$1; +#X obj -20 329 print~; +#X obj 140 308 block~ 128; +#X connect 2 0 9 0; +#X connect 3 0 2 0; +#X connect 3 0 4 0; +#X connect 3 0 11 0; +#X connect 5 0 10 0; +#X connect 5 0 8 0; +#X connect 6 0 7 0; +#X connect 7 0 9 0; +#X connect 9 0 4 0; +#X connect 9 0 11 0; +#X connect 10 0 9 0; -- cgit v1.2.1