Support of PortMidi as MIDI output

• May 12, 2013 - 14:20
Reported version
3.0
Type
Functional
Severity
S5 - Suggestion
Status
closed
Project

I tried to use MuseScore on Windows with my Kontakt Player. After many struggles * with Jack MIDI and midiLoop I finally got everything working. Unfortunately it was pointless as some notes were dropped during playback. I don't know if this is an issue with Jack MIDI or midiLoop, but as Jack isn't very user friendly I am only too happy if I can get rid of it. I

-
* one of the was the random (?) assignment of MIDI channels to staves.


Comments

I think I saw #6163 but didn't get that the root of the problem is to behave well as a MIDI source. But I have hopes that in 2.1 (after all the major UI changes etc have settled) MuseScore will have improved MIDI support. Anyway, thanks for this great scrore editor. Better MIDI is just an icing on the cake.

Regarding lasconic's comment:

It would also mean that MuseScore is able to send MIDI events at the right time. Currently, MuseScore relies on Jack MIDI to get this "right time".

I've looked through the portmidi API doc http://portmedia.sourceforge.net/portmidi/doxygen/group__grp__device.ht… for opening an ouput device, and found:

latency is the delay in milliseconds applied to timestamps to determine when the output should actually occur. (If latency is < 0, 0 is assumed.) If latency is zero, timestamps are ignored and all output is delivered immediately. If latency is greater than zero, output is delayed until the message timestamp plus the latency. (NOTE: the time is measured relative to the time source indicated by time_proc. Timestamps are absolute, not relative delays or offsets.) In some cases, PortMidi can obtain better timing than your application by passing timestamps along to the device driver or hardware. Latency may also help you to synchronize midi data to audio data by matching midi latency to the audio buffer latency.

So it sounds like permitting portaudio a few millisecond or so of output latency will allow it to reduce jitter from things like thread context switching, and sounds like portmidi does the heavy work of sending at the right time if I provide a timestamp for each message. I'm wondering if it makes sense to set this latency to the same latency of musescore's internal synthesizer, or if this midi latency should be exposed to preferences.

I'm also trying to figure out if I need to put the midi output message dispatching in its own high priority thread (so is not bogged down by other events), similiar to what is done in this person's port midi test . But I might first try without an additional thread and see if it is good enough.

I say that MuseScore should have a basic portmidi output implemented, and maybe provide a disclaimer such as "If precise midi timing is desired, then use jack." The demand for a simple portmidi output is too high, and jack can be a pain to setup (especially if not on linux).