Friday, June 26, 2009


A very basic Max/MSP patch that I made to be able to convert a floating-point based audio file into four-bit waveforms with integer values. It requires Max/MSP or the freely available Max/MSP runtime. Download the patch here:

Each sample is scaled from -1. - 1.0 to 0 - 15. Each even index sample (0, 2, 4 etc) is written to the low nibble of a byte, while each odd index sample (1, 3, 5 etc) is written to the high nibble of the same byte.

The idea is that samples can then be stored in a way that makes it easy to read back on, say, an Atari 2600 or a Sega Master System or any other sound chip that supports playing back four-bit samples.

So in order to playback the sample, something like this is required (clearly - this is just a concept, not real code):

output to DAC = sample array [index >> ((index%2) << 2)]

In order to use this patch, do the following:

1) Prepare an audio file like you want (probably this involved some pitch shifting, normalisation, filtering etc).

2) Click READ. Load the sample as .wav file into the patch after clicking.

3) Select the number of samples that you wish to read from the file.

4) Click CLEAR, then STOP, then GO, and wait until the INDEX field stops counting up.

5) Double click on the tex object to the left of READ to see the samples - here you can copy and paste your samples.

6) Most likely you will want to add a separator such as a comma (depending on the usage and the target programming language, I suppose). Use a text editor to replace all spaces with comma spaces or whatever separator you require.

7) Paste your samples into your code or wherever you want to use the four-bit audio.


Richard said...

Thank you! I will try this out soon. The explanation is also helpful.