#!/usr/bin/python # Study on bytebeat # By danielinux # License: GPL from random import randint import sys b = 0x7E c = 0x30 t=0 bass_note = [ 18, 9, 6, 16, 12, 10, 12, 10 ] high_note = [ 18, 9, 12, 32, 12, 10, 24, 27 ] high2 = [6, 18, 6, 16, 3, 10, 2, 27, 5, 27, 20, 16, 48, 32, 32, 24 ] 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 >> 11 part = (beat >> 3) # part hit = (t - (beat << 11)) # Hit: 0-1024 bnote = (t - ((t >> 10) << 10)) << 5 note = (t - ((t >> 14)<<14)) << 9 note2 = (t - ((t >> 15)<<15)) << 9 #bass drum x = ((t >> 5)|(t >> 4)) & b if (x > 0): x = b #drop if (hit < 128): x |= 0xF0 #snare if ((beat & 0x01) or ((beat & 0x0F) == 0x06)) and (hit < 128) : x ^= (snare[hit] >> 1) #bass if (part > 0): x ^= (bnote / bass_note[beat % len(bass_note)]) & ~(b) # voice 1 if ((part % 8) > 4) or (part > 0 and part % 8 == 0): x ^= (note / high_note[beat % len(high_note)]) & (0x40) elif (part > 0): x ^= (note2 / high2[beat % len(high2)]) & (0x50) sys.stdout.write(chr(x & 0xFF)) t+=1