Last active
December 19, 2015 18:59
-
-
Save aoisensi/6002973 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
import math | |
f = open('country_roads1.wav','wb') | |
binary = ''.join(map(chr,[0x52, 0x49, 0x46, 0x46, 0x34, 0xb1, 0x02, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x44, 0xac, 0x00, 0x00, 0x44, 0xac, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61])) | |
x = 0.0 | |
data = '' | |
for key in [-1,-1,1,1] + [3]*12 + \ | |
[3,1,-1,-1] + [1]*12 + \ | |
[3,3,1,1] + [-1]*12 + \ | |
[3,3,6,6] + [8]*12: | |
for i in xrange(44100 / 8): | |
data += chr(((math.sin(x) > 0.5) if 1 else -1) * 127 + 128) | |
x += 441*pow(2,key/12.0)*6.28318530718 / 44100 | |
l = len(data)/16 | |
binary += ''.join(map(chr,[l/0x01000000, l%0x00010000/0x100, l%0x00000100/0x100, l%0x100])) | |
binary += data | |
f.write(binary) | |
f.close() |
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
import math | |
f = open('country_roads2.wav','wb') | |
binary = ''.join(map(chr,[0x52, 0x49, 0x46, 0x46, 0x34, 0xb1, 0x02, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x44, 0xac, 0x00, 0x00, 0x44, 0xac, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61])) | |
x = 0.0 | |
data = '' | |
for key in [-1,-1,1,1] + [3]*12 + \ | |
[3,1,-1,-1] + [1]*12 + \ | |
[3,3,1,1] + [-1]*12 + \ | |
[3,3,6,6] + [8]*12 + \ | |
[8,8,3,3] + [6]*4 + [3]*8 + \ | |
[3,1,-1,-1] + [1]*4 +[3]*8 + \ | |
[3,1,-1,-1] + [-1]*12 + \ | |
[-1,-1,1,1] + [-1]*12: | |
for i in xrange(44100 / 8): | |
data += chr(((math.sin(x) > 0.5) if 1 else -1) * 127 + 128) | |
x += 441*pow(2,key/12.0)*6.28318530718 / 44100 | |
l = len(data)/16 | |
binary += ''.join(map(chr,[l/0x01000000, l%0x00010000/0x100, l%0x00000100/0x100, l%0x100])) | |
binary += data | |
f.write(binary) | |
f.close() |
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
import math | |
f = open('country_roads3.wav','wb') | |
binary = ''.join(map(chr,[0x52, 0x49, 0x46, 0x46, 0x34, 0xb1, 0x02, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x44, 0xac, 0x00, 0x00, 0x44, 0xac, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61])) | |
data = '' | |
for key in [(-1,2),(1,2),(3,12)] + \ | |
[(3,1),(1,1),(-1,2),(1,12)] + \ | |
[(3,2),(1,2),(-1,12)] + \ | |
[(3,2),(6,2),(8,12)] + \ | |
[(8,2),(3,2),(6,1),(6,3),(3,8)] + \ | |
[(3,1),(1,1),(-1,2),(1,4),(3,8)] + \ | |
[(3,1),(1,1),(-1,2),(-1,12)] + \ | |
[(-1,2),(1,2),(-1,12)]: | |
x = 0.0 | |
for i in xrange(44100 / 8 * key[1] - (44100/64)): | |
data += chr(((math.sin(x) > 0.5) if 1 else -1) * 127 + 128) | |
x += 441*pow(2,key[0]/12.0)*6.28318530718 / 44100 | |
data += ''.join(map(chr,[128]*(44100/64))) | |
l = len(data)/16 | |
binary += ''.join(map(chr,[l/0x01000000, l%0x00010000/0x100, l%0x00000100/0x100, l%0x100])) | |
binary += data | |
f.write(binary) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment