Doing DJ things with Sonic Pi & MIDI controller

Posted by StuffonmyMind on November 20, 2024

I was chilling in my bed on a rainy Sunday evening in Chennai when I got a message from Shiv Hari that got me giggling and kicking my feet in the air

I heard you set during a live stream of an algo rave event in Bangalore and I quite liked it .. It had a very electronic style to it while also keeping it interesting .. I have a gig on the 17th of November (Sunday) at Sly Granny Indiranagar .. would you be interested in playing like an hour long set for that ?

I had never played at a club setting before so i was super excited but at the same time incredible anxious cause i just had a week and a half to get all the material together.

It ended up being so much fun and I got to experiment a lot with MIDI controls for effects & volumes for transitions!

1
2
3
4
5
6
7
8
9
10
live_loop :volume_control do
  use_real_time
  control_num,val = sync "/midi:minilab3_midi:1/control_change"
  val_to_set = val.to_f/127*4 # Normalise
  puts "setting volume: #{val_to_set} "
  if control_num==74
    puts "controller number 21 detected: setting volume to #{val_to_set} "
    set_volume! (val_to_set)  # added *4
  end
end

Also Triggers!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Trigger a Sample on Note On press
set :kv,0
live_loop :trigger_sample do
  use_real_time
  # MIDI to trigger
  note, velocity = sync  "/midi:minilab3_midi:10/note_on"
  
  if velocity>0 then
    
    # Sample to Trigger
    with_fx :ixi_techno, phase: 0.5, res: 0.5, mix: 0.8 do
      synth :fm,note: hz_to_midi(80)  ,release: 20
      synth :fm,note: hz_to_midi(82)  ,release: 20
      sleep 7.5
    end
    
  else
    kill get(:kv)
  end
end

It felt really good to go and put on a show not just for myself but for my friends who have been around since the day I toying around with music and coding! cause a year ago this would have seemed like a non-scenario :)