Create raw samples for sound effects and music in JS and C/C++. The synthesizer is a port of Sonant, the tracker is written from scratch.
pl_synth is implemented in multiple different ways. The release files are self-contained, i.e. you only need to use one of these files in your project.
release/pl_synth.min.js
- the minified version of the vanilla JS implementation. 1.2kb gzipped.release/pl_synth_wasm.min.js
- the minified version of the JS+WASM implementation. The compiled WASM is embedded. 2.5kb gzipped, but about twice as fast as vanilla JS. Recommended if you're not size-restricted.c/pl_synth.h
- a single header library for C/C++
Songs and sound effects can be created with the tracker software contained in tracker.html
. After cloning this repo, the tracker can be launched with a simple doubleclick (i.e. it loads fine from a file://
url). The only requirement for the tracker is release/pl_synth_wasm.min.js
.
An online version can be found at https://phoboslab.org/synth/
- Drop by no-fate.net
- Q1k3 by no-fate.net
- Underrun by no-fate.net
- Voidcall by no-fate.net
- Liver by m / Bits'n'Bites
- Regressions by m / Bits'n'Bites
- Beatnic by m / Bits'n'Bites
- Frank 4k by m / Bits'n'Bites
- Synth 4k by m / Bits'n'Bites
- Chippy by m / Bits'n'Bites
- Fabrik by wullon / adinpsz
- Microscope by Ferris / Youth Uprising
- Chill by Ferris / Youth Uprising
- Poseidon demo song by Ferris / Youth Uprising
- Haumea Drums by Ferris / Youth Uprising
- Ambidumbi by Gargaj / Ümlaüt Design
In a browser, load the pl_synth_wasm.min.js
, instantiate pl_synth and then
use synth.sound()
and synth.song()
to create WebAudio AudioBuffers. These
AudioBuffers can be re-used for multiple AudioBufferSourceNodes, so you only need to generate them once.
When using the JS+WASM version, this asynchronously instantiates pl_synth with the given AudioContext.
When using the vanilla JS version, this instantiates pl_synth with the given AudioContext. Returns the synth instance.
Creates a single sound effect with the given instrument data (as created with the tracker), and an optional note and row_len. The default note value 147 correspondes to a C-5 note. The default row_len correspondes to 120 BPM. Returns a WebAudio AudioBuffer.
Creates a whole song with the given songData (as created with the tracker). Returns a WebAudio AudioBuffer.
<script src="pl_synth_wasm.min.js"></script>
<script>
// Create a new WebAudio context
let audioContext = new AudioContext();
// Instantiate the JS+WASM pl_synth. Since we need to compile the the embedded
// WASM module you need to wait for the callback to use it.
pl_synth_wasm_init(audioContext, (synth) => {
// Create a sound effect
buffer = synth.sound([7,3,140,1,232,3,8,,9,1,139,3,,4611,1403,34215,256,4,1316,255,,,,1,,1,7,255]);
// Create a WebAudio AudioBufferSourceNode and play it
let source = audioContext.createBufferSource();
source.buffer = buffer;
source.connect(audioContext.destination);
source.start();
});
</script>
Also have a look at example.html
.
For usage of the native C/C++ version please refer to the documentation within c/pl_synth.h
and have a look at
c/example.c
. This uses pl_synth.h
to generate some music and saves it as example.wav