SoundFont 2 synthesizer
Every note you hear from alphaTab is synthesized on the fly โ there are no pre-rendered instrument recordings in the box. alphaTab converts the score into MIDI, feeds that stream to a built-in software synthesizer that plays samples from a SoundFont 2 (.sf2) file, and mixes the synth output into the platform's audio backend. Swap in a high-quality sampled piano, a genre-tuned drum kit, or a guitar amp emulation and the same pipeline produces very different audio.
The current synthesizer implementation is derived from TinySoundFont โ a huge thanks to Bernhard Schelling and the TinySoundFont contributors whose work made the initial synth possible. A next-generation synthesizer is in active development; both share the same public API surface, so anything on this page continues to hold when the new engine ships.
The pipelineโ
Every note you hear passes through four stages:
- Score to MIDI. alphaTab generates a MIDI stream from the loaded score โ one channel per track, with pitch bends, program changes, and metronome events layered in.
- MIDI to sample buffers. TinySoundFont looks up the requested MIDI program and note in the loaded SoundFont, plays back the matching sample zone, and applies the SoundFont's envelope, filter, and modulation curves.
- Sample buffers to the audio backend. The synth hands finished PCM chunks (
bufferTimeInMillisecondsworth at a time) to a platform-specific output. - The backend drives the speakers. Web Audio through an AudioWorklet on the browser,
NAudioon .NET,AudioTrackon Android.
Everything upstream of stage 3 is portable across platforms. The backend at stage 4 is the only piece that swaps out per runtime.
The bundled SoundFontโ
alphaTab ships with a compact, permissively-licensed SoundFont derived from the Sonivox General MIDI set. It covers the full GM instrument list plus drums and totals a few megabytes. That is enough to make any Guitar Pro or MusicXML file audible without extra downloads.
For higher-quality guitars, orchestras, or drum kits, replace it with a purpose-built SoundFont โ see Custom SoundFonts. To layer several instrument packs at once (guitars from one file, pianos from another), see Combining multiple SoundFonts.
Show it in codeโ
import * as alphaTab from '@coderline/alphatab';
const container = getAlphaTabContainer();
const api = new alphaTab.AlphaTabApi(container, {
core: { file: '/scores/song.gp' },
player: {
playerMode: alphaTab.PlayerMode.EnabledSynthesizer,
// On Web the bundled SoundFont ships via the assets folder; the Vite / webpack
// plugin points this URL at the shipped file. Override to swap in your own.
soundFont: '/assets/sonivox.sf2',
},
});
api.soundFontLoaded.on(() => {
console.log('SoundFont ready โ playback can start.');
});
getAlphaTabContainer() is a placeholder for the platform-specific step of obtaining the render target โ a <div> on Web, an AlphaTab control on .NET, or an AlphaTabView on Android.
On .NET and Android there is no automatic download step; call api.loadSoundFont(bytes) with the SoundFont bytes you read from disk or a resource. See Custom SoundFonts for the byte-buffer pattern.
Where to look nextโ
- Custom SoundFonts โ swap the bundled synth voices for your own.
- Combining multiple SoundFonts โ layer several
.sf2files into one synth. - Audio buffer size โ the latency and stability trade-off for stage 3.
- Web Audio and AudioWorklet, NAudio (.NET), AudioTrack (Android) โ the per-platform backends at stage 4.
api.loadSoundFont,api.soundFontLoaded, andplayer.soundFontโ the properties that drive the pipeline.