Other things on this site...


Turning real music into 8-bit music

You might have heard some of the funky funky music still being made on old 8-bit computers. For example the AY Riders' delightful cover of Hung Up by Madonna. I got an email from someone asking if it was possible to take any MP3 and automatically turn it into chiptune music. The answer is, it's tricky...

One of the problems would be a kind of "reverse engineering" thing about calculating which notes are present in the music, and when they start and stop - I know from some of my research that that's surprisingly difficult, and computers can't yet do it very reliably. If you have no polyphony (only ever one note happening at a time) then the pitch can be tracked pretty well. But when there are multiple sounds at once, things get difficult...

I know that "polyphonic pitch tracking" is an ongoing research area. Maybe there are already some decent systems that can already do it, I'm not sure. Once that problem is cracked, then it's just a case of resynthesising the notes using a chiptuney palette.

OK, so polyphony might get in our way, but let's have a simple-minded go at it anyway. Here's some code which runs in SuperCollider (you also need the Tartini plugin and the MP3 quark). It takes an arbitrary MP3 and makes it into a chippy-sounding pulse wave:

SynthDef("help_mp3_01", { |bufnum = 0|
    var son, pitch, amp, wibble;
    son = DiskIn.ar(2, bufnum).mean;
    pitch = Tartini.kr(son)[0];
    amp = Amplitude.ar(son);
    pitch = Median.kr(5, pitch); // smooth
    pitch = pitch.min(10000).max(10); // limit
    pitch = pitch.cpsmidi.round.midicps; // coerce
    wibble = Pulse.ar(pitch, 0.2, amp * 2); // resynthesise
    wibble = FreeVerb.ar(wibble, 0.3, 0.1, 0.9); // bit of reverb just to taste
    Out.ar(0, wibble.dup);

// Now let's create the MP3 object and cue it into a Buffer.
m = MP3("../mp3s/Gimme A Pig Foot And A Bottle Of Beer.mp3");   
b = Buffer.cueSoundFile(s, m.fifo, 0, 2);
// Off we go:
x = Synth("help_mp3_01", [\bufnum, b.bufnum], addAction:\addToTail);

// Please remember to tidy up after yourself:
b.close; b.free;

And how does it sound? Depends what you put into it. Often it goes disastrously wrong. But here's a rendering of Bessie Smith's Gimme A Pig Foot And A Bottle Of Beer:

(Audio hosted at archive.org)

| music | Permalink