From e625413ae9b5cb00209ab406283fff0b622eb5a7 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Sun, 14 Nov 2004 22:47:29 +0000 Subject: adapted for STK 4.2.0 svn path=/trunk/externals/unauthorized/; revision=2271 --- stkdrone~/Makefile | 4 +-- stkdrone~/README | 2 +- stkdrone~/drone.cc | 28 ++++++++--------- stkdrone~/drone.h | 4 +-- stkdrone~/help-stkdrone~.pd | 75 +++++++++++++++++++++++++++++++++++++++++++++ stksitar~/Makefile | 4 +-- stksitar~/README | 2 +- stksitar~/help-stksitar~.pd | 73 +++++++++++++++++++++++++++++++++++++++++++ stksitar~/sitar.cc | 35 +++++++++------------ stksitar~/sitar.h | 31 +++++++++---------- stksitar~/stksitar~.cc | 4 +-- 11 files changed, 202 insertions(+), 60 deletions(-) create mode 100644 stkdrone~/help-stkdrone~.pd create mode 100644 stksitar~/help-stksitar~.pd diff --git a/stkdrone~/Makefile b/stkdrone~/Makefile index 5e621b0..705caad 100644 --- a/stkdrone~/Makefile +++ b/stkdrone~/Makefile @@ -1,6 +1,6 @@ NAME=stkdrone~ CSYM=stkdrone_tilde -STK_HOME=/usr/local/stk-3.2 +STK_HOME=/usr/local/stk current: pd_linux @@ -21,7 +21,7 @@ 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++ + g++ -export_dynamic -shared -o $*.pd_linux *.o $(STK_HOME)/src/libstk.a -lc -lm -lpthread strip --strip-unneeded $*.pd_linux rm -f *.o ../$*.pd_linux ln -s $*/$*.pd_linux .. diff --git a/stkdrone~/README b/stkdrone~/README index 8ccb16c..493d12f 100644 --- a/stkdrone~/README +++ b/stkdrone~/README @@ -1,5 +1,5 @@ ***************************************************************************** -Version 0.01 +Version 0.2 embedding Perry Cook's ragamatic in Pure Data copyright 2001 by Perry Cook copyleft 2001 by Yves Degoyon diff --git a/stkdrone~/drone.cc b/stkdrone~/drone.cc index ba065ad..dcc3137 100644 --- a/stkdrone~/drone.cc +++ b/stkdrone~/drone.cc @@ -9,12 +9,12 @@ #include "drone.h" -drone :: drone(MY_FLOAT lowestFreq) +drone :: drone(StkFloat lowestFreq) { length = (long) (SRATE / lowestFreq + 1); - loopGain = (MY_FLOAT) 0.999; + loopGain = (StkFloat) 0.999; loopFilt = new OneZero(); - delayLine = new DLineA(length); + delayLine = new DelayA(0.5*length, length); envelope = new ADSR(); noise = new Noise; envelope->setAllTimes(2.0,0.5,0.0,0.5); @@ -35,21 +35,21 @@ void drone :: clear() delayLine->clear(); } -void drone :: setFreq(MY_FLOAT frequency) +void drone :: setFreq(StkFloat frequency) { - MY_FLOAT delay; + StkFloat 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; + loopGain = (StkFloat) 0.997 + (frequency * (StkFloat) 0.000002); + if (loopGain>1.0) loopGain = (StkFloat) 0.99999; } -void drone :: pluck(MY_FLOAT amplitude) +void drone :: pluck(StkFloat amplitude) { envelope->keyOn(); } -void drone :: noteOn(MY_FLOAT freq, MY_FLOAT amp) +void drone :: noteOn(StkFloat freq, StkFloat amp) { this->setFreq(freq); this->pluck(amp); @@ -58,20 +58,20 @@ void drone :: noteOn(MY_FLOAT freq, MY_FLOAT amp) #endif } -void drone :: noteOff(MY_FLOAT amp) +void drone :: noteOff(StkFloat amp) { - loopGain = (MY_FLOAT) 1.0 - amp; + loopGain = (StkFloat) 1.0 - amp; #if defined(_debug_) printf("drone : NoteOff: Amp=%lf\n",amp); #endif } -MY_FLOAT drone :: tick() +StkFloat drone :: tick() { /* check this out */ /* here's the whole inner loop of the instrument!! */ - lastOutput = delayLine->tick(loopFilt->tick((delayLine->lastOut() * loopGain)) + lastOutput_ = delayLine->tick(loopFilt->tick((delayLine->lastOut() * loopGain)) + (0.005 * envelope->tick() * noise->tick())); - return lastOutput; + return lastOutput_; } diff --git a/stkdrone~/drone.h b/stkdrone~/drone.h index c5f7a0d..9cfe448 100644 --- a/stkdrone~/drone.h +++ b/stkdrone~/drone.h @@ -11,7 +11,7 @@ #define __drone_h #include "Instrmnt.h" -#include "DLineA.h" +#include "DelayA.h" #include "OneZero.h" #include "ADSR.h" #include "Noise.h" @@ -19,7 +19,7 @@ class drone : public Instrmnt { protected: - DLineA *delayLine; + DelayA *delayLine; ADSR *envelope; Noise *noise; OneZero *loopFilt; 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/stksitar~/Makefile b/stksitar~/Makefile index 5314a78..f23c21b 100644 --- a/stksitar~/Makefile +++ b/stksitar~/Makefile @@ -21,8 +21,8 @@ LINUXINCLUDE = -I../../src -I/usr/local/include .cc.pd_linux: sitar.o g++ -O3 -Wall -D__OS_Linux_ -g -I$(STK_HOME)/include -c sitar.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 + g++ -export_dynamic -shared -o $*.pd_linux *.o $(STK_HOME)/src/libstk.a -lc -lm -lpthread + strip --strip-unneeded $*.pd_linux rm -f *.o ../$*.pd_linux ln -s $*/$*.pd_linux .. diff --git a/stksitar~/README b/stksitar~/README index bb3db3d..39766e1 100644 --- a/stksitar~/README +++ b/stksitar~/README @@ -1,5 +1,5 @@ ***************************************************************************** -Version 0.01 +Version 0.2 embedding Perry Cook's ragamatic in Pure Data copyright 2001 by Perry Cook copyleft 2001 by Yves Degoyon diff --git a/stksitar~/help-stksitar~.pd b/stksitar~/help-stksitar~.pd new file mode 100644 index 0000000..75f6225 --- /dev/null +++ b/stksitar~/help-stksitar~.pd @@ -0,0 +1,73 @@ +#N canvas 33 1 784 529 10; +#X obj 112 311 dac~; +#X obj 115 248 stksitar~; +#X obj 114 278 *~; +#X floatatom 147 278 5 0 0 0 - - -; +#X msg 162 172 stop; +#X floatatom 196 200 5 52 100000 0 - - -; +#X floatatom 238 248 5 5 35 0 - - -; +#X text 247 335 stksitar~ : Object to embed stk-based sitar 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 0 - - -; +#X obj 134 78 / 1000; +#X obj 134 98 + 0.05; +#X floatatom 182 98 5 0 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 239 205 ( min=52Hz \, default=250 Hz ); +#X text 241 195 Frequency; +#X obj 231 77 qlist; +#X msg 274 76 read sitar-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 obj 134 59 random 200; +#X obj 24 57 random 1000; +#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 28 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 32 0; +#X connect 26 0 5 0; +#X connect 26 1 29 0; +#X connect 27 0 26 0; +#X connect 28 0 26 0; +#X connect 29 0 26 0; +#X connect 31 0 27 0; +#X connect 32 0 3 0; +#X connect 33 0 17 0; +#X connect 36 0 18 0; +#X connect 37 0 33 0; diff --git a/stksitar~/sitar.cc b/stksitar~/sitar.cc index 11cf35b..291c5f2 100644 --- a/stksitar~/sitar.cc +++ b/stksitar~/sitar.cc @@ -9,18 +9,13 @@ #include "sitar.h" -#ifndef MY_FLOAT -#warning "weird : MY_FLOAT undefined" -#define MY_FLOAT double -#endif - -sitar :: sitar(MY_FLOAT lowestFreq) +sitar :: sitar(StkFloat lowestFreq) { length = (long) (SRATE / lowestFreq + 1); - loopGain = (MY_FLOAT) 0.999; + loopGain = (StkFloat) 0.999; loopFilt = new OneZero(); - loopFilt->setCoeff(0.01); - delayLine = new DLineA(length); + loopFilt->setZero(0.01); + delayLine = new DelayA(0.5 * length, length); delay = length/2; delayTarg = delay; envelope = new ADSR(); @@ -43,21 +38,21 @@ void sitar :: clear() delayLine->clear(); } -void sitar :: setFreq(MY_FLOAT frequency) +void sitar :: setFreq(StkFloat frequency) { delayTarg = (SRATE / frequency); delay = delayTarg * (1.0 + (0.05 * noise->tick())); delayLine->setDelay(delay); - loopGain = (MY_FLOAT) 0.995 + (frequency * (MY_FLOAT) 0.000001); - if (loopGain>1.0) loopGain = (MY_FLOAT) 0.9995; + loopGain = (StkFloat) 0.995 + (frequency * (StkFloat) 0.000001); + if (loopGain>1.0) loopGain = (StkFloat) 0.9995; } -void sitar :: pluck(MY_FLOAT amplitude) +void sitar :: pluck(StkFloat amplitude) { envelope->keyOn(); } -void sitar :: noteOn(MY_FLOAT freq, MY_FLOAT amp) +void sitar :: noteOn(StkFloat freq, StkFloat amp) { this->setFreq(freq); this->pluck(amp); @@ -67,17 +62,17 @@ void sitar :: noteOn(MY_FLOAT freq, MY_FLOAT amp) #endif } -void sitar :: noteOff(MY_FLOAT amp) +void sitar :: noteOff(StkFloat amp) { - loopGain = (MY_FLOAT) 1.0 - amp; + loopGain = (StkFloat) 1.0 - amp; #if defined(_debug_) printf("sitar : NoteOff: Amp=%lf\n",amp); #endif } -MY_FLOAT sitar :: tick() +StkFloat sitar :: tick() { - MY_FLOAT temp; + StkFloat temp; temp = delayLine->lastOut(); if (fabs(temp) > 1.0) { @@ -97,9 +92,9 @@ MY_FLOAT sitar :: tick() delayLine->setDelay(delay); } - lastOutput = delayLine->tick(loopFilt->tick(temp) + lastOutput_ = delayLine->tick(loopFilt->tick(temp) + (amPluck * envelope->tick() * noise->tick())); - return lastOutput; + return lastOutput_; } diff --git a/stksitar~/sitar.h b/stksitar~/sitar.h index d787211..1144c86 100644 --- a/stksitar~/sitar.h +++ b/stksitar~/sitar.h @@ -10,34 +10,33 @@ #if !defined(__sitar_h) #define __sitar_h -#include "Instrmnt.h" -#include "DLineA.h" +#include "Instrmnt.h" +#include "DelayA.h" #include "OneZero.h" -#include "ADSR.h" -#include "Noise.h" -#include "Object.h" +#include "Noise.h" +#include "ADSR.h" class sitar : public Instrmnt { protected: - DLineA *delayLine; + DelayA *delayLine; OneZero *loopFilt; ADSR *envelope; Noise *noise; long length; - MY_FLOAT loopGain; - MY_FLOAT amPluck; - MY_FLOAT delay; - MY_FLOAT delayTarg; + StkFloat loopGain; + StkFloat amPluck; + StkFloat delay; + StkFloat delayTarg; public: - sitar(MY_FLOAT lowestFreq); + sitar(StkFloat lowestFreq); ~sitar(); 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(); + virtual void setFreq(StkFloat frequency); + void pluck(StkFloat amplitude); + virtual void noteOn(StkFloat freq, StkFloat amp); + virtual void noteOff(StkFloat amp); + virtual StkFloat tick(); }; #endif diff --git a/stksitar~/stksitar~.cc b/stksitar~/stksitar~.cc index bd47817..bfa7a54 100644 --- a/stksitar~/stksitar~.cc +++ b/stksitar~/stksitar~.cc @@ -49,7 +49,7 @@ static void stksitar_freq(t_stksitar* x, t_float ffreq) post("stksitar~ : wrong frequency" ); return; } - x->x_stksitar->setFreq( (MY_FLOAT) ffreq ); + x->x_stksitar->setFreq( (StkFloat) ffreq ); x->x_freq = ffreq; } @@ -60,7 +60,7 @@ static void stksitar_pluck(t_stksitar* x, t_float fpluck) post("stksitar~ : wrong pluck argument" ); return; } - x->x_stksitar->pluck( (MY_FLOAT) fpluck ); + x->x_stksitar->pluck( (StkFloat) fpluck ); x->x_pluck = fpluck; } -- cgit v1.2.1