Created
November 20, 2016 00:08
-
-
Save auxiliary-character/6dac6160bcbfd5615e78bff854883408 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <string.h> | |
#include <stdio.h> | |
static const float scale[] = { | |
0, //rest | |
11.175303405856125, | |
13.289750322558245, | |
15.804265640195972, | |
16.74403617923831, | |
17.739688382519812, | |
19.91212695821318 | |
}; | |
static const char melody[] = | |
"10000040" | |
"34343040" | |
"20001000" | |
"00102040" | |
"50002000" | |
"50006000" | |
"40504050" | |
"40000000"; | |
//outputs 8-bit PCM audio to stdout | |
//pipe into /dev/dsp, aplay, or a file for audacity | |
int main(){ | |
for(int t;(t>>9)<strlen(melody); ++t){ | |
putchar((char)(t*scale[melody[t>>9]-'0'])); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment