aboutsummaryrefslogtreecommitdiff
path: root/tbext/source
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:14:38 +0200
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:14:38 +0200
commit28b7e464fd119b8c848753a1f41070422c463c41 (patch)
tree07449abdf85d8f1fd4068839b974242b429720ca /tbext/source
parent90c6018a9401e38859f733b3521c919e042322b7 (diff)
parent6932ee2d22511226378218992b0005cb01eb235e (diff)
- abstractions/tb - externals/tb
Diffstat (limited to 'tbext/source')
-rw-r--r--tbext/source/fftbuf.cpp259
-rw-r--r--tbext/source/fftgrrev.cpp160
-rw-r--r--tbext/source/fftgrshuf.cpp153
-rw-r--r--tbext/source/fftgrsort.cpp173
-rw-r--r--tbext/source/him.cpp427
-rw-r--r--tbext/source/main.cpp74
-rw-r--r--tbext/source/sym2num.cpp90
-rw-r--r--tbext/source/tbfft1.cpp134
-rw-r--r--tbext/source/tbfft2.cpp152
-rw-r--r--tbext/source/tbroute.cpp112
-rw-r--r--tbext/source/tbsroute~.cpp109
-rw-r--r--tbext/source/tbssel~.cpp100
-rw-r--r--tbext/source/tbstrg.cpp95
13 files changed, 2038 insertions, 0 deletions
diff --git a/tbext/source/fftbuf.cpp b/tbext/source/fftbuf.cpp
new file mode 100644
index 0000000..13f0b9e
--- /dev/null
+++ b/tbext/source/fftbuf.cpp
@@ -0,0 +1,259 @@
+/* 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 <flext.h>
+
+#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<typename T>
+ 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)
+{
+ if (check(buf))
+ {
+ 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);
+ }
+ else
+ CopySamples(out[0],data,bs);
+
+}
+
+//perform und dsp gleichzeitig?!?
+
+
+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<typename T>
+inline void fftbuf::clear(T* buf)
+{
+ if (buf)
+ {
+ delete buf;
+ buf=NULL;
+ }
+}
+
+inline bool fftbuf::check(buffer * buf)
+{
+ if (buf==NULL)
+ return false;
+//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("blknumber: %i",delay*bs/sr);
+
+ return delay*bs/sr; //ms/sample
+}
diff --git a/tbext/source/fftgrrev.cpp b/tbext/source/fftgrrev.cpp
new file mode 100644
index 0000000..fd844f0
--- /dev/null
+++ b/tbext/source/fftgrrev.cpp
@@ -0,0 +1,160 @@
+/* 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 <flext.h>
+#include <algorithm>
+
+#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_sample * data; //array with data
+ t_sample * d1; //1. element in array with data
+ t_sample * dend; //1 element after the last element
+
+
+ bool reverse;
+
+};
+
+
+FLEXT_LIB_DSP_1("fftgrrev~",fftgrrev,int)
+
+fftgrrev::fftgrrev(int arg):
+ grains(1),offset(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);
+}
+
+void fftgrrev::m_signal(int n, t_float * const *in, t_float *const *out)
+{
+ t_sample * ins = in[0];
+ t_sample * 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
+
+ int 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;
+ }
+ 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..d9ecdfb
--- /dev/null
+++ b/tbext/source/fftgrshuf.cpp
@@ -0,0 +1,153 @@
+/* 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 <flext.h>
+#include <algorithm>
+
+#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_sample * data; //array with data
+ t_sample * d1; //1. element in array with data
+ t_sample * dend; //1 element after the last element
+};
+
+
+FLEXT_LIB_DSP_1("fftgrshuf~",fftgrshuf,int)
+
+fftgrshuf::fftgrshuf(int arg):
+ grains(1),offset(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);
+}
+
+void fftgrshuf::m_signal(int n, t_float * const *in, t_float *const *out)
+{
+ t_sample * ins = in[0];
+ t_sample * 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
+
+ int 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;
+ }
+ 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..1764c02
--- /dev/null
+++ b/tbext/source/fftgrsort.cpp
@@ -0,0 +1,173 @@
+/* Copyright (c) 2003-2004 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 <flext.h>
+#include <algorithm>
+
+#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_sample * data; //array with data
+ t_sample * d1; //1. element in array with data
+ t_sample * dend; //1 element after the last element
+
+
+ bool reverse;
+
+};
+
+
+FLEXT_LIB_DSP_1("fftgrsort~",fftgrsort,int)
+
+fftgrsort::fftgrsort(int arg):
+ grains(1),offset(0),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)
+{
+ t_sample * ins = in[0];
+ t_sample * 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
+
+ int 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/him.cpp b/tbext/source/him.cpp
new file mode 100644
index 0000000..56872df
--- /dev/null
+++ b/tbext/source/him.cpp
@@ -0,0 +1,427 @@
+/* Copyright (c) 2004 Tim Blechmann. */
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */
+/* WARRANTIES, see the file, "COPYING" in this distribution. */
+/* */
+/* */
+/* him~ is a semi-classicical simulation of an hydrogen atom in a magnetic field*/
+/* */
+/* him~ 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 */
+/* */
+/* him~ is based on code provided in the lecture "physik auf dem computer 1" */
+/* held by joerg main during the winter semester 2003/04 at the university */
+/* stuttgart ... many thanks to him and his assistant ralf habel */
+/* */
+/* */
+/* */
+/* 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: Elliott Sharp: The Velocity Of Hue */
+/* Fred Frith: Traffic Continues */
+/* Nmperign: Twisted Village */
+/* Frank Lowe: Black Beings */
+/* */
+
+
+
+#include <flext.h>
+#include <cstdlib>
+#include <cmath>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401)
+#error upgrade your flext version!!!!!!
+#endif
+
+#define NUMB_EQ 4
+
+class him: public flext_dsp
+{
+ FLEXT_HEADER(him,flext_dsp);
+
+public:
+ him(int argc, t_atom *argv);
+
+protected:
+ virtual void m_signal (int n, float *const *in, float *const *out);
+ virtual void m_dsp (int n, float *const *in, float *const *out);
+
+ void set_mu(t_float);
+ void set_muv(t_float);
+ void set_nu(t_float);
+ void set_nuv(t_float);
+ void set_etilde(t_float);
+ void set_dt(t_float);
+ void set_regtime(bool);
+ void state();
+ void reset();
+
+private:
+ // contains DGL-System
+ t_float deriv(t_float x[],int eq);
+
+ // 4th order Runge Kutta update of the dynamical variables
+ void runge_kutta_4(t_float dt);
+
+ //these are our data
+ t_float data[4]; //mu, muv, nu, nuv (semi-parabolische koordinaten)
+ t_float E;
+
+ //and these our settings
+ t_float dt;
+ bool regtime; //if true "regularisierte zeit"
+
+ bool xfade;
+ t_float newE;
+ t_float newdt;
+ bool newsystem;
+ bool newregtime;
+
+ t_float * m_fader;
+
+ //Callbacks
+ FLEXT_CALLBACK_1(set_mu,t_float);
+ FLEXT_CALLBACK_1(set_muv,t_float);
+ FLEXT_CALLBACK_1(set_nu,t_float);
+ FLEXT_CALLBACK_1(set_nuv,t_float);
+ FLEXT_CALLBACK_1(set_etilde,t_float);
+ FLEXT_CALLBACK_1(set_dt,t_float);
+ FLEXT_CALLBACK_1(set_regtime,bool);
+ FLEXT_CALLBACK(state);
+ FLEXT_CALLBACK(reset);
+
+ //reset mus / nus
+ void reset_nuv()
+ {
+ data[3]= 0.5*sqrt( - (4*data[1]*data[1]) -
+ ( data[0]*data[0]*data[1]*data[1]*data[1]*data[1])
+ + (8*E*data[0]) - (8*E*data[2]) -
+ (data[0]*data[0]*data[0]*data[0]*data[1]*data[1])
+ + 16);
+ if (fabs((data[3]))<1e-5)
+ data[3]=0;
+ }
+
+ void reset_muv()
+ {
+ data[1]= 0.5*sqrt( - (4*data[3]*data[3]) -
+ ( data[0]*data[0]*data[1]*data[1]*data[1]*data[1])
+ + (8*E*data[0]) - (8*E*data[2]) -
+ (data[0]*data[0]*data[0]*data[0]*data[1]*data[1])
+ + 16);
+ if (fabs((data[1]))<1e-5)
+ data[1]=0;
+ }
+
+};
+
+
+FLEXT_LIB_DSP_V("him~",him)
+
+him::him(int argc, t_atom *argv)
+{
+ AddInAnything();
+ AddOutSignal();
+ AddOutSignal();
+ AddOutSignal();
+ AddOutSignal();
+ AddOutSignal();
+ AddOutSignal();
+ FLEXT_ADDMETHOD_F(0,"mu",set_mu);
+ FLEXT_ADDMETHOD_F(0,"muv",set_muv);
+ FLEXT_ADDMETHOD_F(0,"nu",set_nu);
+ FLEXT_ADDMETHOD_F(0,"nuv",set_nuv);
+ FLEXT_ADDMETHOD_F(0,"e",set_etilde);
+ FLEXT_ADDMETHOD_F(0,"dt",set_dt);
+ FLEXT_ADDMETHOD_B(0,"regtime",set_regtime);
+ FLEXT_ADDMETHOD_(0,"state",state);
+ FLEXT_ADDMETHOD_(0,"reset",reset);
+
+
+ //beginning values
+ if (argc==1)
+ E=atom_getfloat(argv);
+ else
+ E= -float(rand())/float(RAND_MAX);
+
+ reset();
+
+ state();
+
+ //default mode
+ regtime=true;
+ dt=0.01;
+}
+
+inline t_float him::deriv(t_float * x, int eq)
+{
+ t_float result;
+ // set DGL-System here
+ if (eq == 0) result = x[1];
+ if (eq == 1) result = 2*E*x[0]-0.25*x[0]*x[2]*x[2]*(2*x[0]*x[0]+x[2]*x[2]);
+ if (eq == 2) result = x[3];
+ if (eq == 3) result = 2*E*x[2]-0.25*x[2]*x[0]*x[0]*(2*x[2]*x[2]+x[0]*x[0]);
+
+ return result;
+}
+
+inline void him::runge_kutta_4(t_float dt)
+{
+ t_float k1[NUMB_EQ],k2[NUMB_EQ],k3[NUMB_EQ],k4[NUMB_EQ];
+ t_float temp1[NUMB_EQ], temp2[NUMB_EQ], temp3[NUMB_EQ];
+
+ for(int i=0;i<=NUMB_EQ-1;i++) // iterate over equations
+ {
+ k1[i] = dt * deriv(data,i);
+ temp1[i] = data[i] + 0.5*k1[i];
+ }
+
+ for(int i=0;i<=NUMB_EQ-1;i++)
+ {
+ k2[i] = dt * deriv(temp1,i);
+ temp2[i] = data[i] + 0.5*k2[i];
+ }
+
+ for(int i=0;i<=NUMB_EQ-1;i++)
+ {
+ k3[i] = dt * deriv(temp2,i);
+ temp3[i] = data[i] + k3[i];
+ }
+
+ for(int i=0;i<=NUMB_EQ-1;i++)
+ {
+ k4[i] = dt * deriv(temp3,i);
+ data[i] = data[i] + (k1[i] + (2.*(k2[i]+k3[i])) + k4[i])/6.;
+
+ // we don't want to experience denormals in the next step */
+ if(fabs((data[i]))<1e-5)
+ data[i]=0;
+ }
+
+
+ /*
+ the system might become unstable ... in this case, we'll request a new system
+ */
+
+ for(int i=0;i<=NUMB_EQ-1;i++)
+ {
+ if(data[i]>2)
+ {
+ xfade = newsystem = true;
+ data[i] = 2;
+ }
+ if(data[i]<-2)
+ {
+ xfade = newsystem = true;
+ data[i] = -2;
+ }
+ }
+}
+
+
+
+void him::m_signal(int n, t_float *const *in, t_float *const *out)
+{
+ t_float * out0 = out[0];
+ t_float * out1 = out[1];
+ t_float * out2 = out[2];
+ t_float * out3 = out[3];
+ t_float * out4 = out[4];
+ t_float * out5 = out[5];
+
+
+ if (regtime)
+ {
+ for (int i=0;i!=n;++i)
+ {
+ runge_kutta_4(dt);
+ (*(out0)++)=data[0];
+ (*(out1)++)=data[1];
+ (*(out2)++)=data[2];
+ (*(out3)++)=data[3];
+ (*(out4)++)=data[0]*data[2];
+ (*(out5)++)=(data[0]*data[0]-data[2]*data[2])*0.5;
+ }
+ }
+ else
+ {
+ for (int i=0;i!=n;++i)
+ {
+ runge_kutta_4(dt/(2*sqrt(data[0]*data[0]+data[2]*data[2])));
+ (*(out0)++)=data[0];
+ (*(out1)++)=data[1];
+ (*(out2)++)=data[2];
+ (*(out3)++)=data[3];
+ (*(out4)++)=data[0]*data[2];
+ (*(out5)++)=(data[0]*data[0]-data[2]*data[2])*0.5;
+ }
+ }
+
+ if (xfade)
+ {
+ /* fading */
+ out0 = out[0];
+ out1 = out[1];
+ out2 = out[2];
+ out3 = out[3];
+ out4 = out[4];
+ out5 = out[5];
+
+ t_float * fader = m_fader + n - 1;
+ for (int i=0;i!=n;++i)
+ {
+ (*(out0)++) *= *fader;
+ (*(out1)++) *= *fader;
+ (*(out2)++) *= *fader;
+ (*(out3)++) *= *fader;
+ (*(out4)++) *= *fader;
+ (*(out5)++) *= *fader--;
+ }
+
+ if (newsystem)
+ {
+ reset();
+ newsystem = false;
+ }
+
+ E = newE;
+ dt = newdt;
+ regtime = newregtime;
+
+ out0 = out[0];
+ out1 = out[1];
+ out2 = out[2];
+ out3 = out[3];
+ out4 = out[4];
+ out5 = out[5];
+
+ fader = m_fader;
+ if (regtime)
+ {
+ for (int i=0;i!=n;++i)
+ {
+ runge_kutta_4(dt);
+ (*(out0)++)+= data[0]* *fader;
+ (*(out1)++)+= data[1]* *fader;
+ (*(out2)++)+= data[2]* *fader;
+ (*(out3)++)+= data[3]* *fader;
+ (*(out4)++)+= data[0]*data[2]* *fader;
+ (*(out5)++)+= (data[0]*data[0]-data[2]*data[2])*0.5* *fader++;
+ }
+ }
+ else
+ {
+ for (int i=0;i!=n;++i)
+ {
+ runge_kutta_4(dt/(2*sqrt(data[0]*data[0]+data[2]*data[2])));
+ (*(out0)++)+= data[0]* *fader;
+ (*(out1)++)+= data[1]* *fader;
+ (*(out2)++)+= data[2]* *fader;
+ (*(out3)++)+= data[3]* *fader;
+ (*(out4)++)+= data[0]*data[2]* *fader;
+ (*(out5)++)+= (data[0]*data[0]-data[2]*data[2])*0.5* *fader++;
+ }
+ }
+
+ xfade = false;
+ }
+
+}
+
+void him::m_dsp(int n, t_float *const *in, t_float *const *out)
+{
+ m_fader = new t_float[n];
+ t_float on = 1.f/(n-1);
+
+ t_float value = 0;
+
+ t_float* localfader = m_fader;
+
+ while (n--)
+ {
+ *localfader = value;
+ value += on;
+ ++localfader;
+ }
+ xfade = false;
+}
+
+
+void him::set_mu(t_float f)
+{
+ data[0]=f;
+ reset_nuv();
+}
+
+void him::set_muv(t_float f)
+{
+ data[1]=f;
+ reset_nuv();
+}
+
+void him::set_nu(t_float f)
+{
+ data[3]=f;
+ reset_nuv();
+}
+
+void him::set_nuv(t_float f)
+{
+ data[3]=f;
+ reset_muv();
+}
+
+void him::set_etilde(t_float f)
+{
+ newE=f;
+ xfade = true;
+ //reset_nuv();
+}
+
+void him::set_dt(t_float f)
+{
+ newdt=f;
+ xfade = true;
+}
+
+void him::set_regtime(bool b)
+{
+ newregtime=b;
+ xfade = true;
+}
+
+
+void him::state()
+{
+ post("mu %f",data[0]);
+ post("mus %f",data[1]);
+ post("nu %f",data[2]);
+ post("nus %f",data[3]);
+ post("etilde %f",E);
+}
+
+void him::reset()
+{
+ data[0]=float(rand())/float(RAND_MAX);
+ data[1]=float(rand())/float(RAND_MAX);
+ data[2]=float(rand())/float(RAND_MAX);
+ reset_nuv();
+}
diff --git a/tbext/source/main.cpp b/tbext/source/main.cpp
new file mode 100644
index 0000000..0c9285d
--- /dev/null
+++ b/tbext/source/main.cpp
@@ -0,0 +1,74 @@
+/* Copyright (c) 2003-2004 Tim Blechmann. */
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */
+/* WARRANTIES, see the file, "COPYING" in this distribution. */
+/* */
+/* */
+/* tbext is the collection of some external i wrote. */
+/* some are useful, others aren't... */
+/* */
+/* */
+/* tbext 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: Hamid Drake & Assif Tsahar: Soul Bodies, Vol. 1 */
+/* I.S.O.: I.S.O */
+/* */
+
+
+
+#include <flext.h>
+#define TBEXT_VERSION "0.05"
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
+#error upgrade your flext version!!!!!!
+#endif
+
+void ttbext_setup()
+{
+ post("\nTBEXT: by tim blechmann");
+ post("version "TBEXT_VERSION);
+ post("compiled on "__DATE__);
+ post("contains: tbroute(~), tbfft1~, tbfft2~, bufline~, fftgrrev~");
+ post(" fftgrsort~, fftgrshuf~, him~, sym2num\n");
+
+ FLEXT_SETUP(tbroute);
+ FLEXT_DSP_SETUP(tbsroute);
+ /* obsolete: FLEXT_DSP_SETUP(tbsig); */
+ /* obsolete: FLEXT_DSP_SETUP(tbpow); */
+ FLEXT_DSP_SETUP(tbfft1);
+ FLEXT_DSP_SETUP(tbfft2);
+ FLEXT_DSP_SETUP(fftbuf);
+ FLEXT_DSP_SETUP(fftgrsort);
+ FLEXT_DSP_SETUP(fftgrshuf);
+ FLEXT_DSP_SETUP(fftgrrev);
+ FLEXT_DSP_SETUP(him);
+ FLEXT_SETUP(sym2num);
+
+
+
+}
+
+FLEXT_LIB_SETUP(tbext,ttbext_setup)
diff --git a/tbext/source/sym2num.cpp b/tbext/source/sym2num.cpp
new file mode 100644
index 0000000..8f7bece
--- /dev/null
+++ b/tbext/source/sym2num.cpp
@@ -0,0 +1,90 @@
+/* Copyright (c) 2004 Tim Blechmann. */
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL */
+/* WARRANTIES, see the file, "COPYING" in this distribution. */
+/* */
+/* sym2num interpretes a symbol as decimal number that is related to the ascii */
+/* representation. */
+/* */
+/* */
+/* sym2num 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: Phil Minton & Veryan Weston: Ways */
+/* */
+/* */
+/* */
+
+
+
+#include <flext.h>
+
+#include <cstring>
+#include <cmath>
+
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
+#error upgrade your flext version!!!!!!
+#endif
+
+class sym2num: public flext_base
+{
+ FLEXT_HEADER(sym2num,flext_base);
+
+public:
+ sym2num();
+
+protected:
+ void m_symbol(t_symbol *s);
+
+private:
+
+ FLEXT_CALLBACK_S(m_symbol);
+};
+
+FLEXT_LIB("sym2num",sym2num);
+
+sym2num::sym2num()
+{
+ AddInSymbol();
+
+ FLEXT_ADDMETHOD(0,m_symbol);
+
+ AddOutFloat();
+}
+
+void sym2num::m_symbol(t_symbol * s)
+{
+ const char* str = GetString(s);
+
+ int length = strlen(str);
+
+ int ret(0);
+ while (length--)
+ {
+ ret+=str[length]*pow(2,length);
+ }
+ ToOutFloat(0,ret);
+}
diff --git a/tbext/source/tbfft1.cpp b/tbext/source/tbfft1.cpp
new file mode 100644
index 0000000..e941bfd
--- /dev/null
+++ b/tbext/source/tbfft1.cpp
@@ -0,0 +1,134 @@
+/* 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. */
+/* */
+/* */
+/* tbfft1~ transforms the fft spectrum */
+/* */
+/* tbfft1~ 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: John Zorn / Mike Patton / Ikue Mori: Hemophiliac */
+/* Rashied Ali / Frank Lowe: Duo Exchange */
+/* Keith Rowe / John Tilbury: Duos For Doris */
+/* */
+
+
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401)
+#error upgrade your flext version!!!!!!
+#endif
+
+
+class tbfft1: public flext_dsp
+{
+ FLEXT_HEADER(tbfft1,flext_dsp);
+
+public: // constructor
+ tbfft1();
+
+protected:
+ virtual void m_signal (int n, float *const *in, float *const *out);
+ void set_freq(t_float);
+ void set_fact(t_float);
+
+private:
+ FLEXT_CALLBACK_1(set_freq,t_float)
+ FLEXT_CALLBACK_1(set_fact,t_float)
+
+ t_int center;
+ t_float factor;
+
+ t_float pos;
+ t_int posi;
+
+ float *ins;
+ float *outs;
+
+ t_float s;
+ t_float b;
+
+
+};
+
+
+FLEXT_LIB_DSP("tbfft1~",tbfft1)
+
+tbfft1::tbfft1()
+{
+ AddInSignal();
+ AddOutSignal();
+ FLEXT_ADDMETHOD_F(0,"center",set_freq);
+ FLEXT_ADDMETHOD_F(0,"factor",set_fact);
+}
+
+
+void tbfft1::m_signal(int n, t_float *const *in, t_float *const *out)
+{
+ ins = in[0];
+ outs = out[0];
+
+ n=n/2+1;
+ while(n!=0)
+ {
+ pos= n + factor * (center-n);
+ posi=t_int(pos);
+
+
+ if (n < t_int(center))
+ {
+ *(outs+n) = ((pos-t_float(posi)) * (*(ins+posi)))/2
+ +((1-pos+t_float(posi)) * (*(ins+posi+1)))/2;
+ }
+ else
+ {
+ *(outs+n) = ((pos-t_float(posi)) * (*(ins+posi-1)))/2
+ +((1-pos+t_float(posi)) * (*(ins+posi)))/2;
+ }
+
+ --n;
+ }
+
+
+}
+
+void tbfft1::set_freq(t_float freq)
+{
+ s=Samplerate();
+
+ b=Blocksize();
+
+ center=freq/(s/b);
+}
+
+
+void tbfft1::set_fact(t_float f)
+{
+ if (f<2)
+ factor=f;
+}
diff --git a/tbext/source/tbfft2.cpp b/tbext/source/tbfft2.cpp
new file mode 100644
index 0000000..1ab08db
--- /dev/null
+++ b/tbext/source/tbfft2.cpp
@@ -0,0 +1,152 @@
+/* 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 <flext.h>
+
+#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();
+ ~tbfft2();
+
+protected:
+ virtual void m_signal (int n, float *const *in, float *const *out);
+ virtual void m_dsp (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 * tmp;
+
+ 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);
+}
+
+tbfft2::~tbfft2()
+{
+ free(tmp);
+}
+
+void tbfft2::m_dsp(int n, t_float *const *in, t_float *const *out)
+{
+ free(tmp);
+ tmp=(t_float*)malloc(n*sizeof(t_float));
+}
+
+
+
+void tbfft2::m_signal(int n, t_float *const *in, t_float *const *out)
+{
+ t_float * ins = in[0];
+ t_float * outs = out[0];
+
+ CopySamples(tmp,ins,n);
+
+ n0=n/2;
+
+ if (center-width>0)
+ {
+ n=center-width;
+ }
+ else
+ n=0;
+
+ while (n<center+width)
+ {
+ tmp[n]=*(ins+2*center-n);
+ ++n;
+ }
+
+
+
+ //memcpy
+ CopySamples(outs,tmp,n0*2);
+
+}
+
+void tbfft2::set_freq(t_float freq)
+{
+ center=freq;
+ set_width(width);
+}
+
+void tbfft2::set_width(t_float w)
+{
+
+ if (w+center>n0)
+ {
+ width=n0-center;
+ return;
+ }
+ if (center-w<0)
+ {
+ width=center;
+ return;
+ }
+
+ width=w;
+}
+
+
diff --git a/tbext/source/tbroute.cpp b/tbext/source/tbroute.cpp
new file mode 100644
index 0000000..3218886
--- /dev/null
+++ b/tbext/source/tbroute.cpp
@@ -0,0 +1,112 @@
+/* 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. */
+/* */
+/* */
+/* tbroute is an advanced router. */
+/* the signal to the first inlet is being routed to the outlet specified */
+/* by the second inlet. */
+/* the number of outlets is specified by the creation argument */
+/* */
+/* */
+/* tbroute 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: Hamid Drake & Assif Tsahar: Soul Bodies, Vol. 1 */
+/* I.S.O.: I.S.O */
+/* */
+/* */
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
+#error upgrade your flext version!!!!!!
+#endif
+
+class tbroute: public flext_base
+{
+ FLEXT_HEADER(tbroute,flext_base);
+
+public: // constructor
+ tbroute(int chan);
+
+protected:
+ void route(t_float f);
+
+ void routebang();
+ void set_route(int i);
+
+private:
+ FLEXT_CALLBACK_1(route,t_float);
+
+ FLEXT_CALLBACK(routebang);
+ FLEXT_CALLBACK_1(set_route,int);
+
+ int dest;
+};
+
+
+FLEXT_LIB_1("tbroute",tbroute,int);
+
+tbroute::tbroute(int chan)
+{
+ AddInAnything();
+ AddInInt();
+
+ for (int i=0; i!=chan;++i)
+ {
+ AddOutAnything();
+ }
+
+ FLEXT_ADDMETHOD(0,route);
+ FLEXT_ADDBANG(0,routebang);
+ FLEXT_ADDMETHOD(1,set_route);
+ dest=0;
+}
+
+void tbroute::route(t_float f)
+{
+ ToOutFloat(dest,f);
+}
+
+
+void tbroute::routebang()
+{
+ ToOutBang(dest);
+}
+
+void tbroute::set_route(int i)
+{
+ --i;
+ if ((i>-1) && (i<CntOut()))
+ {
+ dest=i;
+ }
+ else
+ {
+ post("no such outlet");
+ }
+}
diff --git a/tbext/source/tbsroute~.cpp b/tbext/source/tbsroute~.cpp
new file mode 100644
index 0000000..d18d264
--- /dev/null
+++ b/tbext/source/tbsroute~.cpp
@@ -0,0 +1,109 @@
+/* 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. */
+/* */
+/* */
+/* tbsroute~ is an advanced signal router. */
+/* the signal to the first inlet is being routed to the outlet specified */
+/* by the second inlet. */
+/* the number of outlets is specified by the creation argument */
+/* */
+/* */
+/* tbsroute~ 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: AMM: AMMMUSIC 1966 */
+/* Sun Ra: Dancing Shadows */
+/* */
+
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401)
+#error upgrade your flext version!!!!!!
+#endif
+
+class tbsroute: public flext_dsp
+{
+ FLEXT_HEADER(tbsroute,flext_dsp)
+
+public: // constructor
+ tbsroute(t_int chan);
+
+protected:
+ virtual void m_signal (int n, float *const *in, float *const *out);
+ void set_route(int i);
+
+private:
+ FLEXT_CALLBACK_1(set_route,int)
+ t_int dest;
+};
+
+
+FLEXT_LIB_DSP_1("tbroute~",tbsroute,int);
+
+tbsroute::tbsroute (t_int chan):
+ dest(0)
+{
+ AddInSignal();
+ AddInInt();
+
+ for (t_int i=0; i!=chan;++i)
+ {
+ AddOutSignal();
+ }
+
+ FLEXT_ADDMETHOD(1,set_route);
+}
+
+
+void tbsroute::m_signal(int n, float *const *in, float *const *out)
+{
+
+ CopySamples(out[dest],in[0],n);
+
+ for (int i = 0; i != CntOutSig(); i++)
+ if (i!=dest) ZeroSamples(out[i],n);
+
+
+
+
+}
+
+void tbsroute::set_route(int i)
+{
+ --i;
+ if ((i>-1) && (i<CntOutSig()))
+ {
+ dest=i;
+ post("routing to outlet %i",i+1);
+ }
+ else
+ {
+ post("no such outlet");
+ }
+
+}
diff --git a/tbext/source/tbssel~.cpp b/tbext/source/tbssel~.cpp
new file mode 100644
index 0000000..f9111aa
--- /dev/null
+++ b/tbext/source/tbssel~.cpp
@@ -0,0 +1,100 @@
+/* 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. */
+/* */
+/* */
+/* tbssel~ selects one signal from the incoming signals */
+/* the number of inlets is specified by the creation argument */
+/* */
+/* */
+/* tbssel~ 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: AMM: AMMMUSIC 1966 */
+/* Sun Ra: Dancing Shadows */
+/* */
+
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401)
+#error upgrade your flext version!!!!!!
+#endif
+
+class tbssel: public flext_dsp
+{
+ FLEXT_HEADER(tbssel,flext_dsp)
+
+public: // constructor
+ tbssel(t_int chan);
+
+protected:
+ virtual void m_signal (int n, float *const *in, float *const *out);
+ void set_source(int i);
+
+private:
+ FLEXT_CALLBACK_1(set_source,int)
+ t_int source;
+};
+
+
+FLEXT_LIB_DSP_1("tbroute~",tbssel,int);
+
+tbssel::tbssel (t_int chan):
+ source(0)
+{
+ for (t_int i=0; i!=chan;++i)
+ {
+ AddInSignal();
+ }
+
+ AddOutSignal();
+
+ FLEXT_ADDMETHOD(1,set_source);
+}
+
+
+void tbssel::m_signal(int n, float *const *in, float *const *out)
+{
+
+ CopySamples(out[0],in[source],n);
+
+
+}
+
+void tbssel::set_source(int i)
+{
+ if ((i>-1) && (i<CntInSig()))
+ {
+ source=i;
+ post("selecting inlet %i",i);
+ }
+ else
+ {
+ post("no such inlet");
+ }
+
+}
diff --git a/tbext/source/tbstrg.cpp b/tbext/source/tbstrg.cpp
new file mode 100644
index 0000000..a999e2f
--- /dev/null
+++ b/tbext/source/tbstrg.cpp
@@ -0,0 +1,95 @@
+/* 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. */
+/* */
+/* tbstrg can be used to switch between several modules. it requires a creation */
+/* argument (number of outlets). */
+/* if you send an integer to the inlet this outlet will get the message 1, the */
+/* outlet, that was active earlier, will get the message 0. */
+/* */
+/* */
+/* tbstrg 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: Bob Ostertag - DJ Of The Month */
+/* John Zorn's Cobra: Tokyo Operations '94 */
+/* */
+/* */
+
+
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
+#error upgrade your flext version!!!!!!
+#endif
+
+class tbstrg: public flext_base
+{
+ FLEXT_HEADER(tbstrg,flext_base);
+
+public: // constructor
+ tbstrg(t_int chan);
+
+protected:
+ void set_route(t_int i);
+
+private:
+
+ FLEXT_CALLBACK(set_route,t_int);
+ t_int dest;
+};
+
+
+FLEXT_LIB_1("tbstrg",tbstrg,int);
+
+tbstrg::tbstrg(t_int chan)
+{
+ AddInInt();
+
+ for (t_int i=0; i!=chan;++i)
+ {
+ AddOutAnything();
+ }
+
+
+ FLEXT_ADDMETHOD(0,set_route);
+ dest=0;
+}
+
+void tbstrg::set_route(t_int i)
+{
+ if (i != dest)
+ {
+ --i;
+ if ((i>-1) && (i<CntOut()))
+ {
+ ToOutInt(dest,0);
+ dest=i;
+ ToOutInt(dest,1);
+ }
+ }
+}