SynthstromAudible / DelugeFirmware

https://synthstromaudible.github.io/DelugeFirmware/
GNU General Public License v3.0
551 stars 88 forks source link

Severe Trigger Clock Dropouts #2144

Closed acook closed 2 days ago

acook commented 2 weeks ago

Please describe the problem:

Alternate title: Trigger Clock Output Fails to Meet Realtime Deadline

When using the analog clock at the gate output, it will randomly stop transmitting for long periods.

On 8aa506f this happens after a few seconds. According to @m-m-adams it happens after a few minutes on Release Candidate 3 564cba31cd14d9fbfc16a28114ab6d4dba9441e6.

What is the expected behavior?

The trigger clock putters along more-or-less constantly, within a margin of error that most humans (and downstream sequencers) consider indistinguishable from lock-step.

Is there a relevant Pull request?

No response

What hardware did you reproduce it with?

OLED

What firmware did you reproduce it with?

Nightly

What is the firmware name:

8aa506f

If possible provide the steps to reproduce the issue and upload additional media:

  1. Turn on
  2. Configure output 4 for clock
  3. Set desired PPQN (happens at any but more obviously with larger PPQN)
  4. Hook up something to watch the clock output
  5. Press play
  6. Wait a few seconds (typically less than 30) and the clock output will stop and then restart, this will continue to happen over and over again at apparently random intervals

Additional Info

Tested with multiple downstream devices, but it is so severe that it is visible with the naked eye.

Watching a blinking LED connected to the output is sufficient to detect the dropouts at higher PPQNs, it is that major! The LED (or any downstream sequencer/clock divider) will receive no signal at all for up to nearly a second(?!) before the Deluge resumes transmitting, leaving the downstream devices hopelessly out of sync.

The improvements between the latest nightlies and the current community branch is likely due to improvements in the yield/scheduler code that have gone in, but it remains. I'm not sure what commit introduced the issue.

NOTE: This is different to the other analog clock output bug that I reported.

UPDATE 2024-06-19

Some attempts at code fixes have improved the situation, so that the dropouts occur less often, sometimes only after dozens of minutes (depending on the BPM). But the issue persists and the underlying cause has not yet been identified. What is suspected is that the flag which tells the Deluge when another clock pulse is needed gets double set, resulting in triggers being delayed. @m-m-adams noticed that something similar happens in MIDI, where the number of ticks per minute is correct but get delayed and bunched up. This may be the same behaviour happening with gates, but the gate circuitry isn't fast enough to send all of those pulses so close together so they all get blended together, resulting in the clock not being transmitted in discrete pulses but instead as a single gate.

m-m-adams commented 2 weeks ago

When the clock falls behind it attempts to catch up by sending two clocks at once, resulting in inconsistent midi clock and no gate output.

The clock falls behind when two ticks need to be output in the same render window. As the nightly build is targeting larger consistent window sizes this now occurs more frequently, however it is present in official and the RC as well (#2132 and unstable midi clock reports on discord).

The fix will likely be to proactively schedule ticks further in advance

m-m-adams commented 3 days ago

I think I've got it - if you could test the build from the linked PR that would be great, but it's been stable for over an hour now

There might still be issues but they should manifest as jitter instead of entirely doubled midi clocks and skipped gate clocks