Sound Bytes

A coding competition


Project maintained by coding-competitions Hosted on GitHub Pages — Theme by mattgraham

Good Eats Theme Song

by djscheuf

Listen

A loose riff on the Good Eats theme song. Been watching too much Good Eats Reloaded recently :)

index.js


// Good Eats entry
n = 10, rate = 44100;
f = n => Math.pow(2, (n-49)/12)*440;
song = [49,53,54,52,51,50,49,49,49];
for (i = 0; i < song.length; i++) {
    var n = song[i], l = Math.round(rate / f(n));
    var arr = new Array(1600);
    if (n > 0) for (var x = 0; x < l; x++){
        arr[x] = Math.random();
    }
    for (t = 0; t < 20000; t++) {
        var y = arr[t % l];
        process.stdout.write(Buffer.from(Float32Array.of(y).buffer));
        arr[t % l] = (arr[t % l] + arr[(t + 1) % l]) / 2 * .998
    }
}

Language

JavaScript

Golf Score

517

Parameters

Sample Rate: 44100 Hz
Sample Size: 32 bits
Channels: 2 (stereo)
Encoding: floating-point

Commands

Run

node .

Spectrogram

Spectrogram