SoundFont Piano
App: apps/soundfont_demo/
A playable computer-keyboard piano driven by a SoundFont (.sf2) bank (engine PLM-134 / ADR 0043).
It loads a bank with SoundFontInstrument and voices notes as real polyphonic audio
through the streaming audio sink — no MIDI hardware required, the QWERTY
keyboard is the keyboard.
Get a bank first
Section titled “Get a bank first”The bank is a large, licensed asset, so it is not committed — it is loaded at runtime like any other
audio resource. Fetch the default YDP Grand Piano (CC-BY 3.0, FreePats / Zenph) once, into the app’s
soundfonts/ folder — see apps/soundfont_demo/README.md for the exact command. Any General-MIDI .sf2
works; drop it in and point main.wren at it. If the bank is absent the demo still runs and shows a hint
instead of crashing.
Run from root
Section titled “Run from root”% ./plume3d soundfont_demo- White keys:
A S D F G H J K L— one octave of natural notes (C D E F G A B C D). - Black keys:
W E T Y U O— the sharps/flats. - Octave:
Zlowers,Xraises. - Sustain: hold
Space(MIDI CC 64).
A small GUI window shows the loaded bank name, the current octave, and the live active-voice count.
What it does
Section titled “What it does”- On
init, loads the bank withSoundFontInstrument.new("soundfonts/YDP-GrandPiano.sf2", 48000, 2)and selects preset0. - Each
update, it edge-detects the mapped keys (press →noteOn, release →noteOff) and mapsSpaceto the sustain pedal viacontrolChange(64, …). The engine renders and queues the audio automatically.
Key pattern
Section titled “Key pattern”import "engine" for SoundFontInstrument, Input
// init: load a bank and pick an instrument._inst = SoundFontInstrument.new("soundfonts/YDP-GrandPiano.sf2", 48000, 2)_inst.setPreset(0)
// update: just trigger notes from ANY source — the engine keeps the audio flowing.if (Input.key("a") && !_wasDown) _inst.noteOn(60, 0.9) // middle C_inst.controlChange(64, Input.key("space") ? 127 : 0) // sustain pedal- SoundFontInstrument — load a bank, select a preset,
noteOn/noteOff/controlChange/pitchBend(the engine renders its audio automatically). - Audio — the streaming sink the instrument renders into.
- Input —
key/keyJustPressedfor the keyboard piano. - Gui — the status window.