4klang is a tiny but powerful synthesizer written for making music to fit in 4KB demos. When exporting a song using the VSTi the result is a 4klang.inc
and 4klang.asm
file to be assembled with yasm, and this project export the very same files, but instead they are generated by writing your song in Javascript.
The Javascript api contains simple functions for creating patterns and playing notes, and you can use your programming skills to create loops, generate fancy patterns or whatever.
You'll find example songs in songs folder. So if you e.g. want to test the song groove is in the code, you just symlink it to 4klang.inc.js
in this directory.
The run.sh script is currently tuned for Mac OSX, and there's another runlinux.sh that works for Linux. It will use nodejs to generate 4klang.inc
which then will be assembled with 4klang.asm to create an object file to be linked with 4klangrender.c which will create an executable that creates raw audio data. By piping it into SoX you'll get audio output or you can generate a wav file.
Here's the generated audio output from the example song Groove is in the code