aboutsummaryrefslogtreecommitdiff
path: root/stkdrone~
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-16 17:08:55 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-16 17:08:55 +0000
commit506b8e7dedb80d79bf015e47d92e8b8dd8284584 (patch)
tree6393e98add0a0ae7f92388665b3b6242977f5b64 /stkdrone~
parent856eaf396d9a4d371a458a2c373a052bb72c8057 (diff)
added files straight from Yves' sources
svn path=/trunk/externals/unauthorized/; revision=864
Diffstat (limited to 'stkdrone~')
-rw-r--r--stkdrone~/INSTALL13
-rw-r--r--stkdrone~/Makefile33
-rw-r--r--stkdrone~/README20
-rw-r--r--stkdrone~/drone-freqs46
-rw-r--r--stkdrone~/drone.cc77
-rw-r--r--stkdrone~/drone.h40
-rw-r--r--stkdrone~/help-stkdrone~.pd75
-rw-r--r--stkdrone~/stkdrone~.cc119
8 files changed, 423 insertions, 0 deletions
diff --git a/stkdrone~/INSTALL b/stkdrone~/INSTALL
new file mode 100644
index 0000000..6eaaff0
--- /dev/null
+++ b/stkdrone~/INSTALL
@@ -0,0 +1,13 @@
+install STK in /usr/local/stk
+or change STK paths in the makefile
+to your STK's location.
+
+untar in /my/pd/dir/externs
+
+cd /my/pd/dir/externs/stkdrone~
+
+make
+
+make install
+
+open help-stkdrone~.pd
diff --git a/stkdrone~/Makefile b/stkdrone~/Makefile
new file mode 100644
index 0000000..5e621b0
--- /dev/null
+++ b/stkdrone~/Makefile
@@ -0,0 +1,33 @@
+NAME=stkdrone~
+CSYM=stkdrone_tilde
+STK_HOME=/usr/local/stk-3.2
+
+current: pd_linux
+
+pd_linux: $(NAME).pd_linux
+
+.SUFFIXES: .pd_linux
+
+LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+LINUXCCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch -g
+
+LINUXINCLUDE = -I../../src -I/usr/local/include
+
+.cc.pd_linux: drone.o
+ g++ -O3 -Wall -D__OS_Linux_ -g -I$(STK_HOME)/include -c drone.cc
+ g++ $(LINUXCCFLAGS) $(LINUXINCLUDE) -I$(STK_HOME)/include -o $*.o -c $*.cc
+ ld -export_dynamic -shared -o $*.pd_linux *.o $(STK_HOME)/src/stklib.a -lc -lm -lstdc++ -lg++
+ strip --strip-unneeded $*.pd_linux
+ rm -f *.o ../$*.pd_linux
+ ln -s $*/$*.pd_linux ..
+
+clean:
+ rm -f *.o *.pd_* so_locations
+
+install:
+ cp help-*.pd *-freqs ../../doc/5.reference
diff --git a/stkdrone~/README b/stkdrone~/README
new file mode 100644
index 0000000..8ccb16c
--- /dev/null
+++ b/stkdrone~/README
@@ -0,0 +1,20 @@
+*****************************************************************************
+Version 0.01
+embedding Perry Cook's ragamatic in Pure Data
+copyright 2001 by Perry Cook
+copyleft 2001 by Yves Degoyon
+tarballs and updates available @ http://ydegoyon.free.fr
+
+stkdrone~ : embeds STK drone simulation in Pure Data.
+
+To install stkdrone~, follow the steps from INSTALL
+
+This software is published under GPL terms.
+
+This is software with ABSOLUTELY NO WARRANTY.
+Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing
+due to a bug or for other reasons.
+We do not warrant that the program is free of infringement of any third-party
+patents.
+
+*****************************************************************************
diff --git a/stkdrone~/drone-freqs b/stkdrone~/drone-freqs
new file mode 100644
index 0000000..12f1a85
--- /dev/null
+++ b/stkdrone~/drone-freqs
@@ -0,0 +1,46 @@
+55.0;
+82.5;
+55.0;
+220.0;
+82.5;
+82.5;
+82.5;
+220.0;
+220.0;
+82.5;
+220.0;
+220.0;
+55.0;
+82.5;
+55.0;
+55.0;
+220.0;
+220.0;
+220.0;
+55.0;
+82.5;
+82.5;
+220.0;
+55.0;
+55.0;
+220.0;
+82.5;
+82.5;
+55.0;
+82.5;
+82.5;
+220.0;
+220.0;
+82.5;
+55.0;
+55.0;
+55.0;
+220.0;
+220.0;
+82.5;
+220.0;
+82.5;
+82.5;
+82.5;
+82.5;
+82.5;
diff --git a/stkdrone~/drone.cc b/stkdrone~/drone.cc
new file mode 100644
index 0000000..ba065ad
--- /dev/null
+++ b/stkdrone~/drone.cc
@@ -0,0 +1,77 @@
+ /******************************************/
+/* Karplus-Strong drone string model */
+/* by Perry Cook, 1995-96 */
+/* */
+/* There exist at least two patents, */
+/* assigned to Stanford, bearing the */
+/* names of Karplus and/or Strong. */
+/******************************************/
+
+#include "drone.h"
+
+drone :: drone(MY_FLOAT lowestFreq)
+{
+ length = (long) (SRATE / lowestFreq + 1);
+ loopGain = (MY_FLOAT) 0.999;
+ loopFilt = new OneZero();
+ delayLine = new DLineA(length);
+ envelope = new ADSR();
+ noise = new Noise;
+ envelope->setAllTimes(2.0,0.5,0.0,0.5);
+ this->clear();
+}
+
+drone :: ~drone()
+{
+ delete loopFilt;
+ delete delayLine;
+ delete envelope;
+ delete noise;
+}
+
+void drone :: clear()
+{
+ loopFilt->clear();
+ delayLine->clear();
+}
+
+void drone :: setFreq(MY_FLOAT frequency)
+{
+ MY_FLOAT delay;
+ delay = (SRATE / frequency);
+ delayLine->setDelay(delay - 0.5);
+ loopGain = (MY_FLOAT) 0.997 + (frequency * (MY_FLOAT) 0.000002);
+ if (loopGain>1.0) loopGain = (MY_FLOAT) 0.99999;
+}
+
+void drone :: pluck(MY_FLOAT amplitude)
+{
+ envelope->keyOn();
+}
+
+void drone :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
+{
+ this->setFreq(freq);
+ this->pluck(amp);
+#if defined(_debug_)
+ printf("drone : NoteOn: Freq=%lf Amp=%lf\n",freq,amp);
+#endif
+}
+
+void drone :: noteOff(MY_FLOAT amp)
+{
+ loopGain = (MY_FLOAT) 1.0 - amp;
+#if defined(_debug_)
+ printf("drone : NoteOff: Amp=%lf\n",amp);
+#endif
+}
+
+MY_FLOAT drone :: tick()
+{
+ /* check this out */
+ /* here's the whole inner loop of the instrument!! */
+ lastOutput = delayLine->tick(loopFilt->tick((delayLine->lastOut() * loopGain))
+ + (0.005 * envelope->tick() * noise->tick()));
+ return lastOutput;
+}
+
diff --git a/stkdrone~/drone.h b/stkdrone~/drone.h
new file mode 100644
index 0000000..c5f7a0d
--- /dev/null
+++ b/stkdrone~/drone.h
@@ -0,0 +1,40 @@
+/******************************************/
+/* Karplus-Strong drone string model */
+/* by Perry Cook, 1995-96 */
+/* */
+/* There exist at least two patents, */
+/* assigned to Stanford, bearing the */
+/* names of Karplus and/or Strong. */
+/******************************************/
+
+#if !defined(__drone_h)
+#define __drone_h
+
+#include "Instrmnt.h"
+#include "DLineA.h"
+#include "OneZero.h"
+#include "ADSR.h"
+#include "Noise.h"
+
+class drone : public Instrmnt
+{
+protected:
+ DLineA *delayLine;
+ ADSR *envelope;
+ Noise *noise;
+ OneZero *loopFilt;
+ long length;
+ MY_FLOAT loopGain;
+public:
+ drone(MY_FLOAT lowestFreq);
+ ~drone();
+ void clear();
+ virtual void setFreq(MY_FLOAT frequency);
+ void pluck(MY_FLOAT amplitude);
+ virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
+ virtual void noteOff(MY_FLOAT amp);
+ virtual MY_FLOAT tick();
+};
+
+#endif
+
diff --git a/stkdrone~/help-stkdrone~.pd b/stkdrone~/help-stkdrone~.pd
new file mode 100644
index 0000000..a65624b
--- /dev/null
+++ b/stkdrone~/help-stkdrone~.pd
@@ -0,0 +1,75 @@
+#N canvas 168 23 784 529 10;
+#X obj 112 311 dac~;
+#X obj 115 248 stkdrone~;
+#X obj 114 278 *~;
+#X floatatom 147 278 5 0 0;
+#X msg 162 172 stop;
+#X floatatom 197 201 5 0 0;
+#X floatatom 238 248 5 5 35;
+#X text 247 335 stkdrone~ : Object to embed stk-based drone synthesis
+;
+#X text 247 360 Comments and bugs @ ydegoyon@free.fr;
+#X msg 113 346 \; pd dsp 1;
+#X msg 179 346 \; pd dsp 0;
+#X msg 24 34 bang;
+#X msg 93 99 play;
+#X msg 113 173 play;
+#X obj 195 248 / 100;
+#X text 276 279 Master level;
+#X obj 23 99 metro 2000;
+#X floatatom 52 75 5 0 0;
+#X obj 134 78 / 1000;
+#X obj 134 98 + 0.05;
+#X floatatom 182 98 5 0 0;
+#X obj 217 278 loadbang;
+#X text 301 258 ( min=0.05 \, max=0.35 \, default = 0.25 );
+#X text 303 248 Strength of plucking;
+#X text 241 195 Frequency;
+#X obj 231 77 qlist;
+#X msg 274 76 read drone-freqs;
+#X msg 231 55 next;
+#X msg 274 55 rewind;
+#X text 247 348 Originally written by Perry Cook for STK/ragamatic
+;
+#X obj 386 76 loadbang;
+#X msg 189 278 40;
+#X obj 24 75 + 0;
+#X text 21 12 Ready for meditation ??;
+#X text 240 398 And now another message from Nancy Reagan : "Drugs
+destroy your brain";
+#X text 239 205 ( min=50Hz \, default=250 Hz );
+#X obj 134 59 random 100;
+#X obj 24 56 random 1000;
+#X floatatom 98 27 5 0 0;
+#X connect 1 0 2 0;
+#X connect 2 0 0 0;
+#X connect 2 0 0 1;
+#X connect 3 0 2 1;
+#X connect 4 0 1 0;
+#X connect 5 0 1 1;
+#X connect 6 0 14 0;
+#X connect 11 0 16 0;
+#X connect 11 0 37 0;
+#X connect 12 0 1 0;
+#X connect 13 0 1 0;
+#X connect 14 0 1 2;
+#X connect 16 0 12 0;
+#X connect 16 0 27 0;
+#X connect 16 0 36 0;
+#X connect 16 0 37 0;
+#X connect 17 0 16 1;
+#X connect 18 0 19 0;
+#X connect 19 0 20 0;
+#X connect 19 0 1 2;
+#X connect 21 0 31 0;
+#X connect 25 0 5 0;
+#X connect 25 1 28 0;
+#X connect 26 0 25 0;
+#X connect 27 0 25 0;
+#X connect 28 0 25 0;
+#X connect 30 0 26 0;
+#X connect 31 0 3 0;
+#X connect 32 0 17 0;
+#X connect 36 0 18 0;
+#X connect 37 0 32 0;
+#X connect 38 0 37 1;
diff --git a/stkdrone~/stkdrone~.cc b/stkdrone~/stkdrone~.cc
new file mode 100644
index 0000000..75ddafc
--- /dev/null
+++ b/stkdrone~/stkdrone~.cc
@@ -0,0 +1,119 @@
+/* stkdrone~ -- STK-based drone synthesis
+ * requires STK library
+ * Copyleft 2001 Yves Degoyon.
+ * Permission is granted to use this software for any purpose provided you
+ * keep this copyright notice intact.
+ *
+ * THE AUTHOR AND HIS EXPLOITERS MAKE NO WARRANTY, EXPRESS OR IMPLIED,
+ * IN CONNECTION WITH THIS SOFTWARE.
+ *
+*/
+
+#include "m_pd.h"
+#include "drone.h"
+
+#define DEFAULT_FREQ 250.0
+#define DEFAULT_PLUCK 0.25
+
+typedef struct _stkdrone
+{
+ t_object x_obj;
+ drone *x_stkdrone;
+ t_int x_on;
+ t_float x_freq;
+ t_float x_pluck;
+} t_stkdrone;
+
+static t_class *stkdrone_class;
+
+static void *stkdrone_new(void)
+{
+ t_stkdrone *x = (t_stkdrone *)pd_new(stkdrone_class);
+ x->x_freq = DEFAULT_FREQ;
+ x->x_pluck = DEFAULT_PLUCK;
+ outlet_new(&x->x_obj, &s_signal);
+ inlet_new( &x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("freq") );
+ inlet_new( &x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("pluck") );
+ if( (x->x_stkdrone = new drone( 50.0 )) == NULL ) {
+ post( "stkdrone~: cannot build drone instrument from STK" );
+ return NULL;
+ } else {
+ return (x);
+ }
+}
+
+static void stkdrone_freq(t_stkdrone* x, t_float ffreq)
+{
+ if ( ffreq < 50.0 )
+ {
+ post("stkdrone~ : wrong frequency" );
+ return;
+ }
+ x->x_stkdrone->setFreq( (MY_FLOAT) ffreq );
+ x->x_freq = ffreq;
+}
+
+static void stkdrone_pluck(t_stkdrone* x, t_float fpluck)
+{
+ if ( fpluck < 0.05 || fpluck > 0.35 )
+ {
+ post("stkdrone~ : wrong pluck argument" );
+ return;
+ }
+ x->x_stkdrone->pluck( (MY_FLOAT) fpluck );
+ x->x_pluck = fpluck;
+}
+
+static void stkdrone_play(t_stkdrone* x)
+{
+ x->x_on = 1; // activate sound
+ x->x_stkdrone->noteOn( x->x_freq, x->x_pluck ); // start sound
+}
+
+static void stkdrone_stop(t_stkdrone* x)
+{
+ x->x_on = 0; // deactivate sound
+}
+
+static t_int *stkdrone_perform(t_int *w)
+{
+ t_float *out = (t_float *)(w[1]);
+ int n = (int)(w[2]);
+ t_stkdrone* x = (t_stkdrone*)(w[3]);
+
+ while ( n-- )
+ {
+ if ( x->x_on )
+ {
+ double dare;
+
+ dare = (float)x->x_stkdrone->tick();
+ // post( "synthesis : %f", dare );
+ *out=dare;
+ }
+ else
+ {
+ *(out) = 0.0;
+ }
+ out++;
+ }
+
+ return (w+4);
+}
+
+static void stkdrone_dsp(t_stkdrone *x, t_signal **sp)
+{
+ dsp_add(stkdrone_perform, 3, sp[0]->s_vec, sp[0]->s_n, x);
+}
+
+extern "C" void stkdrone_tilde_setup(void)
+{
+ stkdrone_class = class_new(gensym("stkdrone~"), (t_newmethod)stkdrone_new, 0,
+ sizeof(t_stkdrone), 0, A_NULL);
+ class_sethelpsymbol(stkdrone_class, gensym("help-stkdrone~.pd") );
+ class_addmethod(stkdrone_class, (t_method)stkdrone_dsp, gensym("dsp"), A_NULL);
+ class_addmethod(stkdrone_class, (t_method)stkdrone_play, gensym("play") , A_NULL);
+ class_addmethod(stkdrone_class, (t_method)stkdrone_stop, gensym("stop") , A_NULL);
+ class_addmethod(stkdrone_class, (t_method)stkdrone_freq, gensym("freq") , A_DEFFLOAT, A_NULL);
+ class_addmethod(stkdrone_class, (t_method)stkdrone_pluck, gensym("pluck") , A_DEFFLOAT, A_NULL);
+}