Hi ,
I am working on a thesis project, that would use algorithmic music generation in context of live coding, by building an application, that would generate variations on melodies and beats, and integrate it with Sonic PI.
At this stage, I have a generator, that produces variations on a single voice MIDI input, based on nth-order Markov chains. The result is then sent to Sonic PI, utilzing the OSC protocol.
Sonic PI code:
live_loop :foo2 do
with_fx :reverb, mix: 0.2, room: 0.8 do
use_synth :fm
use_real_time
note = sync "/osc*/melody/notes"
play note
end
end
Sending OSC messages:
for (const [idx, [pitch, quantizedSteps]] of notes.entries()) {
this.oscClient.send(pitch);
/* eslint-disable-next-line no-await-in-loop */
await sleep((quantizedSteps / stepsPerQuater) * 1000);
bar.update(idx + 1);
}
Currently, messages are played, when they are received by Sonic PI and I was wondering what would be the options of syncing the incoming messages to the current beat/loop(s)/metronome playing in Sonic PI?
Or, what could be done alternatively to sync the generator with Sonic PI?
Thanks in advance