View Issue Details

IDProjectCategoryView StatusLast Update
0008828ardourbugspublic2021-11-30 19:45
Reporterrohanlean Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformGNUOSLinuxOS Version(any)
Product Version6.9 
Summary0008828: Two separate MIDI tracks feeding the same bus can result in overlapping notes
DescriptionWhen two MIDI tracks send their messages to the same bus, then the messages of the first added track will arrive first. This means that a note "On" event of the first track arrives before a note "Off" event of the second track if the notes start and end, respectively, at the same musical time. The events are then directly forwarded to the plugins, resulting in errors because of the overlapping notes. This behaviour is a bit unintuitive and annoying to fix in the midi files.

I assume that the messages are triggered in a single frame (terminology?), so that maybe the bus could sort its incoming messages before forwarding them.
TagsNo tags attached.

Activities

x42

2021-11-29 21:51

administrator   ~0026253

Which backend do you use? mixing is done by the port-engine.
In case this is JACK, this would be a bug in jACK (or pipewire).

Try with Ardour/ALSA.

rohanlean

2021-11-29 22:23

reporter   ~0026254

> Try with Ardour/ALSA.

I did not manage to get audio out with ALSA, but the MIDI messages still had the same issue. Normally I do use the JACK emulation of pipewire, though.

rohanlean

2021-11-29 22:26

reporter   ~0026255

Correction: the MIDI messages have the same issue with "ALSA raw devices" selected as MIDI system, but not with "ALSA sequencer".

x42

2021-11-29 22:28

administrator   ~0026256

I cannot reproduce nor explain why ALSA raw and ALSA sequencer makes any difference here.

Mixing is independent of hardware I/O but performed by the port-engine which is identical for ALSA (raw and seq I/O backends).

JACK 2 used to have an issue with this but this was fixed a few years ago.

x42

2021-11-29 22:30

administrator   ~0026257

Given that you cannot use Ardour/ALSA, it is likely that pipewire still runs and uses the soundcard.
So Ardour cannot use it, and you also end up using PW's MIDI emulation under the hood.

rohanlean

2021-11-29 22:35

reporter   ~0026258

> I cannot reproduce nor explain why ALSA raw and ALSA sequencer makes any difference here.

I have retested and now the messages are sequenced correctly also with ALSA raw. I am almost entirely certain that they were not before.

rohanlean

2021-11-29 22:38

reporter   ~0026259

> Given that you cannot use Ardour/ALSA, it is likely that pipewire still runs and uses the soundcard.
So Ardour cannot use it, and you also end up using PW's MIDI emulation under the hood.

Yeah, I expected something like that. Theoretically Ardour should be able to ask pipewire for full control, it has "org.freedesktop.ReserveDevice1.*" permissions on the session bus.

x42

2021-11-29 22:48

administrator   ~0026260

>Theoretically Ardour should be able to ask pipewire for full control, it has "org.freedesktop.ReserveDevice1.*" permissions on the session bus.

Ardour does that, at least binaries from https://ardour.org/download -- some distros however disable this, or screw this up when packaging ardour.

rohanlean

2021-11-29 22:56

reporter   ~0026261

OK, so it is fixed now for the original tracks that I added, because somewhere along the way their relative sequencing seems to have changed. I have no idea how or why. But when reproducing the bug anew, it triggers consistently again. ¯\_(?)_/¯

So I guess this is almost certainly a bug in PW then, anyway. I will try to report it in the PW bug tracker.

x42

2021-11-29 23:05

administrator   ~0026262

Thanks, if needed you can cross-link this issue to the PW bugtracker.

rohanlean

2021-11-30 09:38

reporter   ~0026263

@x42, could you have a look at the pipewire bug report at https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1868 please? A pipewire developer has some concerns that I think you are more qualified to answer than I.

rohanlean

2021-11-30 18:17

reporter   ~0026264

Based on what you wrote over there: if note-off--note-on at the same time is not technically wrong (and therefore also possibly present in well-behaved external MIDI sources), should Ardour offer a plugin that sorts the events from multiple sources in the same way in which Ardour already sorts the events of a track? Although I would guess that this is so cheap, you might as well just invisibly include it all the time as a courtesy.

I do not quite see how your suggestion of using multiple channels is a solution. Wouldn't that rely on the later consumers of the MIDI stream to discriminate by channel? When I actually encountered this issue, simply switching a channel would not have helped.

x42

2021-11-30 19:02

administrator   ~0026265

Instead of port-connections, you could use aux-sends to a MIDI Bus. This is an Ardour internal connections and events are also sorted there.

rohanlean

2021-11-30 19:45

reporter   ~0026266

Alright, perfect; thank you for your help. I will close this now.

Issue History

Date Modified Username Field Change
2021-11-29 21:42 rohanlean New Issue
2021-11-29 21:51 x42 Note Added: 0026253
2021-11-29 22:23 rohanlean Note Added: 0026254
2021-11-29 22:26 rohanlean Note Added: 0026255
2021-11-29 22:28 x42 Note Added: 0026256
2021-11-29 22:30 x42 Note Added: 0026257
2021-11-29 22:35 rohanlean Note Added: 0026258
2021-11-29 22:38 rohanlean Note Added: 0026259
2021-11-29 22:48 x42 Note Added: 0026260
2021-11-29 22:56 rohanlean Note Added: 0026261
2021-11-29 23:05 x42 Note Added: 0026262
2021-11-30 09:38 rohanlean Note Added: 0026263
2021-11-30 18:17 rohanlean Note Added: 0026264
2021-11-30 19:02 x42 Note Added: 0026265
2021-11-30 19:45 rohanlean Note Added: 0026266
2021-11-30 19:45 rohanlean Status new => closed
2021-11-30 19:45 rohanlean Resolution open => fixed