library_musicSAMPLE-BASED

SoundFont (SF2)

Full SF2 support for sample-based acoustic instruments. Optimised for massive orchestral or lo-fi layering.

Key Features

library_music

Full SF2 Support

Load any SoundFont 2.0 file. Orchestral, piano, brass, strings — if it exists as an SF2, it works.

speed

24-bit Fractional-rate Oscillators

Sample-accurate playback with fractional-rate resampling for pitch shifting without quality loss.

layers

16-channel Polyphony

Up to 16 simultaneous voices with 8 layers per key for rich, complex instrument patches.

build

Prebaked ScriptedImporter

SF2 files are flattened into SoundFontAsset ScriptableObjects at import time — zero runtime parsing.

tune

Real-time Envelope Control

Adjust attack, decay, sustain, and release parameters from gameplay at runtime.

Quick Start

// Load a SoundFont asset and play a note
var engine = GetComponent<SoundFontEngine>();
engine.LoadFont(mySoundFontAsset);
engine.NoteOn(60, 0.8f);  // Middle C at 80% velocity
engine.NoteOff(60);

Why SoundFont?

Bring your existing SF2 libraries into Unity with zero conversion step. The ScriptedImporter flattens your SoundFont at import time into a native asset — no runtime parsing, no streaming, no memory overhead.

Technical Details

Architecture & Performance

The SoundFont engine inherits from BaseSynthEngineSO, using the shared lock-free command queue and min-heap scheduler for sample-accurate note events.

  • Prebaked SoundFontAsset ScriptableObject via custom ScriptedImporter
  • 24-bit fractional-rate oscillators for sample-accurate pitch shifting
  • 16-channel polyphony with 8 layers per key
  • Zero runtime SF2 parsing — all region data is flattened at import time
  • Energy protection prevents clipping as polyphony grows