Hi.
Last few weeks, I’ve been trying to use sonic pi to squeeze maximum control out of one lpd8. It’s not finished, it will always be a work in progress. It’s not a performance, nor a stream and I’m even actively taking the ‘live’ out of ‘live coding’. It might be useful to someone, somewhere, someday so I’ll post my best shot so far here anyway.
notes = [:a, :b, :c, :d, :e, :f, :g]
notes2 = [:minor, :major, :m6, :diminished]
chords = [(chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose), (chord notes.choose, notes2.choose)]
sleep 2
synthList = [:beep, :blade, :bnoise, :chipbass, :chiplead, :chipnoise, :cnoise, :dark_ambience, :dpulse, :dsaw, :dtri, :dull_bell, :fm, :gnoise, :growl, :hollow, :hoover, :mod_beep, :mod_dsaw, :mod_fm, :mod_pulse, :mod_saw, :mod_sine, :mod_tri, :noise, :piano, :pluck, :pnoise, :pretty_bell, :prophet, :pulse, :saw, :sine, :square, :subpulse, :supersaw, :tb303, :tech_saws, :tri, :zawa]
usedSynth = [:tb303, :hollow, :chipbass, :chiplead]
sampleList = [:bd_808, :bd_ada, :bd_boom, :bd_fat, :bd_gas, :bd_haus, :bd_klub, :bd_pure, :bd_sone, :bd_tek, :bd_zome, :bd_zum, :tabla_ghe1,:tabla_ghe2,:tabla_ghe3,:tabla_ghe4,:tabla_ghe5, :tabla_ghe6, :tabla_ghe7, :tabla_ghe8]
usedSample = [:bd_boom, :tabla_ghe6, :tabla_ghe2, :bd_pure]
synthPanList = ["off", "random", "round", "round cc"]
synthPanMode = ["off", "off", "off", "off"]
mode = ["SYNTHSmode", "SYNTHSmodeEXTRA", "SAMPLESmode"]
modeStr = "SYNTHSmode"
sleepList = [0.125, 0.25, 0.5, 1, 2, 4, 8, 16]
synthSleep = [0.5, 2, 4, 8]
synthAmp = [0.8, 0.8, 0.8, 0.8]
synthPan = [0, 0, 0, 0]
synthAttack = [0, 0, 0, 0]
synthDelay = [0, 0, 0, 0]
synthSustain = [0, 0, 0, 0]
synthRelease = [1, 1, 1, 1]
selSynth = 0
synthTrue = [false, false, false, false]
sampleTrue = [false, false, false, false]
selSample = 0
sampleAmp = [1, 1, 1, 1]
sampleSleep = [0.5, 0.5, 0.5, 0.5]
sampleRate = [1, 1, 1, 1]
velRandSynth = [0, 0, 0, 0]
synthPat = [(ring chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose),
(ring chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose),
(ring chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose),
(ring chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose)]
in_thread(name: :midiNotesIn) do
live_loop :midiNotesIn do
use_real_time
note, velocity = sync "/midi/lpd8_midi_1/1/1/note_on"
if note == 40 then ##pad5
##puts mode.ring.look(:modetick)
modeStr = mode.ring.tick(:modetick)
else
if modeStr == "SYNTHSmode" then
if note == 36 then ##pad1
selSynth = 0
end
if note == 37 then ##pad2
selSynth = 1
end
if note == 38 then ##pad3
selSynth = 2
end
if note == 39 then ##pad4
selSynth = 3
end
velRandSynth[selSynth] = quantise (velocity / 64.0) - 1, 0.05
if note == 41 then ##pad6
synthPat[selSynth] = synthPat[selSynth].ring + synthPat[selSynth].ring.reverse
end
if note == 42 then ##pad7
if synthTrue[selSynth] == true then
synthTrue[selSynth] = false
else
synthTrue[selSynth] = true
end
end
if note == 43 then ##pad8
synthPat[selSynth] = (ring chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose, chords.choose)
end
end
if modeStr == "SYNTHSmodeEXTRA" then
if note == 36 then ##pad1
selSynth = 0
end
if note == 37 then ##pad2
selSynth = 1
end
if note == 38 then ##pad3
selSynth = 2
end
if note == 39 then ##pad4
selSynth = 3
end
end
if modeStr == "SAMPLESmode" then
if note == 36 then ##pad1
selSample = 0
end
if note == 37 then ##pad2
selSample = 1
end
if note == 38 then ##pad3
selSample = 2
end
if note == 39 then ##pad4
selSample = 3
end
if note == 42 then ##pad7
if sampleTrue[selSample] == true then
sampleTrue[selSample] = false
else
sampleTrue[selSample] = true
end
end
end
end
cue :puts
end
end
in_thread(name: :midiChIn) do
live_loop :midiChIn do
use_real_time
ch, val = sync "/midi/lpd8_midi_1/1/1/control_change"
if modeStr == "SYNTHSmode" then
if ch == 1 then
usedSynth[selSynth] = synthList[quantise val / 3, 1]
end
if ch == 2 then
synthSleep[selSynth] = sleepList[quantise val / 6, 1]
if synthSleep[selSynth] == nil then
synthSleep[selSynth] = 16
end
end
if ch == 3 then
synthAmp[selSynth] = quantise val / 64.00, 0.05
end
if ch == 4 then
synthPan[selSynth] = quantise val / 64.0 - 1, 0.05
end
if ch == 5 then
synthAttack[selSynth] = quantise val / 64.0, 0.05
end
if ch == 6 then
synthDelay[selSynth] = quantise val / 64.0, 0.05
end
if ch == 7 then
synthSustain[selSynth] = quantise val / 64.0, 0.05
end
if ch == 8 then
synthRelease[selSynth] = quantise val / 32.0, 0.05
end
end
if modeStr == "SYNTHSmodeEXTRA" then
if ch == 4 then
synthPanMode[selSynth] = synthPanList[quantise val / 32, 1]
end
end
if modeStr == "SAMPLESmode" then
if ch == 1 then
#selSample = quantise val / 12, 1
usedSample[selSample] = sampleList[quantise val / 6, 1]
end
if ch == 2 then
sampleSleep[selSample] = sleepList[quantise val / 6, 1]
if sampleSleep[selSample] == nil then
sampleSleep[selSample] = 16
end
end
if ch == 3 then
sampleAmp[selSample] = quantise val / 64.00, 0.05
end
if ch == 4 then
sampleRate[selSample] = quantise val / 16.0, 0.05
if sampleRate[selSample] < 0.1 then
sampleRate[selSample] = 0.1
end
end
end
cue :puts
end
end
in_thread(name: :puts) do
live_loop :puts do
sync :puts
puts modeStr
if modeStr == "SYNTHSmode" then
puts "notes ", synthPat[selSynth]
puts "synthTrue? ", synthTrue[selSynth]
puts "°1 ", selSynth, usedSynth[selSynth]
puts "°2 sleep ", synthSleep[selSynth]
puts "°3 amp ", synthAmp[selSynth]
puts "°4 pan ", synthPan[selSynth]
puts "°5 A attack ", synthAttack[selSynth]
puts "°6 D delay ", synthDelay[selSynth]
puts "°7 S sustain", synthSustain[selSynth]
puts "°8 R release", synthRelease[selSynth]
puts "---"
puts "velRandSynth", velRandSynth[selSynth]
end
if modeStr == "SYNTHSmodeEXTRA" then
puts "auto synth panning?"
puts synthPanMode
end
if modeStr == "SAMPLESmode" then
puts "sampleTrue? ", sampleTrue[selSample]
puts usedSample[selSample]
puts "°2 sleep ", sampleSleep[selSample]
puts "°3 amp ", sampleAmp[selSample]
puts "°4 rate ", sampleRate[selSample]
end
end
end
in_thread(name: :synthPanMode) do
live_loop :synthPanMode do
x = 0
4.times do
if synthPanMode[x] == "random" then
#4.times do
synthPan[x] = rrand(-1, 1)
#end
end
if synthPanMode[x] == "round" then
synthPan[x] = synthPan[x] + 0.05
if synthPan[x] > 0.95 then
synthPan[x] = -0.95
end
end
if synthPanMode[x] == "round cc" then
synthPan[x] = synthPan[x] - 0.05
if synthPan[x] < -0.95 then
synthPan[x] = 0.95
end
end
end
sleep 0.5
end
end
in_thread(name: :pattern) do
live_loop :synth0 do
if synthTrue[0] == true then
use_synth usedSynth[0]
play synthPat[0].tick, amp: synthAmp[0], attack: synthAttack[0], delay: synthDelay[0], sustain: synthSustain[0], release: synthRelease[0], pan: synthPan[0], pitch: velRandSynth[0]
end
sleep synthSleep[0]
end
live_loop :synth1 do
if synthTrue[1] == true then
use_synth usedSynth[1]
play synthPat[1].tick, amp: synthAmp[1], attack: synthAttack[1], delay: synthDelay[1], release: synthRelease[1], pan: synthPan[1]
end
sleep synthSleep[1]
end
live_loop :synth2 do
if synthTrue[2] == true then
use_synth usedSynth[2]
play synthPat[2].tick, amp: synthAmp[2], attack: synthAttack[2], delay: synthDelay[2], release: synthRelease[2], pan: synthPan[2]
end
sleep synthSleep[2]
end
live_loop :synth3 do
if synthTrue[3] == true then
use_synth usedSynth[3]
play synthPat[3].tick, amp: synthAmp[3], attack: synthAttack[3], delay: synthDelay[3], release: synthRelease[3], pan: synthPan[3]
end
sleep synthSleep[3]
end
live_loop :sample0 do
if sampleTrue[0] == true then
sample usedSample[0], amp: sampleAmp[0], rate: sampleRate[0]
end
sleep sampleSleep[0]
end
live_loop :sample1 do
if sampleTrue[1] == true then
sample usedSample[1], amp: sampleAmp[1], rate: sampleRate[1]
end
sleep sampleSleep[1]
end
live_loop :sample2 do
if sampleTrue[2] == true then
sample usedSample[2], amp: sampleAmp[2], rate: sampleRate[2]
end
sleep sampleSleep[2]
end
live_loop :sample3 do
if sampleTrue[3] == true then
sample usedSample[3], amp: sampleAmp[3], rate: sampleRate[3]
end
sleep sampleSleep[3]
end
end