Bytebeat

From Noisebridge
(Difference between revisions)
Jump to: navigation, search
(new bytebeat, created using pytebeat)
Line 91: Line 91:
 
  python -c'import sys;[sys.stdout.write(chr((t<<3+(t>>10)%3^t>>4+(t>>12)%4^t**(2+(t>>13)%8))%256))for t in xrange(2**18)]'|aplay
 
  python -c'import sys;[sys.stdout.write(chr((t<<3+(t>>10)%3^t>>4+(t>>12)%4^t**(2+(t>>13)%8))%256))for t in xrange(2**18)]'|aplay
 
  python -c'import sys;[sys.stdout.write(chr((t^t>>4^(t*((t>>(11+(t>>16)%3))%16))^t*3)%256))for t in xrange(2**20)]'|aplay
 
  python -c'import sys;[sys.stdout.write(chr((t^t>>4^(t*((t>>(11+(t>>16)%3))%16))^t*3)%256))for t in xrange(2**20)]'|aplay
 
+
python -c'import sys;map(lambda t:sys.stdout.write(chr(( t+(t>>(5+(t>>10)%4)^t) )%256)),range(2**21))'|aplay
 
=== links ===
 
=== links ===
 
* [http://www.metafilter.com/111959/Todays-formulaic-music Today's formulaic music.] - Metafilter post about bytebeat with many links
 
* [http://www.metafilter.com/111959/Todays-formulaic-music Today's formulaic music.] - Metafilter post about bytebeat with many links
 
* Recordings made at Noisebridge: [http://www.youtube.com/watch?v=89Dm7yiYoXM] [http://www.youtube.com/watch?v=1tqgzMqk0jM] [http://www.youtube.com/watch?v=S14UknY8qtc] [http://www.youtube.com/watch?v=C87qr2sDu4s]
 
* Recordings made at Noisebridge: [http://www.youtube.com/watch?v=89Dm7yiYoXM] [http://www.youtube.com/watch?v=1tqgzMqk0jM] [http://www.youtube.com/watch?v=S14UknY8qtc] [http://www.youtube.com/watch?v=C87qr2sDu4s]

Revision as of 01:50, 23 May 2012

bytebeat in x86 assembler


 ; noise.asm -- just fooling around :-)
 ; mct and leif, ; Sun Feb 19 19:08:13 PST 2012
 ; 
 ; Build with:
 ;
 ;       nasm -felf32 noise.asm
 ;       ld -melf_i386 -o noise noise.o
 ;
 ; Run with:
 ;
 ;       ./noise | aplay
 ;
 ; Equivalent to:
 ;        python -c'import sys;[sys.stdout.write(chr((t>>10^t>>(t>>13)%4)%256)) for t in xrange(2**20)]' |aplay

 global _start

 section .data

 section .bss

         var:    resb 1  ; one bye variable

 section .text

         ; f(x) = (x >> 10 ^ x>>((x>>13)%4)) % 256

         _start: mov esi, 0

                 ;int 3

         .loop: 

                 mov edi, esi
                 shr edi, 13 ; edi := x >> 13

                 mov eax, edi
                 cwd
                 mov bx, 4
                 div bx  ; dx := (x >> 13) % 4

                 mov eax, esi
                 mov cx, dx
                 shr eax, cl   ; eax := x >> ((x >> 13) % 4)

                 mov edi, esi
                 shr edi, 10   ; edi := x >> 10

                 xor eax, edi
                 mov [var], al

                 mov eax, 4      ; sys_write
                 mov ebx, 1      ; stdout
                 mov ecx, var    ; buffer
                 mov edx, 1      ; length
                 int 80h         ; syscall

                 inc esi
                 jmp .loop
 

 ### Basic Sierpinski harmony bytebeat t & t >> 8 in as few bytes as possible:
         .globl _start
 _start: inc %ebx             # output fd 1 in %ebx for write()
         inc %edx             # byte count of 1 in %edx for write()
 loop:   inc %eax             # increment t each time through the loop
         push %eax            # save it on the stack
         and %ah, %al         # compute t & t >> 8, our output sample
         push %eax            # store it on the stack for write()
         lea 3(%ebx), %eax    # a three-byte way to set %eax to 4 (__NR_write)
         mov %esp, %ecx       # pass sample pointer to write() (little-endian!)
         int $0x80            # invoke system call
         pop %eax             # discard sample
         pop %eax             # restore t into %eax
         jmp loop             # and repeat
 ### Kragen Javier Sitaker
 ### 2012-01-10

 

Compile with gcc -m32 -nostdlib and pipe the output to aplay. After stripping, the ELF is 240 bytes; size(1) says it has 18 bytes of code.

bytebeat in <140-character command lines with python

python -c'import sys;[sys.stdout.write(chr((t^t>>(t>>11)%3^t>>(t>>12)%4)%256)) for t in xrange(2**19)]'|aplay
python -c'import sys;[sys.stdout.write(chr((t>>(t>>11)%4^(t>>10)*(t>>15))%256)) for t in xrange(2**19)]'|aplay
python -c'import sys;[sys.stdout.write(chr((t<<3+(t>>10)%3^t>>4+(t>>12)%4^t**(2+(t>>13)%8))%256))for t in xrange(2**18)]'|aplay
python -c'import sys;[sys.stdout.write(chr((t^t>>4^(t*((t>>(11+(t>>16)%3))%16))^t*3)%256))for t in xrange(2**20)]'|aplay
python -c'import sys;map(lambda t:sys.stdout.write(chr(( t+(t>>(5+(t>>10)%4)^t) )%256)),range(2**21))'|aplay

links

Personal tools