Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: Stuck MIDI notes #1341

Open
TubularCorpration opened this issue Jan 26, 2025 · 14 comments
Open

Issue: Stuck MIDI notes #1341

TubularCorpration opened this issue Jan 26, 2025 · 14 comments

Comments

@TubularCorpration
Copy link

Describe the issue

Sometimes MIDI notes get stuck on. Some synth engines seem more prone to it than others but it isn't specific to any one of them, and doesn't correlate to CPU load - for example, I've never had it happen with Osirus/OsTIrus but it's fairly common with OB-XD and many others that are far less CPU intensive, and very common with Helm. Since it's easiest to reproduce with Helm that's what I'll use in my example.

To Reproduce

Steps to reproduce the behavior:

It's hard to narrow it down to any one scenario that causes it, but I am able to consistently replicate it using Helm and sequenced MIDI from my Octatrack. This is not the only thing that causes stuck notes for me but it's the only way so far that I've been able to easily, consistently replicate the problem.

  1. Starting from the Zynthian's default settings, add a new chain with an instance of Helm. Load or create a patch that has a relatively long attack and release (a .zss of the setup I used for testing is in the zip file attached below)
  2. On an external sequencer connected to the Zynthian's DIN input, prepare a sequence containing one long note starting at 00:00:00. In my case the duration is 6 beats at 105bpm but this isn't critical - as long as it sustains for at least three seconds it should be enough.
  3. Configure your sequencer so that it DOES NOT send transport start/stop messages.
  4. Start playback on your sequencer and them quickly stop (less than 1 second between start and stop should work, closer to .5 seconds is definitely fast enough).
  5. Repeat 4 but allow approximately 2 seconds between start and stop.
  6. In both 4 and 5, everything should behave normally with no stuck notes
  7. Configure your external sequencer so that it DOES send transport start/stop messages to the Zynthian
  8. Repeat steps 4 and 5
  9. With the sequencer sending transport messages, the short on/off in step 4 will still behave as expected, but the long on/off in step 5 will consistently produce a stuck note that sustains indefinitely.
  10. The Zynthian's internal all-notes-off command will stop the stuck note, but playing the same note again from an external controller won't consistently "unstick" it.

Expected behavior

Note off messages received from an external device.

Actual behavior

Note off messages from external controllers are sometimes dropped, depending on variables including (but not limited to) duration and whether transport messages are also being received.

Additional context

  • I have also gotten stuck notes through simple playing, without sending any transport messages, but so far I haven't been able to consistently replicate them this way.
  • I've had more stuck notes with the Octatrack than with other MIDI sources but it isn't specific to the Octatrack, and I haven't been able to produce stuck notes on any other hardware I own using the Octatrack as a MIDI source
  • The amount of MIDI data isn't a factor. For example, playing a simple monophonic series of a few notes from the Octatrack's keys will frequently produce stuck notes, but playing a large number of overlapping notes as fast as possible (mashing the keys) on an old Yamaha PF85 for an extended amount of time has never produced a single stuck note.
  • I haven't personally had problems with stuck notes using USB-MIDI, but another member of my band uses exclusively USB-MIDI to play a DIY Zynthian and also experiences stuck notes. I know he has had the same issue with at least two different keyboard controllers.

The attached zip includes a standard MIDI file that were recorded from the MIDI thru on the Zynthian while I was preparing this. They are only useful as a timing reference - playing them back into the Zynthian does NOT produce stuck notes since they don't contain the transport messages (I haven't found a way to record system realtime messages, unfortunately). The first two notes in the file didn't produced stuck notes on the Zynthian, regardless of whether it was also sent transport messages. The second two notes in the file didn't produce stuck notes if no transport messages were sent but DID consistently produce stuck notes when transport messages were sent. Because I have also experienced stuck notes without any transport messages I don't believe they are the root cause, but the fact that I can consistently control whether or not notes stick through a combination of note duration and presence/absence of transport messages.

I also included a MIDI-OX screenshot showing an unfiltered MIDI stream that produces a stuck note.

Zynthian stuck notes.zip

Configuration

Hardware

Raspberry Pi 5 Model B Rev 1.0
Audio: V5 ADAC
Display: MIPI DSI 800x480 (inverted)
Wiring: V5
I2C: MCP23017@0x20, MCP23017@0x21
Profile: v5

System

Debian GNU/Linux 12 (bookworm)
Build Date: 2024-10-02
Memory: 11% (889M/8052M)
SD Card: 8% (33G/470G)
Temperature: 25.2ºC
Overclock: None

MIDI & UI

Tuning: 440 Hz
Master Channel: Off
Preload Presets: On
ZS3 (SubSnapShots): On
Power Save: 10 minutes
Audio Levels on Snapshots: On

Software

zyncoder: oram-2409.2 (36691b3) 
zynthian-ui: oram-2409.5 (5dfe2b0)
zynthian-sys: oram-2409.4 (9cf56bd)
zynthian-data: oram-2409.3 (305b301)
zynthian-webconf: oram-2409.3 (25cda92)
@TubularCorpration
Copy link
Author

TubularCorpration commented Jan 26, 2025

After some more testing, I've determined that it's not the amount of time between the messages that's causing stuck notes, it's the order thy're recieved. It just happens that the Octatrack is more prone to send the noteoff and stop messages in the order that causes a stuck note on the Zynthian when I allow more time between starting and stopping, but I've been able to produce stuck notes regardless of timing. The determining factor is whether the stop message is sent before or after the noteoff. If the noteoff comes first then the Zynthian behaves as expected, if the stop comes first then I get a stuck note.

Correct behavior:

Image

Stuck note:

Image

As I described in the bug report, I've never had a stuck note with any other piece of hardware I've used with the Octatrack since 2017 (which is quite a few different pieces, new and old) and I also get stuck notes on the Zynthian sometimes with other controllers regardless of whether transport messages are sent or not, so it's not inherently tied to the Octatrack itself or to transport messages only, but these two sequences of MIDI messages produce consistent, replicable behavior so it seems like a big clue.

I've been monitoring MIDI from the Zynthian's THRU port for all tests, so it should be completely untouched by the Zynthian software.

EDIT: it's also worth noting that while I was not sending clock from the Octatrack for these tests, in normal use I have it set to send clock continuously, even when its sequencer is stopped. So while the fact that I have experienced stuck notes while the Zynthian from the Octatrack's keys with its sequencer stopped means that the problem isn't tied specifically to transport messages, the fact that I have always had clock running means it could be tied directly to system realtime messages in general.

Later this week when I have time I will try to figure out whether there's a correlation between whether or not a synth accepts clock (i.e. for LFO or arpeggiator sync) and whether or not it is prone to stuck notes. I have never experienced stuck notes with Fluidsynth of VL-Tone, for example, and I'm fairly confident that all of the synths that I HAVE experienced stuck notes with are those that can sync to clock.

@BenMcLean
Copy link

BenMcLean commented Jan 27, 2025

I've had at least some stuck notes with every external MIDI controller and synth module combo I've ever used, not just the Zynthian. I think the only solution to truly eliminate stuck notes is to just not use external MIDI controllers. Period.

However, some are a lot worse than others, so it can probably be improved. I'm just saying that actually eliminating stuck notes is unlikely, so make sure you have a MIDI panic button mapped.

@riban-bw
Copy link

I can't reproduce this in the lab with a script sending these MIDI commands to zynmidirouter input. (Same input as DIN-MIDI.)

The timestamps in your screenshots are in hex but there are no units. I see a single unit of time between the 1/2 and between the 3/4 and 305 units of time between 2/3. I suspect they are ms.

Sending messages with these ms timeoffset (or other, longer intervals) does not triggers the problem for me. Webconf shows the messages received in the same order as they are transmitted.

@TubularCorpration
Copy link
Author

TubularCorpration commented Jan 27, 2025

The different order off messages is happenign in the Octatrack, sorry if that wasn't clear enough. I've submitted a ticket with them but I don't expect it to amount to anything since they haven't updated it in years.

The reason it's relevant here is that, for me, the order that the note off and stop messages reach the Zynthian (from and Octatrack) is the one variable I've found that consistently leads to stuck notes and allowed me to replicate the issue consistently, but it's not the only thing that causes them and the Octatrack isn't the only device that I get stuck notes with. The source of the MIDI notes and the synth engine that they are routed to in the Zynthian influence how common stuck notes are but it has been hard for me to replicate them with any kind of predictability, that's why I didn't submit a ticket sooner. I think this is less a report of a specific bug and more a data gathering expedition to see if we can collectively figure out a common factor that would help mitigate or eliminate stuck notes.

There were a few threads specifically about it back around 2019 and it has come up in other threads since then, but the whole thing is pretty nebulous and the old threads never gained any traction.

https://discourse.zynthian.org/t/stuck-notes-w-dx7/3464
https://discourse.zynthian.org/t/stuck-notes/2894
https://discourse.zynthian.org/t/helm-seems-to-have-a-problem-with-stuck-notes/4897

Another data point that might help narrow things down is that, for me at least, I have never experienced or been able to deliberately cause a stuck note with Fluid Synth. I rarely use the other standalone engines, but this evening or tomorrow I'll find some time to see if I can deliberately cause stuck notes with ZynAddSubFX or any of the others. It's totally plausible that only LV2 engines experience them. If I can get one of the standalone engines to stick at least it would rule that out.

At some point in the next week my friend who uses a DIY Zynthian will be over to work on writing, I'll try to have him bring it and take some time to explore the stuck notes that he gets. He uses a Pi 4, no official hardware and only USB MIDI, whereas I'm using primarily DIN MIDI on official hardware with a Pi 5, but we both experience stuck notes. Between our two systems we pretty much rule out every variable on the hardware side.

If there's any specific information you want me to collect or things you want me to try, please let me know.

@rv0
Copy link

rv0 commented Jan 27, 2025

I've been having same issues the whole day.

I'm using the Hapax as sequencer. Midi cable goes straight into the Zynthian (latest V5 batch, have it since last week and installed the updates).

It's indeed very random as to when and which synth it happens with. After reboot the issue is gone (until its back).
This snapshot I'm using atm has 2x Noize Mak3r, 1x ZynAddSubFX, 1x Dexed, 1x Helm, 1x JC303.
But I'm not playing all of those at once, nor am I sending lots of notes. In fact, once it starts happening, it keeps happening even if I play a single note on my midi keyboard. In my case now, it happens with Dexed, but I've seen it happen with other instruments as well.

@rv0
Copy link

rv0 commented Jan 27, 2025

edit: there was a snapshot here with the issue, but eventually it turned out to be sustain pedal engaged, so not relevant here

@riban-bw
Copy link

riban-bw commented Jan 27, 2025

The original report was against current oram stable (2412.5). Has anyone tested against staging (oram) or testing (vangelis)? I can't seem to make this go wrong on my test machine here in the lab.

[Edit] I just switched to oram stable 2512.5 and the first F4 note I played got stuck...

[Edit] ...but that is because the snapshot has the sustain pedal asserted!

@rv0
Copy link

rv0 commented Jan 27, 2025

Oh uhm.. My bad I guess. I'm very new to Zynthian. Will research it.
EDIT: You're absolutely correct. I don't know how that happened. Very odd. Sorry for the noise!

BTW, OT perhaps, but my machine says 2409.4 is latest Oram stable, not 2412.5 (and I had just run the update again)

@TubularCorpration
Copy link
Author

I assembled mine in the first week of December last year and the stuck notes have been consistent across every stable version of the OS since then, So I guess that would be 2409.2. I reflashed my card when 2409.3 came out.

@riban-bw
Copy link

It would be useful if someone who experiences this, check if the sustain pedal control in the affected engine is asserted during the fault state

@TubularCorpration
Copy link
Author

I can do that later tonight, but the way it behaves for me I don't expect that to be the problem. After a note gets stuck I can keep playing notes and they behave normally while the stuck note stays stuck.

I'm pretty sure once a note is stuck playing the same note a second time (which sends a new note-off message and would be expected to unstick the stuck note) doesn't work but I haven't tested that carefully yet, I just tried it a couple times during a practice a few weeks ago and it didn't seem to work. The internal all-notes-off/panic button always works for me.

@TubularCorpration
Copy link
Author

TubularCorpration commented Jan 27, 2025

I just checked the sustain status. Used the same method I described in my initial bug report to stick a note in Helm, opened up the MIDI Controllers parameter page and confirmed that the controller widget for sustain was still displaying "off."

EDIT: while I was emailing with Elektron support earlier today I also realized that the reason the STOP and NOTE OFF messages in my screenshot have the same time stamp is probably because I was monitoring the DIN MIDI data stream through a USB MIDI interface. The USB 1ms frame rate is slower than the MIDI data rate so it's possible for the interface to receive more than one MIDI message during a single USB frame. Because MIDI data isn't timestamped, all MIDI messages that arrive during a single frame occur "simultaneously" as far as the computer is concerned. That's the reason why it's impossible for standard USB MIDI interfaces to achieve jitter lower than 1ms and I would assume it applies to the timestamp accuracy of MIDI-OX with a USB interface, too.

I switched to an RTP-MIDI interface on my desktop because the MIDI timing with USB interfaces was always too loose for me; I won't have time until Thursday but I'll try to remember to check with that and see if the stop and note off messages from the Octatrack are still identical when I have finer resolution. If I find a timing difference maybe Riban's script will be able to give us reproduceable stuck notes if it's adjusted to reflect that.

@TubularCorpration
Copy link
Author

Elektron suport was able to replicate the message order issue that I've been using to reproduce stuck notes on the Zynthian. Here's a more accurate log of MIDI events from them that could be helpful for us.

This is the sequence of MIDI messages that will cause a stuck note for me on the Zynthian 100% of the time (at least when using the snapshot I included with my original report) with accurately logged timing between the start/note-on and stop/note-off messages:

Image

"For context I believe that the MIDI frame duration on the Octatrack is 15ms, which means that the messages is sent in two successive different frames. "

@chrismatthews
Copy link

I was able to reproduce my issue tonight using the attached midi file in loop for 1hour 40mins, externally through the DIN Plug to the V5 (pi4) on current oram stable. I was sending only Notes On and Off with Sustain pedal using only Pianoteq

Take2_MIDI 1-1.1.zip

The loop was continuous and so no changes to the system during the running time and until the issue no XRUNs in the logs, once the issue was heard, I had lots of them, no temperature change - under 40C CPU at ca 50%. After restarting the zynthian service everything was normal again (no reboot was needed)

Jan 29 21:05:28 zynthian startx[900]: WARNING:zynthian_autoconnect.cb_jack_xrun: Jack Audio XRUN! =>count: 150, delay: 305.0us
Jan 29 21:05:32 zynthian startx[900]: WARNING:zynthian_autoconnect.cb_jack_xrun: Jack Audio XRUN! =>count: 151, delay: 68.0us
Jan 29 21:05:33 zynthian startx[900]: WARNING:zynthian_autoconnect.cb_jack_xrun: Jack Audio XRUN! =>count: 152, delay: 198.0us
Jan 29 21:05:45 zynthian startx[900]: WARNING:zynthian_autoconnect.cb_jack_xrun: Jack Audio XRUN! =>count: 153, delay: 57.0us
Jan 29 21:05:49 zynthian startx[900]: WARNING:zynthian_autoconnect.cb_jack_xrun: Jack Audio XRUN! =>count: 154, delay: 83.0us

I'll run the same test tomorrow via the USB and let you know, small steps, after that I'll move to vangelis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants