home/ atoms/ sonic-pi-midi-output

Sonic Pi sends MIDI messages in sync with music via midi, midi_note_on, and related functions

Functions like midi_note_on :e3, 50 send MIDI messages at the current logical time, keeping them in sync with sleep-driven timing. The midi shortcut sends note_on and note_off together with a sustain: duration. The port: and channel: opts target specific devices and MIDI channels. This allows Sonic Pi to sequence external MIDI hardware in lockstep with internally generated audio in the same live_loop.

Examples

live_loop :moog_trigger do use_real_time midi (octs :e1, 3).tick, sustain: 0.1 sleep 0.125 end

Assessment

Write a live_loop that sends MIDI note_on events to an external synth at 8th-note intervals, cycling through a pentatonic scale.

“many `midi_*` fns work just like `play`, `sample` and `synth` in that they send a message at the current (logical) time”
corpus · sonic-pi-built-in-tutorial · chunk 23