index

Article posted on: 2022-03-29 20:51
Last edited on: 2022-04-02 14:40
Written by: Sylvain Gauthier

Release: sndc

sndc is a sound compiler a bit like LaTeX is a document compiler. You give it a .sndc file and it will output a sound from it, always the same sound bit for bit on any machine regardless of the processing power.

It aims at being a suckless way of quickly hacking sound effects and potentially even music. It consists of a core, static library libsndc.a that you can easily import into other projects or if you wish to build a different interface on top of it, as well as a sndc executable to perform the actual sound compilation, and two wrappers sndc_play and sndc_export to respectively play sndc’s output using aplay and export it into whatever audio format using sox.

I’ve been working on it for about a year now. It is inspired by sfxr, a small program to quickly create video game sound effects. I won’t number versions as I expect it will be a continuous rolling-release as more modules are added.

How to build

Dependencies:

$ git clone https://pedantic.software/git/sndc
$ cd sndc
$ make install PREFIX=<path_to_installation> # PREFIX defaults to /usr/local

Features

Global features:

Builtin modules

How to use

sndc files are a simple description of a node stack. Each node is an instance of a module, either builtin or imported from another sndc file.

nodes have input and output data. data can be either float, buffer (of floats) or string. A node is only called once during the stack processing, will consume its inputs and produce its outputs. nodes are processed sequentially in the same order as they appear in the sndc file.

nodes inputs can be literal floats or strings or they can be connected to the output of nodes above them in the file. Connecting the input of a node to the output of a node after it will produce an error.

sndc will dump the first buffer of the last node in the file given to it as an argument, as a raw stream of binary float32.

The README.md file gives more details on the exact syntax of the language, and the examples folder gives plenty of examples including complex melodies with external keyboard file and layout file.

I might start a series of blog posts on how to properly use each module, the workflow I came up with to design sounds with it and how to write C modules.