Skip to content

Instantly share code, notes, and snippets.

@d0lfyn
Created May 24, 2021 20:46
Show Gist options
  • Save d0lfyn/43c98a50e90de34a09366c2fd893bb07 to your computer and use it in GitHub Desktop.
Save d0lfyn/43c98a50e90de34a09366c2fd893bb07 to your computer and use it in GitHub Desktop.
Permuto for Sonic Pi
bpm = 400
palette = 28
dilution = 14
length = 16
noteLength = 1
chance = 0.5
velocityMax = 0.3
velocityMin = 0.2
seed = Time.new.to_i
seed = 1621788316
sequence = Array.new(length, { morpheme: nil })
domain = scale(0, :aeolian, num_octaves: 10)
use_bpm(bpm)
use_random_seed(seed)
use_synth(:saw)
use_midi_defaults(port: "port_2")
use_midi_logging(false)
puts(seed)
midi_all_notes_off()
define :randUnit do
morpheme = rand_i(palette + dilution)
return (morpheme >= palette) ? { morpheme: nil } : { morpheme: morpheme, velocity: (velocityMin + (rand * (velocityMax - velocityMin))) }
end
live_loop :perform do
for unit in sequence
morpheme = unit[:morpheme]
velocity = unit[:velocity]
midi(domain[morpheme + 21], channel: 1, sustain: (noteLength - 0.05), vel_f: velocity) if !morpheme.nil?
wait(noteLength)
end
(0...sequence.length).each do |i|
sequence[i] = randUnit() if (rand < chance)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment