Author:
- Name: Anders Kaare Straadt
Location: DK - Denmark
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
- “Helpful” formatting
- Character salad
- Loop exit trying to hide by a switch statement
- Strong string encryption. By that I mean “fmt”=>“gnu”.
- A
/*{*/
that throws off bracket matching in vim. Begun the editor wars have! (Wait, I’m on the vim-team!) cm
andap
stands for “allpass” and “comb”, respectively.- One effect was created with deliberate “memory corruption”.
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)
- Kick drum from sines, pitched up to create toms.
- Roland TR-808 style hi-hats (a bunch of high-pass filtered square waves).
- SID/C64-style snare drum (oscillates between noise and square wave).
- There’s some FM synthesis in the bass.
- Schroeder reverberator a la Freeverb. The same building blocks are used for the echo effect.
- Waveshaping/overdrive using tanh(x), ohh yeaaah..
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
- prog.c - entry source code
- Makefile - entry Makefile
- prog.orig.c - original source code
- try.sh - script to try entry
- prog.html - run emulator in a browser
Secondary files
- 2024_straadt.tar.bz2 - download entry tarball
- README.md - markdown source for this web page
- .entry.json - entry summary and manifest in JSON
- .gitignore - list of files that should not be committed under git
- .path - directory path from top level directory
- index.html - this web page