These instructions are mainly for my own personal reference and should not be considered a supported feature of Sonic Pi. For experimentation only. Assumes OSX 10.10
- Setup a virtual midi channel on OSX
This is sometimes referred to as a "loopback" device and it should allow the various software applications to communicate.
- Open
/Applications/Utilities/Audio\ MIDI\ Setup.app/
and go to "Window > Show MIDI studio". - Double click
IAC Driver
- In the new window, click
Device is online
- Close
Audio MIDI Setup
- Download MIDI Monitor
This is just to watch the messages fly around the system. Not essential for this.
- Download Virtual MIDI Piano Keyboard (VMPK)
- Copy to the
Applications
folder - Open and go to "Edit > MIDI Connections"
- Enable MIDI input, select
CoreMIDI
as the driver andIAC Driver Bus 1
as the "Input MIDI Connection". The outputs should both be FluidSynth.
- Open Sonic Pi and run the following:
require 'unimidi'
output = UniMIDI::Output.open(:first)
notes = [36, 40, 43, 48, 52, 55, 60, 64, 67] # C E G arpeggios
duration = 0.2
output.open do |output|
8.times do
note = (scale :a1, :minor_pentatonic).choose
output.puts(0x90, note, 100) # note on message
sleep(duration) # wait
output.puts(0x80, note, 100) # note off message
end
end
Are you getting good results with this? MIDI in Sonic Pi would be awesome :-)