Skip to content

Instantly share code, notes, and snippets.

@Enkerli
Created April 25, 2017 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Enkerli/d89889406e023d4ee4b6bf6f99512892 to your computer and use it in GitHub Desktop.
Save Enkerli/d89889406e023d4ee4b6bf6f99512892 to your computer and use it in GitHub Desktop.
Sonic Pi script to auto-accompany a melodic line every four notes. Goes well with the idea that accompaniment would yield to a melody. https://en.wikipedia.org/wiki/Tempo_rubato#.22Accompaniment_yields.2Fadjusts_to_melody.22
use_real_time # Preventing latency
use_tuning :just, :c # Just Intonation
bass = (ring 48, 53, 48, 43, 53, 48, 55, 41) # Alternating between C, F, and G
with_fx :compressor, threshold: 0.1 do # Preventing clipping
with_fx :reverb do # Everything on the same reverb
melody = synth :prophet, note: 0, release: 1000, cutoff_slide: 0.02, amp: 0
live_loop :notes do
note_on, velocity = sync "/midi/USB_Midi_Cable/4/1/note_on" # Incoming notes from Yamaha WX-11 wind controller
if velocity > 0 # Only use actual note-ons
control melody, note: note_on, amp: velocity / 127.0 # Incoming note
if tick(:bar)%4 == 0
synth :tech_saws, res: 0.1, cutoff: 80, note: bass.tick(:bass), release: 1.2, amp: velocity / 200.0 # Tanpura-style bass
end
end
end
live_loop :windy do # Use the incoming breath control, MIDI CC#2, to modulate the low-pass filter
control_change, breath = sync "/midi/USB_Midi_Cable/4/1/control_change"
if control_change==2
control melody, cutoff: breath
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment