Skip to content

Commit

Permalink
adding scales example
Browse files Browse the repository at this point in the history
  • Loading branch information
heuermh committed Nov 21, 2012
1 parent 9fd0b4a commit 3c4e3f6
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 0 deletions.
146 changes: 146 additions & 0 deletions Arpeggiators.ck
Expand Up @@ -197,4 +197,150 @@ public class Arpeggiators
procedure @=> arpeggiator.procedure;
return arpeggiator;
}

fun static UpArpeggiator up(Scale scale, FloatProcedure procedure)
{
UpArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
return arpeggiator;
}

fun static DownArpeggiator down(Scale scale, FloatProcedure procedure)
{
DownArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
return arpeggiator;
}

fun static UpDownArpeggiator upDown(Scale scale, FloatProcedure procedure)
{
UpDownArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
return arpeggiator;
}

fun static DownUpArpeggiator downUp(Scale scale, FloatProcedure procedure)
{
DownUpArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
return arpeggiator;
}

fun static RandomArpeggiator random(Scale scale, FloatProcedure procedure)
{
RandomArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
return arpeggiator;
}


fun static UpArpeggiator up(Chord chord, FloatProcedure procedure, dur rate)
{
UpArpeggiator arpeggiator;
chord.root @=> arpeggiator.root;
chord.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static DownArpeggiator down(Chord chord, FloatProcedure procedure, dur rate)
{
DownArpeggiator arpeggiator;
chord.root @=> arpeggiator.root;
chord.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static UpDownArpeggiator upDown(Chord chord, FloatProcedure procedure, dur rate)
{
UpDownArpeggiator arpeggiator;
chord.root @=> arpeggiator.root;
chord.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static DownUpArpeggiator downUp(Chord chord, FloatProcedure procedure, dur rate)
{
DownUpArpeggiator arpeggiator;
chord.root @=> arpeggiator.root;
chord.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static RandomArpeggiator random(Chord chord, FloatProcedure procedure, dur rate)
{
RandomArpeggiator arpeggiator;
chord.root @=> arpeggiator.root;
chord.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static UpArpeggiator up(Scale scale, FloatProcedure procedure, dur rate)
{
UpArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static DownArpeggiator down(Scale scale, FloatProcedure procedure, dur rate)
{
DownArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static UpDownArpeggiator upDown(Scale scale, FloatProcedure procedure, dur rate)
{
UpDownArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static DownUpArpeggiator downUp(Scale scale, FloatProcedure procedure, dur rate)
{
DownUpArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}

fun static RandomArpeggiator random(Scale scale, FloatProcedure procedure, dur rate)
{
RandomArpeggiator arpeggiator;
scale.root @=> arpeggiator.root;
scale.intervals @=> arpeggiator.intervals;
procedure @=> arpeggiator.procedure;
rate => arpeggiator.rate;
return arpeggiator;
}
}
85 changes: 85 additions & 0 deletions examples/scalesExample.ck
@@ -0,0 +1,85 @@
/*
LiCK Library for ChucK.
Copyright (c) 2007-2012 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/>.
*/

TimeSignature.common(160) @=> TimeSignature t;

SinOsc sin => ADSR adsr => Dist dist => SinTrem trem => JCRev rev => dac;
0.6 => sin.gain;
adsr.keyOff();
adsr.set(t.t, t.s, 0.8, t.s);
6.0 => float tremRate;
0.05 => float revMix;
trem.rate(tremRate);
trem.depth(0.2);
rev.mix(revMix);

class Play extends FloatProcedure
{
fun void run(float value)
{
value => sin.freq;
adsr.keyOn();
t.e => now;
adsr.keyOff();
}
}

fun void effect()
{
while (true)
{
t.d => now;
tremRate * 1.05 => tremRate;
revMix + 0.012 => revMix;
trem.rate(tremRate);
rev.mix(revMix);
}
}

261.6256 => float c;
440.0 => float a;

Play play;
Scales.major(c, "C") @=> Scale c_major;
Scales.majorBlues(c, "C") @=> Scale c_majorBlues;
Scales.majorPentatonic(c, "C") @=> Scale c_majorPentatonic;
Scales.minor(a, "A") @=> Scale a_minor;
Scales.minorBlues(a, "A") @=> Scale a_minorBlues;
Scales.minorPentatonic(a, "A") @=> Scale a_minorPentatonic;

t.w => now;

LoopBuilder loopBuilder;
loopBuilder.append(Arpeggiators.upDown(c_major, play, t.s), 2);
loopBuilder.append(Arpeggiators.upDown(c_majorBlues, play, t.s), 1);
loopBuilder.append(Arpeggiators.upDown(c_majorPentatonic, play, t.s), 1);
loopBuilder.append(Arpeggiators.upDown(a_minor, play, t.s), 1);
loopBuilder.append(Arpeggiators.upDown(a_minorBlues, play, t.s), 1);
loopBuilder.append(Arpeggiators.upDown(a_minorPentatonic, play, t.s), 1);

spork ~ effect();

Loops.loop(loopBuilder.build(), 2).run();

t.d => now;

<<<"done">>>;

0 comments on commit 3c4e3f6

Please sign in to comment.