chipwave

clean-up: #48

here's an old port i did of a pure data patch called chipwave by Phill Phelps.
also see the updated pd version Dan Wilcox made: rc-patches

//after http://www.zenpho.co.uk/chipwave.shtml

s.boot
(
SynthDef(\ioscs, {|out= 0, amp= 0.5, freq= 400, width= 0.25, gate= 1, atk= 0.002, dec= 0, sus= 1, rel= 0.2, ws= #[0, 2, 2, 3, 2, 2, 2, 2, 2], ps= #[0, 12, -12, 0, 7, 0, 7, 0, 7]|
        var e= EnvGen.ar(Env.adsr(atk, dec, sus, rel), gate, amp, doneAction:2);
        var w= Duty.ar(0.025, 0, Dseq(ws));
        var p= Duty.ar(0.025, 0, Dseq(ps));
        var f= freq*p.midiratio;
        var ti= LFTri.ar(f, 0, 0.5, 0.5);
        var sq= LFPulse.ar(f, 0, width*0.5, 2, -1);
        var ns= LFNoise0.ar(f*10);
        var z= Select.ar(w, [DC.ar(0), ti, sq, ns]);
        Out.ar(out, LeakDC.ar(z*e));
}).add;
)

//arp
a= Synth(\ioscs, [\freq, 60.midicps, \amp, 0.5, \width, 0.5]).setn(\ws, #[0, 2, 2, 3, 2, 2, 2, 2, 2], \ps, #[0, 12, -12, 0, 7, 0, 7, 0, 7])
a.release
a= Pbind(\instrument, \ioscs, \midinote, Pseq([60, 60, 70, 60, 65, 63], inf), \amp, 0.5, \dur, 0.25, \width, Pseg(Pseq([0, 1], inf), 5)).play
a.stop

//kick
a= Synth(\ioscs, [\freq, 60.midicps, \amp, 1, \atk, 0.002, \dec, 0, \sus, 1, \rel, 0.3, \width, 0.5]).setn(\ws, #[0, 3, 2, 2, 2, 2, 2, 2, 2], \ps, #[0, 18, -12, 0, 0, -6, -12, -24, -48])
a.release
a= Pbind(\instrument, \ioscs, \midinote, Pseq([40, 48], inf), \amp, 0.5, \rel, 0.3, \legato, 0.3, \dur, 0.5, \width, 0.5, \ws, #[[0, 3, 2, 2, 2, 2, 2, 2, 2]], \ps, #[[0, 18, -12, 0, 0, -6, -12, -24, -48]]).play
a.stop

//snare
a= Synth(\ioscs, [\freq, 60.midicps, \amp, 1, \atk, 0.002, \dec, 0, \sus, 1, \rel, 0.3, \width, 0.5]).setn(\ws, #[0, 3, 2, 3, 3, 3, 3, 3, 3], \ps, #[0, 18, 0, 3, 12, 18, 24, 36, 36])
a.release
a= Pbind(\instrument, \ioscs, \midinote, 70, \amp, Pseq([0, 0.5, 0, 0.25], inf), \rel, 0.3, \dur, 0.5, \width, 0.5, \ws, #[[0, 3, 2, 3, 3, 3, 3, 3, 3]], \ps, #[[0, 18, 0, 3, 12, 18, 24, 36, 36]]).play
a.stop

//bass
a= Synth(\ioscs, [\freq, 60.midicps, \amp, 1, \atk, 0.002, \dec, 0, \sus, 1, \rel, 0.3, \width, 0.5]).setn(\ws, #[0, 1, 1, 1, 1, 1, 1, 1, 1], \ps, #[0, 24, 0, 12, 0, -1, 1, -1, 0])
a.release
a= Pbind(\instrument, \ioscs, \midinote, Pseq([40, 48, 48, 60], inf), \amp, 0.5, \rel, 0.3, \dur, 0.25, \width, 0.5, \ws, #[[0, 1, 1, 1, 1, 1, 1, 1, 1]], \ps, #[[0, 24, 0, 12, 0, -1, 1, -1, 0]]).play
a.stop

(
Ppar([
        Pbind(\instrument, \ioscs, \amp, 0.5, \midinote, Pseq([64, 66, 52], inf), \dur, 0.25),
        Pbind(\instrument, \ioscs, \amp, 0.5, \midinote, Pseq([60, 70], inf), \dur, 0.5),
        Pbind(\instrument, \ioscs, \amp, 0.5, \midinote, 100, \dur, 1/3)
]).play;
)