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:

Implementation

Very ugly.

Parts:

Steep Functions (not complete)

Maths / Util

Drawbacks

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.

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;
}

Play/listen in madtealab

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…