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
so I have this code:
“”"
use_bpm 160
live_loop :kp do
with_swing 0.5 do
if (ring true, true, true, true).tick
sample “/Users/soundwarrior/Documents/sonic pi /audio/samples audio/for sonic pi/drums/kick/dt02_kick-classic_anatanz.wav”
end
end
sleep 1
end
live_loop :clap do
with_swing 0.5 do
if (ring true, false, false, true, true, false).tick
sample “/Users/soundwarrior/Documents/sonic pi /audio/samples audio/for sonic pi/drums/clap/909 Clap.WAV”
end
end
sleep 1
end
live_loop :snare do
with_swing 0.5 do
if (ring false, true, false, true, true, false).tick
sample “/Users/soundwarrior/Documents/sonic pi /audio/samples audio/for sonic pi/drums/snare/909 Snare.wav”
end
end
sleep 1
end
live_loop :hh do
with_swing 0.6 do
if (ring false, true, false, true, false, true).tick
sample “/Users/soundwarrior/Documents/sonic pi /audio/samples audio/for sonic pi/drums/highhat/Rhythmace Open hihat.wav”
end
end
sleep 1
end
but instead of using samples in sonic pi I want this code to trigger using the specisific midi notes I set reapers sampler to respond to if anyone can help that would be great
Have you tried replacing all calls to sample
with corresponding calls to midi
?
how would that work? and wouldn’t you need to replace the true and false with some thing els that referenceses the specific midi notes?
It totally depends on what you want to achieve.
Replacing calls to sample
with midi
would preserve the rhythmic behaviour of the piece with the external/internal MIDI devices being triggered at the same time the sampler would have been.
However, if you want it to do something different, you need to change more of the code.
What specifically are you trying to do?
I don’t know how you usually activate samples in Reaper, so I’m assuming they have a note just like synths. I also don’t know about your setup in general. Still, I think the following code is worth looking at as a starting point.
use_bpm 160
# These are the MIDI numbers used by Reaper to play the samples.
# You will have to change these to fit your case, by changing the numbers.
# They're basically the "notes" you ask Reaper to play.
kick_number = 1
clap_number = 2
snare_number = 3
hat_number = 4
# This is the name of MIDI input port, shown in the input/output options.
# Change this to fit the name for Reaper's midi input
midi_port = "pi"
# This is the MIDI channel used in your Sonic PI settings to send signals to Reaper.
# Again, change this to suit your setup
midi_channel = 2
live_loop :kp do
with_swing 0.5 do
if (ring true, true, true, true).tick
midi kick_number, port: midi_port, channel: midi_channel, sustain: 0.125
end
end
sleep 1
end
live_loop :clap do
with_swing 0.5 do
if (ring true, false, false, true, true, false).tick
midi clap_number, port: midi_port, channel: midi_channel, sustain: 0.125
end
end
sleep 1
end
live_loop :snare do
with_swing 0.5 do
if (ring false, true, false, true, true, false).tick
midi snare_number, port: midi_port, channel: midi_channel, sustain: 0.125
end
end
sleep 1
end
live_loop :hh do
with_swing 0.6 do
if (ring false, true, false, true, false, true).tick
midi hat_number, port: midi_port, channel: midi_channel, sustain: 0.125
end
end
sleep 1
end
2 Likes