# shackspace wiki

### Webseiten-Werkzeuge

project:algorithmicsoundscapes

# Project: Algorithmic Soundscapes

## Wat?

Have a c-oneliner generate something you can directly pipe into /dev/dsp or aplay. For an example (this actually started it) check out this YouTube video.

The code usually follows the basic pattern of

`main(t){for(t=0;;++t)putchar(  X  );}`

Where X is a formula based on t. You can compile it as follows:

```# code in code.c
gcc -xc -lm code.c
./code | aplay```

If you don't want to compile it yourself, you can use an online service like http://wurstcaptures.untergrund.net/music/ to render the first few seconds of your track.

You can also compile it inline and have it play directly:

`echo "main(t){for(t=0;;++t)putchar(  X  );}"|gcc -xc -lm -&&./a.out|aplay`

Note the -lm in both cases which links against the math library so you can use sin, cos, tan, et al.

## Collection

Formula Who Comment
`(t|t>>8)>>(t>>7)|(t<<6|t<<8)>>(t>>11)|(t<<7|t<<11)>>(t>>11)`
`(t|t>>17)>>(t>>7)|(t<<2|t<<8)>>(t>>11)|(t<<2|t<<11)>>(t>>17)`
h0uz3 cool morse blips after a while
`(int)sin(t>>16)|(t|t>>8)`
`(t>>9&t>>8)*(t>>3)`
`(t>>8|t-2)&(2-t|8<<t)`
h0uz3 Symmetries are for pussies
`((t>>8|t-2)&(2-t|8<<t))<<((t>>8|t-2)&(2-t|8<<t))>>((t>>8|t-2)&(2-t|8<<t))`
h0uz3 Downward spiral
`((t>>3|t<<7)|t>>11)|t>>16`
h0uz3 Time to wake up, huh?
`((((t>>3|t<<7)|t>>11)|t>>16)&23)`
h0uz3 23 makes everything a little more sane
`((sin((t%17)*3.1415*0.5)*100)<<t/90)|(sin(t*t*3.1415*0.5)*50)`

]]

samuiraidramatic space aliens
`((t>>4)|(t<<4)&0x11111+t/1000)`
tvBaby-Kübelwagen-Alarm-Therapist #x1 [pre]
```t<700000?((t/2000%2?t<<3:t<<2)>>(t/10000%3)<<t/100000)
:t<800000?-t*t*t>>(t/1000)|t/(800000-t)
:t<805000?t<<(t/500)
:/*"fin"*/1/(t-t)```
tvAlarm-Symphony #x2 (w/happy end)
`((t>>7)* 0xff) * (t & 0xff)/32 & ~(t / 127)`
bdwheele Almost pac-man
Stereo Version: http://preview.tinyurl.com/65pjn98 sso 8-Bit Psytrance? Try at 22050Hz Sampling Rate!
`((t>>10)<<((t>>4)%([8,9,10,11][(t>>11)%4]-(t>>15)%4)))`
titoBoss level

## Tips & Tricks

• add multiple voices using eg. bitwise or „|
• use operators and bitmasks! +,-,*,/ and &,^,|,«,»
• exploit math functions (sin, cos, tan, …)
• shift left for higher notes „«
• shift right for lower notes „»
• add rhythm by shifting everything right by a right-shift of t „(formula)»(t»N)“, the bigger N, the higher the rhythm frequency
• as with everything algorithmically generated: prime numbers are your friend! they make it sound so much more interesting by yielding less repetitive output
• build chords!
• note 1:
`(t<<6|t<<8)>>(t>>11)`
• note 2:
`(t<<7|t<<11)>>(t>>11)`
• combine:
`(t<<6|t<<8)>>(t>>11)|(t<<7|t<<11)>>(t>>11)`
project/algorithmicsoundscapes.txt · Zuletzt geändert: 2013-02-18 14:32 von 178.24.96.131