Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding adsr and env tremolo effects

  • Loading branch information...
commit 11ee3c54a44c0a596edee808c2eef5ac40f0e78c 1 parent d868996
@heuermh authored
View
45 examples/adsrTremoloExample.ck
@@ -0,0 +1,45 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2015 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK 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 3 of the License, or
+ (at your option) any later version.
+
+ LiCK 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 LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+AdsrTremolo adsrTremolo;
+
+1.0 => adsrTremolo.mix;
+6::ms => adsrTremolo.attack;
+24::ms => adsrTremolo.decay;
+0.9 => adsrTremolo.sustain;
+30::ms => adsrTremolo.release;
+16.666 => adsrTremolo.rate;
+
+SinOsc sin;
+0.8 => sin.gain;
+220.0 => sin.freq;
+
+sin => adsrTremolo => dac;
+
+<<<"ready">>>;
+for (0 => int i; i < 5; i++)
+{
+ <<<"rate", adsrTremolo.rate()>>>;
+ 10::second => now;
+ adsrTremolo.rate() / 2.0 => adsrTremolo.rate;
+}
+<<<"done">>>;
View
94 examples/adsrTremoloPedal.ck
@@ -0,0 +1,94 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2015 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK 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 3 of the License, or
+ (at your option) any later version.
+
+ LiCK 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 LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+AdsrTremolo adsrTremolo;
+
+adsrTremolo.stop();
+1.0 => adsrTremolo.mix;
+6::ms => adsrTremolo.attack;
+24::ms => adsrTremolo.decay;
+0.9 => adsrTremolo.sustain;
+30::ms => adsrTremolo.release;
+16.666 => adsrTremolo.rate;
+
+class Toggle extends Procedure
+{
+ fun void run()
+ {
+ adsrTremolo.toggle();
+ <<<"running", adsrTremolo.running()>>>;
+ }
+}
+
+class IncreaseRate extends Procedure
+{
+ fun void run()
+ {
+ Constrain.constrainf(adsrTremolo.rate() * 1.1, 0.0001, 2000.0) => adsrTremolo.rate;
+ <<<"rate", adsrTremolo.rate()>>>;
+ }
+}
+
+class DecreaseRate extends Procedure
+{
+ fun void run()
+ {
+ Constrain.constrainf(adsrTremolo.rate() * 0.9, 0.0001, 2000.0) => adsrTremolo.rate;
+ <<<"rate", adsrTremolo.rate()>>>;
+ }
+}
+
+class ScaleUp extends Procedure
+{
+ fun void run()
+ {
+ adsrTremolo.scale(1.05);
+ <<<"adsr", adsrTremolo.attack(), adsrTremolo.decay(), adsrTremolo.sustain(), adsrTremolo.release()>>>;
+ }
+}
+
+class ScaleDown extends Procedure
+{
+ fun void run()
+ {
+ adsrTremolo.scale(0.95);
+ <<<"adsr", adsrTremolo.attack(), adsrTremolo.decay(), adsrTremolo.sustain(), adsrTremolo.release()>>>;
+ }
+}
+
+adc => adsrTremolo => dac;
+
+Toggle toggle;
+IncreaseRate increaseRate;
+DecreaseRate decreaseRate;
+ScaleUp scaleUp;
+ScaleDown scaleDown;
+
+StompKeyboard stomp;
+toggle @=> stomp.button0Down;
+increaseRate @=> stomp.button1Down;
+decreaseRate @=> stomp.button2Down;
+scaleUp @=> stomp.button3Down;
+scaleDown @=> stomp.button4Down;
+
+<<<"ready">>>;
+stomp.open(0);
View
2  examples/chewPedal.ck
@@ -23,7 +23,7 @@
Chew chew;
chew.stop();
-0.8 => chew.mix;
+1.0 => chew.mix;
0.1 => chew.topDepth;
0.1 => chew.bottomDepth;
440.0 => chew.topRate;
View
42 examples/envelopeTremoloExample.ck
@@ -0,0 +1,42 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2015 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK 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 3 of the License, or
+ (at your option) any later version.
+
+ LiCK 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 LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+EnvelopeTremolo envelopeTremolo;
+
+1.0 => envelopeTremolo.mix;
+30::ms => envelopeTremolo.duration;
+16.666 => envelopeTremolo.rate;
+
+SinOsc sin;
+0.8 => sin.gain;
+220.0 => sin.freq;
+
+sin => envelopeTremolo => dac;
+
+<<<"ready">>>;
+for (0 => int i; i < 5; i++)
+{
+ <<<"rate", envelopeTremolo.rate()>>>;
+ 10::second => now;
+ envelopeTremolo.rate() / 2.0 => envelopeTremolo.rate;
+}
+<<<"done">>>;
View
90 examples/envelopeTremoloPedal.ck
@@ -0,0 +1,90 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2015 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK 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 3 of the License, or
+ (at your option) any later version.
+
+ LiCK 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 LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+EnvelopeTremolo envelopeTremolo;
+
+envelopeTremolo.stop();
+30::ms => envelopeTremolo.duration;
+16.666 => envelopeTremolo.rate;
+
+class Toggle extends Procedure
+{
+ fun void run()
+ {
+ envelopeTremolo.toggle();
+ <<<"running", envelopeTremolo.running()>>>;
+ }
+}
+
+class IncreaseRate extends Procedure
+{
+ fun void run()
+ {
+ Constrain.constrainf(envelopeTremolo.rate() * 1.1, 0.0001, 2000.0) => envelopeTremolo.rate;
+ <<<"rate", envelopeTremolo.rate()>>>;
+ }
+}
+
+class DecreaseRate extends Procedure
+{
+ fun void run()
+ {
+ Constrain.constrainf(envelopeTremolo.rate() * 0.9, 0.0001, 2000.0) => envelopeTremolo.rate;
+ <<<"rate", envelopeTremolo.rate()>>>;
+ }
+}
+
+class ScaleUp extends Procedure
+{
+ fun void run()
+ {
+ envelopeTremolo.scale(1.05);
+ <<<"duration", envelopeTremolo.duration()>>>;
+ }
+}
+
+class ScaleDown extends Procedure
+{
+ fun void run()
+ {
+ envelopeTremolo.scale(0.95);
+ <<<"duration", envelopeTremolo.duration()>>>;
+ }
+}
+
+adc => envelopeTremolo => dac;
+
+Toggle toggle;
+IncreaseRate increaseRate;
+DecreaseRate decreaseRate;
+ScaleUp scaleUp;
+ScaleDown scaleDown;
+
+StompKeyboard stomp;
+toggle @=> stomp.button0Down;
+increaseRate @=> stomp.button1Down;
+decreaseRate @=> stomp.button2Down;
+scaleUp @=> stomp.button3Down;
+scaleDown @=> stomp.button4Down;
+
+<<<"ready">>>;
+stomp.open(0);
View
2  import.ck
@@ -317,6 +317,7 @@ Machine.add("lick/lfo/Lfo.ck");
// effects, package effect
Machine.add("lick/effect/Effect.ck");
+Machine.add("lick/effect/AdsrTremolo.ck");
Machine.add("lick/effect/AnalogDelay.ck");
Machine.add("lick/effect/Chew.ck");
Machine.add("lick/effect/Cooper.ck");
@@ -327,6 +328,7 @@ Machine.add("lick/effect/CryBaby.ck");
Machine.add("lick/effect/DigitalDelay.ck");
Machine.add("lick/effect/Drop.ck");
Machine.add("lick/effect/DualRect.ck");
+Machine.add("lick/effect/EnvelopeTremolo.ck");
Machine.add("lick/effect/Feedback.ck");
Machine.add("lick/effect/Flange.ck");
Machine.add("lick/effect/Flutter.ck");
View
122 lick/effect/AdsrTremolo.ck
@@ -0,0 +1,122 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2015 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK 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 3 of the License, or
+ (at your option) any later version.
+
+ LiCK 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 LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+public class AdsrTremolo extends Effect
+{
+ ADSR _adsr;
+ float _rate;
+
+ {
+ inlet => _adsr => wet;
+
+ spork ~ _tickAtRate();
+ }
+
+ fun float rate()
+ {
+ return _rate;
+ }
+
+ fun float rate(float f)
+ {
+ f => _rate;
+ return f;
+ }
+
+ fun dur attack()
+ {
+ return _adsr.attackTime();
+ }
+
+ fun dur attack(dur d)
+ {
+ d => _adsr.attackTime;
+ return d;
+ }
+
+ fun dur decay()
+ {
+ return _adsr.decayTime();
+ }
+
+ fun dur decay(dur d)
+ {
+ d => _adsr.decayTime;
+ return d;
+ }
+
+ fun float sustain()
+ {
+ return _adsr.sustainLevel();
+ }
+
+ fun float sustain(float f)
+ {
+ f => _adsr.sustainLevel;
+ return f;
+ }
+
+ fun dur release()
+ {
+ return _adsr.releaseTime();
+ }
+
+ fun dur release(dur d)
+ {
+ d => _adsr.releaseTime;
+ return d;
+ }
+
+ fun void scale(float f)
+ {
+ attack() * f => attack;
+ decay() * f => decay;
+ release() * f => release;
+ }
+
+ fun void _tickAtRate()
+ {
+ while (true)
+ {
+ 1 => _adsr.keyOn;
+ 1::second / (2.0 * _rate) => now;
+ 1 => _adsr.keyOff;
+ 1::second / (2.0 * _rate) => now;
+ }
+ }
+
+ fun static AdsrTremolo create()
+ {
+ AdsrTremolo adsrTremolo;
+ return adsrTremolo;
+ }
+
+ fun static AdsrTremolo create(dur attack, dur decay, float sustain, dur release)
+ {
+ AdsrTremolo adsrTremolo;
+ attack => adsrTremolo.attack;
+ decay => adsrTremolo.decay;
+ sustain => adsrTremolo.sustain;
+ release => adsrTremolo.release;
+ return adsrTremolo;
+ }
+}
View
83 lick/effect/EnvelopeTremolo.ck
@@ -0,0 +1,83 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2015 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK 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 3 of the License, or
+ (at your option) any later version.
+
+ LiCK 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 LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+public class EnvelopeTremolo extends Effect
+{
+ Envelope _env;
+ float _rate;
+
+ {
+ inlet => _env => wet;
+
+ spork ~ _tickAtRate();
+ }
+
+ fun float rate()
+ {
+ return _rate;
+ }
+
+ fun float rate(float f)
+ {
+ f => _rate;
+ return f;
+ }
+
+ fun dur duration()
+ {
+ return _env.duration();
+ }
+
+ fun dur duration(dur d)
+ {
+ d => _env.duration;
+ }
+
+ fun void scale(float f)
+ {
+ duration() * f => duration;
+ }
+
+ fun void _tickAtRate()
+ {
+ while (true)
+ {
+ 1 => _env.keyOn;
+ 1::second / (2.0 * _rate) => now;
+ 1 => _env.keyOff;
+ 1::second / (2.0 * _rate) => now;
+ }
+ }
+
+ fun static EnvelopeTremolo create()
+ {
+ EnvelopeTremolo envelopeTremolo;
+ return envelopeTremolo;
+ }
+
+ fun static EnvelopeTremolo create(dur duration)
+ {
+ EnvelopeTremolo envelopeTremolo;
+ duration => envelopeTremolo.duration;
+ return envelopeTremolo;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.