Skip to content

Instantly share code, notes, and snippets.

@Enkerli
Created May 5, 2017 03:50
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/d8817b43cbd06859a83a917d6a8ebbc5 to your computer and use it in GitHub Desktop.
Save Enkerli/d8817b43cbd06859a83a917d6a8ebbc5 to your computer and use it in GitHub Desktop.
Using lip pressure to control a “whammy bar” effect in Sonic Pi, driven by a Wind Controller.
use_real_time # Preventing latency
use_tuning :just, :c # Just Intonation
transpo=-12 # Transposition offset
with_fx :compressor, threshold: 0.2 do # Preventing clipping
with_fx :reverb, room: 0.8 do # Everything on the same reverb
with_fx :rlpf, res: 0.7, cutoff_slide: 0.02 do |lipf| # Everything on breath-controlled low-pass filter
with_fx :whammy, transpose_slide: 0.02, mix_slide: 0.02 do |wham| # Everything on a whammy bar
tibi = synth :tb303, note: 0, wave: 1, pulse_width_slide: 0.02, res: 0.7, release: 1000, amp: 0 # TB-303-inspired pulse
prof = synth :prophet, note: 0, res: 0.8, release: 1000, amp: 0 # Prophet-like sub
live_loop :notes do
note_on, velocity = sync "/midi/USB_Midi_Cable/4/1/note_on" # Incoming notes from Yamaha WX-11 wind controller
note_on=note_on+transpo # Transpose by offset
if velocity > 0 # Only use actual note-ons
control tibi, note: note_on, amp: velocity / 150.0 # Incoming note
control prof, note: note_on-12, amp: velocity / 127.0 # Lower octave
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 lipf, cutoff: breath
control wham, mix: breath/127.0 # Mix the whammy bar through breath control
control tibi, pulse_width: 0.5-(breath/256.0) # Also modulate the pulse width: lower is closer to square wave
end
end
live_loop :bendy do
bend_change = sync "/midi/USB_Midi_Cable/4/1/pitch_bend" # The WX-11 sends lip pressure as pitch bend
bent=(bend_change[0]-8192)/ 8192.0 # Convert pitch bend to -1.0 to 1.0
control wham, transpose: bent * 12 # Modulate the whammy bar
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment