Change parameters of a synth with MIDI CC from controller

This seem’s to work OK.
I’ve modified it so I could use my keyboard “knobs” to provide the cc input,
I used 20 and 72 instead of your 0 cc
You can control them togehter on the same midi_cc (eg your 0) which gives an interesting result.

# Example to send to forum

#Midi CC in
#cc_in = "/midi:arduino_leonardo_*:1/control_change"
cc_in = "/midi*/control_change" #so that it would respond to my keyboard


with_fx :reverb, room: 0.5, mix: 0 do |fx|
  
  live_loop :midiccin do
    use_real_time
    n,v=sync cc_in
    if n== 72 #I used 72, but could be 0 for your midi input
      control fx, mix: v/127.00
    end
  end
  
  #Simple beat
  live_loop :beat do
    tick
    sample :bd_ada, amp: 1 if bools(1,0,0,0, 1,1,0,0).look
    sample :sn_dolf, amp: 1 if bools(0,0,1,0, 0,0,0,1).look
    sleep 0.25
  end
  set :startCO,80 #used from when program runs until cc changes it
  
  live_loop :contCutoff do
    use_real_time
    n,v = sync "/midi*/control_change"
    if n==20 #I used cc 20 from my keyboard controller
      co=10+100*v/127.0
      set :startCO,co
      control get(:s),cutoff: co
    end
  end
  
  
  
  #bassline
  live_loop :bass do
    s = synth :bass_foundation, note: 40, sustain: 2, release: 0, cutoff: get(:startCO)
    set :s,s
    sleep 1
    control s, note: 28
    sleep 0.2
    control s, note: 31
    sleep 0.8
  end
  
end
2 Likes