Created
October 16, 2017 10:26
-
-
Save danielinux/c334567d004144ab89bdb63d63ee3503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** *** *** *** | |
* Robot war cry | |
* | |
** Chiptune generated via loop variable (bytebeat). | |
* use: | |
* cc -o rwc rwc.c | |
* ./rwc |aplay | |
* | |
* Discovered by: danielinux | |
* Source code license: GPL | |
* | |
*/ | |
#include <stdio.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
unsigned t=0; | |
unsigned loops[8]={8, 10, 12, 8, 1, 10, 12, 8}; | |
unsigned hiccups[8]={1,1,3,1,5,1,5,1}; | |
unsigned juice,tck,kick,glory,pity,groove,nostalgia,desolation,beat,bass; | |
uint8_t out; | |
srand(0); | |
while(1) { | |
tck = (t >> 15) % 8; | |
juice = ((t >> 6) & 1)?((t>>4)<<1):((t>>5)<<1); | |
kick = ((t|(t>>6)) >> 2)/hiccups[tck]; | |
groove = ((t << 3) | (t|loops[tck])) & 0x55; | |
nostalgia = (((t << 7) | ((t<<5)/loops[tck])) * (t >> 7)) & 0x40; | |
glory = ((t|(t>>5) >> 1)/hiccups[tck]) % 4; | |
pity = (((((t << 2) | (t >> 3))/loops[tck])) << 4) & 0x3f; | |
desolation = (((t >> 17) * ((t>>1) | (t << 1)))/loops[tck]) & 0x06; | |
bass = (((((juice|(juice >> 4))%15))<<2)/loops[tck]) & 0xa0; | |
beat = ((juice<<1) | (kick | glory)) & 0x55; | |
out = 0xff & (beat|bass|pity|groove|nostalgia|desolation); | |
write(STDOUT_FILENO, &out, 1); | |
t+=1; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment