bytebeat music
"Bytebeat music (or one-liner music) was invented in September 2011. They're generally a piece of rhythmic and somewhat melodic music with no score, no instruments, and no real oscillators. It's simply a single-line formula that defines a waveform as a function of time, processed (usually) 8000 times per second, resulting in an audible waveform with a 256-step resolution from silence (0) to full amplitude (256). If you put that formula into a program with a loop that increments time variable (t), you can generate the headerless unsigned 8 bit mono 8kHz audio stream on output, like in this application. Since these directly output a waveform, they have great performance in compiled languages and can often be ran on even the weakest embedded devices."
and it's fucking awesome.
essentially, with just a few lines of code you can create an endlessly repeating piece of music.
there are online tools for that, or, if you want, you can create it yourself like i will show you now.
the language in which i will code the programs is C, don't worry, they're very short.
#include <stdio.h>
int main()
{
int t;
for(t=0;;t++)
{
putchar((t*5&t>>7) | (t*3&t>>10));
}
}
now, if you're on linux, you can either play this directly after compiling it, or export it as .wav.
to compile this program, you can run the command:
gcc nameofprogram.c -o nameoffile
this should create the file you will later execute in the terminal for it to play.
now, to play the file, you have to know which audio renderer you are using, in my case it's pulseaudio.
to play these files in pulseaudio you have to pipe the program into pacat.
./nameoffile | pacat --format u8 --rate 8000
(you can play with the --format and the --rate)
the jingle should start playing, if you want it to stop, just press ctrl+c.
like i mentioned before, you can also convert that into a .wav file with a couple of commands
this requires sox. (on arch linux, run sudo pacman -S sox).
./nameoffile | head -c 4M > nameoffile.raw
sox -r 8000 -c 1 -t u8 nameoffile.raw nameoffile.wav
i also have another program which sounds great with --rate 6000.
#include <stdio.h>
int main()
{
int t;
for(;;t++)
{
putchar((t*9&t>>4|t*5&t>>7|t*3&t/1024)-1);
}
}