Hello, I’m trying the Berlin Free Orchestra midi instruments linked here (thank you - they’re amazing!)
When I play the code below, sustained notes ring on indefinitely (Sonic Pi STOP button doesn’t stop them). I can only stop sound by switching off the config on/off settings in the SINE player.
Think I need some kind of panic/stop in Sonic Pi? But can’t work out how to do this. Forgive what may be an obvious Q, am MIDI beginner, have added info below for other newbs.
notes = [:c4, :e4, :g4, :b4]
# strings (channel 1)
live_loop :strings do
notes.each do |n|
midi_note_on n, port: "iac_driver_bus_1", channel: 1
sleep 0.4
midi_note_off n, port: "iac_driver_bus_1", channel: 1
end
sleep 1
end
# trumpets (channel 2)
live_loop :trumpets do
notes.reverse.each do |n|
midi_note_on n, port: "iac_driver_bus_1", channel: 2
sleep 0.25
midi_note_off n, port: "iac_driver_bus_1", channel: 2
end
sleep 1
end
To get the SINE player to work on Mac:
switch on IAC driver on the mac (in MIDI Audio Devices)
open SINE player, switch on IAC Driver Bus under Options/Midi devices, switch on config/output channels
Then open Sonic Pi I/O and check MIDI IN-OUT is switched on. SP needs to be opened after SINE.
PS the horn section is a free library of big band sounds, Rotary
I think it’s because you’re sending the midi note on and note off as separate commands. If you use the midi command with a sustain parameter for the note length, then I think Sonic Pi should send the note off when you press the stop button.
You can also use use_midi_defaults to set the default port so that you don’t have to specify it each time.
notes = [:c4, :e4, :g4, :b4]
use_midi_defaults port: "iac_driver_bus_1"
# strings (channel 1)
live_loop :strings do
notes.each do |n|
midi n, channel: 1, sustain: 0.4
end
sleep 1
end
# trumpets (channel 2)
live_loop :trumpets do
notes.reverse.each do |n|
midi n, channel: 2, sustain: 0.25
end
sleep 1
end
Thanks @emlyn - this worked and is far tidier. This gives me a way to make horn stabs with Sonic Pi - woohooo! I’m not a keyboard player and also daw-avoidant, so this is v cool
many MIDI synths respond to the CC message 123 which is “all sounds off”. Sonic Pi has the function midi_all_notes_off which will send this message to all connected MIDI devices on all channels which can be a useful way of requesting total silence on all devices (which honour this cc message). You can also scope to a specific MIDI device and channel if desired.