Hi there, I have a fun little Roland S-1 I’m trying to use with SC. The device can function as a USB audio interface, and also can receive MIDI (also over USB).
When trying it out, I was surprised my MIDI-played note events always came before the scsynth-played sounds. I know that the MIDI latency must match the Server latency…it says so in the Sending MIDI out with Patterns helpfile:
If you want to synchronize events played by a MIDI device and events played by the SuperCollider server, the MIDIOut object’s latency must match the server latency. You can set the latency any time to affect all future events.
I set things up like this:
MIDIClient.init;
m = MIDIOut.newByName("S-1", "S-1");
If I check m.latency
, it is set to 0.2, the same as my running Server’s s.latency
.
(
p = Ppar([
Pbind(
\type, \midi,
\midicmd, \noteOn,
\midiout, m,
\chan, 2,
\degree, Pwhite(-7, 12),
\dur, 1,
\amp, 0.7,
),
Pbind(
\instrument, \kick,
\dur, 1,
\amp, 0.7,
)
]).play(quant: 1);
)
When I play events using Event type \midi
, I expected the midiout
device’s latency to be used. It seems it’s not…I can change m.latency
to any value, and there is no change in how (when) my Event Patterns are played on the MIDI device.
I dug into the implementation of the \midi
Event type (in Event.makeParentEvents
), and I see it has a \lag
key, which I can use to do what I want. If I add a \lag
key with value m.latency
(or s.latency
, since they should be the same) in my MIDI Pbind
, then I hear correctly synchronized audio-vs-MIDI events on the S-1 device.
I was genuinely surprised that my MIDI Events don’t seem to take the m.latency
value into account. I see that in MIDIOut.write
(called by MIDIOut.noteOn
and friends) it does pass in the latency value. So is it possible there’s something specific with this device and setup? In general, does the MIDIOut latency work for other devices?
Thanks,
Glen.