Drums again controlling drums in reapers sampler with midi?

Hi everyone I hope you’re all doing well.

I have configured separate instances of reapers inbuilt sampler to respond to specific midi notes for drum programming. Below is a code example using spread and dice functions, if I loaded samples in to the instances of reapers sampler would I be able to control them with the spread and dice functions via midi? And would I be able to write in midi note numbers instead of midi notes?

Your help with this question would be most welcome, heres the code
“””
use_bpm 140
live_loop :drums do
with_swing 0.2 do
if spread(4,4).tick
sample “/Users/soundwarrior/Documents/reaper personal/projects/sound warrior/abis rave 140 bpm/abis rave drum samples /bde-dnb30.aif”
end
if spread(5,4).look
sample “/Users/soundwarrior/Documents/reaper personal/projects/sound warrior/abis rave 140 bpm/abis rave drum samples /Snare_Tight_SP01.wav”
end
end
if dice(9) > 5
sample “/Users/soundwarrior/Documents/reaper personal/projects/sound warrior/abis rave 140 bpm/abis rave drum samples /D#0 oSh_Clap2.aif”
end
sleep 1
end

You can use the midi_cc command to send midi numbers to any channel and port of your choice. You can then use spread and dice to decide which numbers to send via midi similar to how you’re using dice and spread to decide which samples to play.

I would like to do this with midi notes not midi cc’s but I would like to use midi note numbers instead of writing the note names is this possible? would you be able to write me sample code please?

Numbers work perfectly fine, since the notes are aliases for the midi numbers that Sonic Pi use. Basically, you have to use midi_cc for controls (like changing the cutoff) and midi for playing notes. midi also have parameters like sustain, which tells the function for how long to send the signal. I’ve written an example below, which might make it more understandable.

live_loop :main do
  # Using the "pi" midi port and channel 1
  use_midi_defaults channel: 1, port: "pi"
  
  # Using midi_cc to send a control signal to input 10 (in my case the cutoff)
  # this sends a single signal. Using this is necesssary if you want to send control signals
  midi_cc 10, rrand(60,80)
  
  # note names are aliases for midi numbers, so this works too
  # in my setup, port 20 controls the resonance
  midi_cc 20, :c2
  
  # Sending midi notes with the midi function.
  midi (scale :c3, :minor).choose, sustain: 0.125
  sleep 0.125
end
1 Like