Last active
September 15, 2017 16:05
-
-
Save reprimande/9d6f78da364fcd7a106b6bccd9e05926 to your computer and use it in GitHub Desktop.
TidalCycles + SupserCollider + ES-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-- Initial --} | |
:load /path/to/zzz.hs | |
import Sound.Tidal.Zzz | |
let ps = [ | |
S "synth" (Just ""), | |
I "ch" (Just 0), | |
I "note" (Just 0), | |
F "cv" (Just 0), | |
I "gate" (Just 0), | |
I "length" (Just 0), | |
F "slew" (Just 0), | |
S "device" (Just "es") ] | |
zzzShape = (zzz ps) | |
synth = makeS zzzShape "synth" | |
ch = makeI zzzShape "ch" | |
note = makeI zzzShape "note" | |
cv = makeF zzzShape "cv" | |
gate = makeI zzzShape "gate" | |
length = makeF zzzShape "length" | |
slew = makeF zzzShape "slew" | |
device = makeS zzzShape "device" | |
s1 <- zzzStream "/zzz" 12345 ps | |
s2 <- zzzStream "/zzz" 12345 ps | |
s3 <- zzzStream "/zzz" 12345 ps | |
s4 <- zzzStream "/zzz" 12345 ps | |
s5 <- zzzStream "/zzz" 12345 ps | |
s6 <- zzzStream "/zzz" 12345 ps | |
s7 <- zzzStream "/zzz" 12345 ps | |
s8 <- zzzStream "/zzz" 12345 ps | |
let hush' = mapM_ ($ silence) [s1,s2,s3,s4,s5,s6,s7,s8] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE NoMonomorphismRestriction #-} | |
module Sound.Tidal.Zzz where | |
import Sound.Tidal.Stream | |
import Sound.Tidal.Pattern | |
import Sound.Tidal.Parse | |
import Sound.OSC.FD | |
import Sound.Tidal.OscStream | |
zzz :: [Param] -> Shape | |
zzz ps = Shape { | |
params = ps, | |
cpsStamp = True, | |
latency = 0 | |
} | |
zzzSlang path = OscSlang { | |
path = path, | |
preamble = [], | |
namedParams = True, | |
timestamp = NoStamp | |
} | |
zzzBackend path port = do | |
s <- makeConnection "127.0.0.1" port (zzzSlang path) | |
return $ Backend s (\_ _ _ -> return ()) | |
zzzStream path port ps = do let shape = (zzz ps) | |
backend <- zzzBackend path port | |
z <- stream backend shape | |
return z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
s.options.device = "ES-8"; | |
s.options.sampleRate = 44100; | |
s.options.numOutputBusChannels = 16; | |
s.boot; | |
) | |
s.quit | |
( | |
SynthDef(\cv, {|ch=14, val=0, time=0| | |
OffsetOut.ar(ch, Lag.ar(DC.ar(1) * val, time)); | |
}).store; | |
SynthDef(\es5, {|ch=20, val=1, time=0.001, t_trig=0| | |
var e; | |
e = EnvGen.ar(Env([0, 1, 1, 0], [0, time, 0]), gate: t_trig); | |
OffsetOut.ar(ch, e * val); | |
}).store; | |
~synths = ( | |
dp: (ch: 1, note: true, gate: true, cv: true ), | |
li: (ch: 2, note: true, gate: true, cv: true ), | |
ac: (ch: 3, note: true, gate: true, cv: true ), | |
ba: (ch: 4, note: true, gate: true, cv: true ), | |
bi: (ch: 5, note: true, gate: true, cv: true ), | |
at: (ch: 6, note: true, gate: true, cv: true ), | |
p1: (ch: 7, note: true, gate: true, cv: true ), | |
p2: (ch: 8, note: false, gate: true, cv: false ), | |
ph: (ch: 8, note: true, gate: false, cv: true ) | |
); | |
~ch2val = { |ch| if (ch == 7) { -1 } {(1 << ch) / 127} }; | |
~n2cv = { |n| (0.089 / 11) * n }; | |
~es5 = Array.fill(8, { |i| Synth(\es5, [\ch, 8 + 6, \val, ~ch2val.(i)]) }); | |
~es8 = Array.fill(8, { |i| Synth(\cv, [\ch, 0 + i]) }); | |
~es3 = Array.fill(8, { |i| Synth(\cv, [\ch, 8 + i]) }); | |
OSCdef(\zzz, {|msg, time, addr, recvPort| | |
var d = (\ch: -1, \gate: -1, \note: -1, \device: 'es', \cv: nil, \length: 0.001, \slew: 0.0, \synth: 'foo'), | |
ch = -1, gate = -1, note = -1, device, cv, length, slew, synth; | |
msg.postln; | |
msg[3..].pairsDo({ |k, v| d.put(k, v); }); | |
device = d.at(\device); | |
synth = ~synths.at(d.at(\synth)); | |
if (synth == nil, { | |
ch = d.at(\ch); | |
gate = d.at(\gate); | |
length = d.at(\length); | |
note = d.at(\note); | |
cv = d.at(\cv); | |
slew = d.at(\slew); | |
}, { | |
ch = synth.at(\ch); | |
if (synth.at(\note), { | |
note = d.at(\note); | |
slew = d.at(\slew); | |
}); | |
if (synth.at(\cv), { | |
cv = d.at(\cv); | |
}); | |
if (synth.at(\gate), { | |
gate = 1; | |
length = d.at(\length); | |
}); | |
}); | |
if (gate == 1, { ~es5[ch - 1].set(\t_trig, 1); }); | |
if (ch < 7, { | |
if (note >= 0, | |
{ ~es3[ch - 1].set(\val, ~n2cv.(note), \time, slew); }, | |
{ ~es3[ch - 1].set(\val, 0, \time, slew); } | |
); | |
}); | |
if (ch < 9, { | |
if (cv != nil, { | |
~es8[ch - 1].set(\val, cv, \time, slew); | |
}) | |
}); | |
}, "/zzz", nil, 12345); | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment