Created
April 25, 2017 02:27
-
-
Save Enkerli/a3c80ddd0840d91fa8333e790f03befd to your computer and use it in GitHub Desktop.
Sonic Pi script creating a countermelody through contrary motion.
This file contains hidden or 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
use_real_time # Preventing latency | |
use_tuning :just, :c # Just Intonation | |
delta=counter=naute=idx=0 | |
previous=60 | |
gamme=(scale 50, :minor_pentatonic, num_octaves: 5) | |
counter_gamme=(scale 38, :minor_pentatonic, num_octaves: 2) | |
with_fx :compressor, threshold: 0.1 do # Preventing clipping | |
with_fx :reverb do # Everything on the same reverb | |
with_fx :lpf, cutoff_slide: 0.02 do |filtre| | |
melody = synth :tb303, pulse_width: 0.1, wave: 1, note: 0, release: 1000, amp: 0, note_slide_shape: 3 | |
counter_melody = synth :fm, divider: 4, note: 0, release: 1000, 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 | |
delta=note_on - previous | |
if gamme.index(note_on) | |
idx=gamme.index(note_on) | |
control melody, note_slide: 0 | |
else | |
control melody, note_slide: 0.25 | |
if delta > 0 | |
idx=idx+1 | |
else | |
idx=idx-1 | |
end | |
end | |
naute=gamme[idx] | |
control melody, note: naute, amp: velocity / 127.0 # Incoming note | |
if delta < 0 | |
counter=counter_gamme.tick | |
else | |
counter=counter_gamme.reverse.tick | |
end | |
control counter_melody, note: counter, amp: velocity / 127.0 # Incoming note | |
previous=naute | |
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 filtre, cutoff: breath | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment