Binaural beats for brain-synchronization, now available for the web!
This adds SDL2 audio support to sbagen for a more cross-platform & modern system. It can be built on any platform that supports SDL, including WebAssembly.
- ✅ SDL2 audio support for cross-platform compatibility
- ✅ Modern macOS support (fixed Carbon/CoreAudio issues)
- ✅ WebAssembly build for browser usage
- ✅ OGG Vorbis support (native only)
- ✅ MP3 support with libmad (native only)
# Default build (SDL + OGG + MP3)
npm run build
# Run examples
./build/sbagen -i 440+5/5 # Play 440Hz + 5Hz binaural beat
./build/sbagen -i 100+10/10 # Lower frequency tones
./build/sbagen -p drop 00ds+ # Pre-programmed sequences# Build for web
npm run wbuild
# Start demo server
npm start
# Then open http://localhost:8080npm install sbagenimport sbagen from "sbagen";
// Load an SBG file
const sbg = await sbagen(await fetch("example.sbg").then((r) => r.text()));
// Add audio files to the virtual filesystem (for mixing)
const riverBytes = new Uint8Array(
await fetch("examples/river2.ogg").then((r) => r.arrayBuffer()),
);
sbg.addFile("river2.ogg", riverBytes);
// Play the sequence
sbg.play();Initialize sbagen with (optional) SBG file content.
-
addFile(filename: string, bytes:Uint8Array): voidDownload a file and add it to the virtual filesystem for use in sequences. -
play(duration: Number): voidStart playback of the sequence, optional duration (in seconds.) -
stop(): voidStop playback and reset position. -
run(args: Array<string>): voidRun sbagen with any arguments you like
- CMake 3.16+
- SDL2
- libvorbisfile (for OGG support)
- libmad (for MP3 support)
- pkg-config
- Emscripten
brew install sdl2 libvorbis mad pkg-config cmakesudo apt-get install libsdl2-dev libvorbis-dev libmad0-dev pkg-config cmake