IOCCC image by Matt Zucker

The International Obfuscated C Code Contest

2024/straadt - Prize in sound coding

layered music generator

Author:

To build:

    make all

To use:

    ./prog

Try:

    ./prog

and then play the resulting prog.wav using a sound player.

Judges’ remarks:

When you run the program, after several moments, a prog.wav sound file is produced.

Using a sound player (you may find sox(1) is a good choice), you may enjoy the result.

Can you figure out how it produces the various layers of instruments?

Author’s remarks:

Obfuscations

To encourage tinkering I’ve obfuscated the song data and program (see Y()) less than the “library code”. Sorry if you wanted to tinker with the library code!

Sound quality

The sample rate of prog.wav is 256kHz because creating aliasing-free waveforms would require more code, but you can always oversample the audio and pass the anti-aliasing problem on to the audio player :-) However, the downsampler in my mplayer(1) is poor, but you can use the high-quality resampler in sox(1) to create a 48kHz version:

    sox prog.wav -r 48000 prog.48kHz.wav

Tricks (the condescending part)

I used this Python snippet to generate q0[2] and q0[3]:

    def X(s): print(hex(int(s.replace("x","1").replace(".","0")[::-1],2))) # not for iopcc-use
    X(".x.x..xx.x.xx.xxx.xx.xxx..xx.xxx")
    X("x.xx.x.x.x.xxxxxx.xx.xxx.xxxxxxx")

Inventory for 2024/straadt

Primary files

Secondary files


Jump to: top