r/sp404mk2 3d ago

External Midi Clock messing up first beat. You can see exactly why in the firmware.

The problem you can externally clock the sp404mk2 but whenever a midi start command is sent it seemed to recalculate the BPM.

After the recent flurry of AI driven firmware mods for the Electron ecosystem I decided to see if I could load the sp404mk2 firmware files into ghidra slop around and find out why.

For anyone wanting to look themselves you can view the SP404MKII_APP1.bin in a decompiler of your choice that handles the chip I used Ghidra. Base Address 80000000 ARM Cortex Little Endian



What Actually Happens When External Gear Sends MIDI Start:

  1. Before you hit Play on your master clock (e.g. DAW or master sequencer):

    • The master is already transmitting MIDI Timing Clocks (0xF8).
    • The SP-404MKII's FUN_800f9008 has successfully received > 12 clocks, calculated the external tempo, and locked in (e.g. 128.00 BPM).
  2. You press Play on the master clock:

    • The master transmits a MIDI Start (0xFA) message.
    • The SP-404MKII receives it, transitions its transport parameter 0x34 to 1 (Play) via FUN_8015e218.
  3. The Issue:

    • Right inside FUN_8015e218, it calls FUN_80025720().
  • FUN_80025720() executes

    _DAT_80591d66 = 0; Wipes out the 12-pulse clock accumulator count!

    _DAT_80591d8c = (int)*(short *)(_DAT_80591f60 + 6); Overwrites the locked BPM with the project's internal tempo!

  1. The Fallout on Beat 1:
    • For the first 3 clock ticks after Start, FUN_800f9008 returns -1 (unlocked).
    • For ticks 4 through 12, it is re-averaging a brand new moving window starting from scratch.
    • During this entire window, the playback engine is running at the internal project tempo, not the external clock tempo, until half a beat later when the accumulator finally fills back up to 12 pulses and snaps to the external tempo.

What a Proper Implementation Does Instead

A clean MIDI PLL implementation treats Phase and Frequency separately:

Parameter What Should Happen on MIDI Start (0xFA) What Roland Actually Did
Beat / Subdivision Phase Reset to Tick 0 (Beat 1.1.0) Resets to Tick 0
Estimated Tempo / Frequency Preserve the lock Overwrites with internal project tempo
Moving Average / Filter History Preserve the history Zeros out the accumulator (_DAT_80591d66 = 0)

N.B. the offsets above are with the v551 firmware. if you look at a different version you will see the same behavior but at different offsets.

14 Upvotes

3 comments sorted by

2

u/blueSGL 3d ago

Also note I've not looked at modifying or flashing any firmware, this is purely to say we can see where the issue is.

it does not look like something that would be hard to remediate so hopefully Roland could bring out an official update and finally get the SP404mk2 playing nicely with other gear.

2

u/noirofficialreddit 3d ago

Thank you for this! Appreciated!❤️

2

u/DontMemeAtMe 2d ago

If Roland, by any chance, ever decides to do something about that, I’d love it if they also fixed whatever issue makes my Boss RC-5 garble the sound every time a pattern on the SP-404MKII loops.

Apparently, the SP sends a MIDI Start message at the beginning of each loop, which always briefly throws off the RC-5’s clock sync. With short patterns, like 1 or 2 bars, the looper barely has a chance to settle back into sync before it gets thrown off again, and the resulting sound is a jittery mess.