diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-07-30 20:40:34 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@iem.at> | 2015-10-14 15:23:30 +0200 |
commit | 2ae5d551c7b67fe5ff413e85d1e68eb1a063993a (patch) | |
tree | a0eb54d184ebbbf98b4a9cd9f00861108b3bc5a9 /stkdrone~/drone.cc | |
parent | 66aa65d08587324b679556b7b50f5db434b8167c (diff) |
added template-style README and LICENSE and purged cruft in prep for porting to the library template
svn path=/trunk/externals/unauthorized/; revision=15171
Diffstat (limited to 'stkdrone~/drone.cc')
-rw-r--r-- | stkdrone~/drone.cc | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/stkdrone~/drone.cc b/stkdrone~/drone.cc deleted file mode 100644 index dcc3137..0000000 --- a/stkdrone~/drone.cc +++ /dev/null @@ -1,77 +0,0 @@ - /******************************************/ -/* 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(StkFloat lowestFreq) -{ - length = (long) (SRATE / lowestFreq + 1); - loopGain = (StkFloat) 0.999; - loopFilt = new OneZero(); - delayLine = new DelayA(0.5*length, 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(StkFloat frequency) -{ - StkFloat delay; - delay = (SRATE / frequency); - delayLine->setDelay(delay - 0.5); - loopGain = (StkFloat) 0.997 + (frequency * (StkFloat) 0.000002); - if (loopGain>1.0) loopGain = (StkFloat) 0.99999; -} - -void drone :: pluck(StkFloat amplitude) -{ - envelope->keyOn(); -} - -void drone :: noteOn(StkFloat freq, StkFloat amp) -{ - this->setFreq(freq); - this->pluck(amp); -#if defined(_debug_) - printf("drone : NoteOn: Freq=%lf Amp=%lf\n",freq,amp); -#endif -} - -void drone :: noteOff(StkFloat amp) -{ - loopGain = (StkFloat) 1.0 - amp; -#if defined(_debug_) - printf("drone : NoteOff: Amp=%lf\n",amp); -#endif -} - -StkFloat 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_; -} - |