RE:FORM Synth
The music in RE-FORM was created in a modified version of fasttracker II clone
In the modified version, you can use the name fields of instruments and samples to code procedural instruments. When saving the xm file, C source code to play it is also saved.

So in the screenshot above, the selected instrument begins =mi7(t,0.25, and then continues ,env(t,0.33...
So what does it mean?
=mi7( // supersaw minor 7 chord
t, // phase / time
0.25, // rate multiplier for extra-note
// (using 2 octaves down for
// a wider/fatter sound )
env(t, 0.33) * 0.8 + 0.3,
// low pass (enveloped)
0.0, // high pass (off)
9, // voices
4, // detune amount
t/2000,// detune phase (slow modulation)
1 // stereo-spread (full)
) * 1.4 // chord gain
+
n( // smoothstep interpolated noise
ena(t, 1.2) * 65
// ena == integrated version of env
// - simulating subtle filtered
// noise to add some complexity
) / 16.0 // noise gain
These are all just functions though so there are no real filters, just stateless approximations. The code snipped is just returning sample value and the arguments are:
t- time/phasep- pattern time: position within the current mod patternr- (is) right channel ,0= left,1= righta- accumulated, value of output buffer, this is used to implement crude side-chaining on the last channel.
Implementation
Very ugly.
Parts:
- Modified version of expr (by Serge Zaitsev) - Expression evaluator with C-like syntax
Steep- Sound library in C, optionally wrapped so it can be executed in run-time through expr (wrapped version used in ft2, and plain C version used in exported C code)modhack, Modified version of Micromod (by Martin Cameron) - handles playback for C export, also contains code for steep vs ft2 integration and C-code-gen.- Compression - Two kinds of compression, one experimental designed to be streamed/compressed-in-memory (combined rle/delta), and a plain 8-bit LZ77. (It turned out we did not need compressed-in-memory anyway)
Steep Functions (not complete)
d(t, [shape=0])- decay. shape: 0 = exponential, 1 = linear, > 1 = rect-ishad(t, [attack, shape=0])- attack-decay, attack is relative to decay (0..1)
env(t, [decay=1], [attack=0])- exponential envelope with anti-click fade-inena(t, [decay=1], [attack=0])- env area (integral ofenv)w(t, [waveform=0], [lp=1], [hp=0])- unified oscillator: waveform: 0 = saw, 1 = square, 1..4 = pulse width; lp: lowpass, hp: highpass.n(x),nm(x)- smoothstep-interpolated noise (stereo/mono)smp([filter=0], [stereoWidth=1])- play sample. filter: 0 = nearest, 1 = linear, 2 = smoothstepss(t, [n=10], [detune=1], [phase=0])- super sawma/mi/su2/su4/ma7/mi7/mm7- super saw chordssaw(t)/sqr(t)/tri(t)/pw(t, [width=0.5])- basic waveforms
Maths / Util
fl(x)- floorsq(x)- squarem(x)- modulator:0.5 - 0.5*cos(x*pi*2)fr(x, [scale = 1])- fractional:x - floor(x/scale)*scalecl(x, [a=-1, b=1])- clamp toa..bmix(a, b, [x=0.5])- interpolationsgn(x)- signsin/cos/exp/log/min/maxetc
Drawbacks
- Dense syntax can be fun, but it is also totally incomprehensible
- Editing; these are individual edit-fields, so adding a line means cut’n pasting all below manually one by one. Also, there is no undo/redo
- If you do something more advanced, you can only see part of it while editing
- This is hacked into the sample playing in ft2 clone, so the xm need to have long samples everywhere even for instruments that are completely procedural (but they are not exported to C code)
- If you write
1/3it’s 0.333 in ft2, but 0 in C (The code is actually not converted to C, it’s just pasted as-is, and the evaluator always returns floats, this also results in a ton of type warnings) - The generated playback code is slow (switch case per sample, and stateless/fake filters need more cpu)
- My tracker skills are rusty, so I would prefer a vst experience like 4klang / sointu…
- C don’t support default arguments, so implementation ends up like this:

The useful parts
I had accumulated a lot of sound design sketches in madtealab, and this was the first time I played with them in more of a music composition context. So this part was quite fun.
I mananged to make some nice sounds with this ft2 build, but I’m not sure if that’s because of the weird environment or in spite of it…
A function that was used for almost all synth sounds is a combined oscillator with fake filters.
w(t, [waveform=0], [lp=1], [hp=0]):waveform0 = saw, 1 = square, 1..4 = pulse width;lplowpass cutoff,hphighpass cutoff.
For instance, the reese-like bass is w() with interpolated noise controlling waveform and filter (and then hard clipped for some distortion).
float w(float x, float waveform, float lp, float hp) {
float vol = 1.0f;
if (lp > 1.0f) { // support combined
hp += max(0.0f, lp - 1.0f); // lp/hp filter
lp = 1.0f; // range 0 - 2
}
lp = (lp * 3.0f - 1.0f) / 2.0f; // guarantee
if (lp < 0.0f) { // silent output
vol = max(0.0f, 1.0f + lp * 2.0f); // for lp <= 0
lp = 0.0f;
}
lp *= 0.973f; // band limit
// range -1-0 sqr -> saw
float sqr = min(1.0f, waveform); // range 0-1 saw -> sqr
float pw = max(0.0f, waveform - 1.0f) / 3.0f; // 1-4 pulsewidth
x -= pw / 4.0f; // phase compensation
sqr *= sqr; // sounds more linear...
float f = 1.0f - 1.8f * pow(1.0f - lp, 4.0f); // filter curve
vol *= 1.0f - sqr * (0.232f * (1.0f - lp) + 0.268f);
float y = (x - floor(x)) * 2.0f - 1.0f;// saw0
float s0 = (y*y*y-y) / (f*y*y-1.0f); // fake filter
x += 0.5f + pw / 2.0f;
x = (x - floor(x)) * 2.0f - 1.0f; // saw1
float s1 = (x*x*x-x) / (f*x*x-1.0f); // fake filter
if (hp > 0.0f) { // high pass
hp = min(1.0f, hp);
float hpm = 1.0f - min(1.0f / 3.0f, hp) * 3.0f;
hpm = 1.0f - hpm * hpm;
float f2 = 1.0f - 1.8f * pow(1.0f - lp * hp, 4.0f);
float b0 = (y * y * y - y) / (f2 * y * y - 1.0f);
float b1 = (x * x * x - x) / (f2 * x * x - 1.0f);
s1 -= b1 * hpm;
s0 -= b0 * hpm;
}
return (sqr * s1 - s0) * vol;
}
Conclusion
This project was sort of superseeded by Mad Tea Synth (vst) used to make What time is it?. Instead of the expr evaluator a more complete language + virtual machine is used for both sound and visuals. It uses streamed qoa (lossy compression) instead of rle/delta/lz.
If you’re interested in the details of the ft2-clone hack, here’s a zip, it also contains the source to build it, and the original RE-FORM xm file. But I don’t really recommend using it…