Skip to content

Audio setup · Local FluidSynth · Updated 6 October 2026

Improve FluidSynth MIDI timing

If MIDI notes bunch together or music crackles when you upload files to MiSTer, this optional host-side adjustment may help. It was developed while testing Nightslave with PC98-486 B244, GeneralUser-GS and a USB Wi-Fi adapter.

Updated full-quality configuration. The earlier timing workaround improved gameplay but still had underruns during Nightslave's opening jingle. The new version uses both ARM CPUs and more audio buffering. Three captured-jingle replays, including SD-card uploads, completed with zero observed underruns or stream restarts. Reverb and chorus remain enabled.

Updating an earlier installation? Extract the new download and run its installer again, then reload the core. This version also fixes a process-scan race and supports updating while FluidSynth is running.

The complete core + BIOS bundle includes this helper and a Scripts-menu setup/undo option. Extracting the bundle does not activate tuning.

What changes

  • While PC98 is active, move the HPS USB interrupt to ARM CPU1, away from MIDI delivery and the main audio thread on CPU0.
  • Give MidiLink and FluidSynth's MIDI-input thread real-time FIFO priorities 65 and 70.
  • Launch FluidSynth with two rendering CPUs: main audio on CPU0 and the synthesis worker on CPU1.
  • Use 48,000 Hz, 256-frame periods and sixteen periods of buffering.

Latency tradeoff: the host buffer is now about 85 ms, approximately 64 ms more than the previous configuration. This helps absorb stalls during demanding passages and uploads. Soundfont choice, reverb, chorus, 256 voices and normal interpolation are preserved. Total output latency also includes MiSTer's downstream audio path.

This is a Linux/FluidSynth adjustment; no new FPGA core is required. It preserves your soundfont selection and does not read or rewrite MIDI messages. It is intended for local FluidSynth, not external MIDI modules or MUNT.

Install

The tested system uses MiSTer MidiLink 3.3 BB7 and FluidSynth 2.1.6, with Python 3, taskset and FluidSynth installed at /usr/sbin/fluidsynth. MIDI delivery stays on ARM CPU0 while synthesis is split across both CPUs. Different distributions or soundfonts may need different tuning.

  1. Download the PC98 MIDI timing bundle and extract it.
  2. Copy the extracted folder to /media/fat/Scripts/pc98-midi-timing on MiSTer.
  3. From MiSTer's Linux terminal or SSH, run:
    python3 /media/fat/Scripts/pc98-midi-timing/mister_midi_install.py
  4. Reboot MiSTer, load PC98-486, select local FluidSynth MIDI and start the game again.

The installer backs up /media/fat/linux/user-startup.sh and adds its own marked startup block. It stores the helper in /media/fat/Scripts/PC98_MIDI. The system image remains read-only: a temporary bind mount supplies the launch arguments and is recreated at startup.

Verify

cat /tmp/pc98-midi-timing.log
ps -ef | grep '[f]luidsynth'
cat /proc/asound/card0/pcm0p/sub0/hw_params

With PC98 active, the log should show USB IRQ affinity and thread placement applied. The FluidSynth command should include -r 48000 -z 256 -c 16 -o synth.cpu-cores=2 (process listings may show a space instead of the equals sign). ALSA should report rate 48000, period size 256 and a buffer near 4096 frames; the tested driver reports 4097. Listen during loading and uploads as well as gameplay.

The startup hook survived a full MiSTer reboot on 5 October. The updated two-CPU configuration was verified on a core reset and normal Nightslave startup on 6 October, without manually changing the new synth's settings. This is not a second full-system reboot test. The owner previously reported clean gameplay and repeated HARD RUSHING (STG2) music-test loops; the new configuration's validation uses measured audio underruns. Mounted disks may need selecting again after a full reboot.

Undo

python3 /media/fat/Scripts/PC98_MIDI/mister_midi_install.py --uninstall

Then reboot MiSTer. Uninstall removes the marked startup hook, restores settings still owned by the helper and removes its runtime launch override. It preserves unrelated startup commands and leaves the downloaded files available. A currently running synth keeps its launch settings until restarted.

Scope and limits

The interrupt and priority changes restore their previous values when PC98 exits. Audio buffering is chosen when FluidSynth starts, so reload the synth when changing cores. Large soundfonts or other heavy background work can still overload the host; this helper does not add CPU capacity.

The investigation reproduced the jingle underruns by replaying captured MIDI directly into the Linux synthesizer, without live MIDI delivery from the FPGA. Lower voice limits, cheaper interpolation and scheduling adjustments alone did not eliminate them. Splitting rendering across both CPUs and increasing the buffer passed the final stress tests. No FPGA modification or kernel scheduling-budget change is included. Tests cover one MiSTer/GeneralUser-GS setup, not every soundfont.

If timing still slips, report your core version, MidiLink/FluidSynth versions, soundfont, connection type and whether uploads were running. Include the helper log. Avoid assuming every MIDI timing problem has this same cause.

Background: MiSTer MidiLink and FluidSynth's latency guidance.