69 lines
2.6 KiB
Python
Executable file
69 lines
2.6 KiB
Python
Executable file
#!/usr/bin/python
|
|
|
|
# Study on bytebeat
|
|
# By danielinux
|
|
# License: GPL
|
|
import sys
|
|
|
|
from random import randint
|
|
|
|
|
|
b = 0x7E
|
|
|
|
c = 0x30
|
|
t=0
|
|
|
|
bass_note0 = [ 16, 0, 8, 0, 8, 16, 9, 0]
|
|
bass_note1 = [ 12, 0, 12, 0, 0, 14,16,0]
|
|
bass_note2 = [ 12, 0, 12, 0, 12, 14,16,0]
|
|
hi_note0 = [4, 8, 4, 8, 6,8,6,8]
|
|
hi_note1 = [12,6,12,6,14,12,14,12]
|
|
|
|
bd = [ 1, 1, 0, 0, 0, 1, 0, 1 ]
|
|
sn = [ 0, 0, 1, 0, 0, 0, 1, 0 , 0, 0, 1, 0, 0, 0, 1, 1]
|
|
|
|
snare = [ 0x41, 0x89, 0xAF, 0x49, 0xC6, 0x20, 0xC0, 0x65, 0xCA, 0xAE, 0xB8, 0x42, 0xAD, 0x52, 0x25, 0xAC, 0xFB, 0xD8, 0x6D, 0xD0, 0x6F, 0x41, 0xB5, 0x53, 0x20, 0x81, 0x97, 0x5F, 0xB4, 0xB7, 0x80, 0xC3, 0x89, 0x69, 0x53, 0x5C, 0xB9, 0x65, 0x22, 0xFB, 0x35, 0xE4, 0x94, 0x2E, 0xD9, 0x6E, 0xDB, 0xEA, 0x4B, 0x78, 0x7E, 0x8C, 0x58, 0x46, 0x2C, 0xD0, 0x3A, 0xC5, 0x68, 0x82, 0x81, 0x62, 0x6F, 0xA6, 0xE0, 0xB5, 0x4D, 0x56, 0xF9, 0xF4, 0xD3, 0xBC, 0x6C, 0x66, 0xB4, 0x45, 0xFF, 0x2B, 0xB3, 0xE1, 0x5A, 0x8D, 0xC2, 0x3A, 0xFF, 0x5B, 0xE1, 0x32, 0x23, 0xE4, 0x22, 0xD0, 0x9A, 0x43, 0xD8, 0xA3, 0xF5, 0x5A, 0x3E, 0x38, 0x60, 0x61, 0xCC, 0xFE, 0x3D, 0x84, 0x25, 0xCC, 0x78, 0xCB, 0x30, 0x7D, 0x8F, 0xAB, 0x60, 0x3E, 0xED, 0x7A, 0x9C, 0x9E, 0xFC, 0xF7, 0xC3, 0x5B, 0x80, 0xD0, 0x53, 0xCC]
|
|
|
|
while 1:
|
|
x = 0
|
|
u = (~(t & 0xFF) & 0xFF)
|
|
beat = t >> 10
|
|
part = (beat >> 3) # part
|
|
hit = (t - (beat << 10)) # Hit: 0-1024
|
|
bnote = (t - ((t >> 10) << 10)) << 6
|
|
note = (t - ((t >> 14)<<14)) << 5
|
|
note2 = (t - ((t >> 13)<<13)) << 7
|
|
|
|
if (bd[beat & 0x07]) and (hit < 32):
|
|
x = 0xFF;
|
|
|
|
#snare
|
|
if (sn[beat & 0x0F]) and (hit < len(snare)):
|
|
x ^= (snare[hit] >> 1)
|
|
|
|
|
|
#bass
|
|
if part > 3:
|
|
if (part & 0x03) < 2:
|
|
if (bass_note0[beat % len(bass_note0)] != 0):
|
|
x ^= (bnote / bass_note0[beat % len(bass_note0)]) & (~b)
|
|
elif part & 0x03 == 0x02:
|
|
if (bass_note1[beat % len(bass_note1)] != 0):
|
|
x ^= (bnote / bass_note1[beat % len(bass_note1)]) & (~b)
|
|
else:
|
|
if (bass_note2[beat % len(bass_note2)] != 0):
|
|
x ^= (bnote / bass_note2[beat % len(bass_note2)]) & (~b)
|
|
|
|
# voice
|
|
if part > 15:
|
|
if (part & 0x03) < 2:
|
|
if (hi_note0[beat % len(hi_note0)] != 0):
|
|
x ^= (bnote / hi_note0[beat % len(hi_note0)]) & (0x30)
|
|
else:
|
|
if (hi_note1[beat % len(hi_note1)] != 0):
|
|
x ^= (bnote / hi_note1[beat % len(hi_note1)]) & (0x30)
|
|
|
|
sys.stdout.write(chr(x & 0xFF))
|
|
t+=1
|
|
|
|
|