Special FX
Special FX is a SoundFont (SF2) synthesiser for my game Ring Village, built to run on DOS machines. It plays SoundFonts in integer-only C, so its output is bit-identical on DOS, Windows, x86 and x64. On DOS it drives a real Sound Blaster 16, streaming audio to the card rather than running in an emulator.
A song written for Special FX.
Details
- SoundFont loading. Walks the SF2 RIFF chunks, reads sample data in place without copying, and sorts presets by bank and program.
- Voices. Up to 64 voices across 16 MIDI channels. When it runs out, it steals the quietest releasing voice, then the oldest. Samples play with linear interpolation and loops.
- Synthesis. Each voice has volume and modulation envelopes, two LFOs and a resonant low-pass filter, with SoundFont modulators in all four curve shapes. It also supports constant-power panning, exclusive classes, the sustain pedal and pitch bend. Control values update every 64 frames, with gains ramped smoothly in between.
- Per-note expression. Pitch, volume, pan, cutoff and resonance can change while a note plays, so slides glide like they do in a DAW.
- Effects. A Freeverb-style reverb and a stereo chorus that doubles as an echo of up to 4 seconds.
- Sound Blaster 16 output. On DOS it finds the card from the BLASTER environment variable and plays through a real Sound Blaster 16.
FL Studio plugin
Special FX also runs as a native FL Studio instrument, compiled from the same synthesiser source, so a SoundFont auditioned in FL sounds exactly as it will in the game. In "Game rate" mode it renders at the game's 22,050 Hz and upsamples with a windowed-sinc filter. FL's slide notes drive the per-note pitch, volume, pan and filter changes. It builds as both 32-bit and 64-bit plugins.
Ongoing work
I'm building a full pipeline for authoring Special FX music in FL Studio. A set of Python scripts reads the FLP format and exports each song as a MIDI 2 file, and a music player on the game side plays it through Special FX. I've proven the approach with prototypes, and it's a work in progress. Slide notes work.