It would be very handy to be able to ‘run’ a buffer via MIDI or OSC. Many times I’ll have one-off sound effects that I run from various buffers while a ‘main’ buffer plays the main song. As it stands now, I have to click (or use the keyboard) to choose the correct buffer, then hit Cmd-R to play the sample referenced by that buffer. Being able to trigger buffers via a MIDI controller would be a game changer…
It may not be possible at the moment to run a specific ‘buffer’ in response to an event, in the sense of something like run_buffer(1)… but In fact, you can do things that are pretty much equivalent. For example, due to the ‘global’ nature of the built in Time-State event store, it is absolutely possible to sync (wait) on an OSC or MIDI event in one buffer, trigger this event from wherever, and then run whatever code in response. The key is that you need to Run the buffer where you are syncing on the event at least once initially to ensure that the code begins waiting for your events.
Hi @bcgreen24 yes I’d echo the above - my example may not be exactly what you’re after, but the principle of having code inside live loops, synced on midi or osc cues - that’s it.
Quite often I’ll have a buffer dedicated to running one-off samples mapped to a midi keyboard. I just cmd-R it once to get the loops going, then it’s good until a hard stop.
I remember many years ago going to see Thomas Dolby who had one of the first Fairlight’s in the UK and he had a party piece of playing humerous sounds from his keyboard. Apparently it cost several times the cost of his London flat. Now, it’s all free! Who said modern life is rubbish?
So far, so good! I did a quick test and created some code that basically does one of the things I was setting out to accomplish: trigger samples via a MIDI controller.
live_loop :midi_sfx do
note = sync "/midi:launchkey_mk2_61_launchkey_midi:10/note_on"
if note == 40 then
sample :ambi_lunar_land, release: 2, sustain: 2
if note == 41 then
sample :ambi_dark_woosh, release: 2, sustain: 2
if note == 42 then
sample :ambi_drone, release: 2, sustain: 2
The above code allows me to map various samples to performance pads on my MIDI controller, and works soooooo well.
Me too. Sam sometimes reminds us that ‘Sonic Pi is not Ruby’ so he’s not necessarily supporting all Ruby constructs. We have to be a bit cautious at investing too much in clever-clever code, but hopefully arrays and things basic things will stay in there.