====== Project: Algorithmic Soundscapes ====== {{tag>project hardware software electronics audio music hadez}} ===== 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 [[http://www.youtube.com/watch?v=qlrs2Vorw2Y|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) |[[leute:hadez]] | | |(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) |[[leute:hadez]] |slow chippy bassline | |(t>>9&t>>8)*(t>>3) |h0uz3 | Ready for a horror trip? Just add some LSD... | |(t>>8|t-2)&(2-t|8< |h0uz3 | Symmetries are for pussies | |((t>>8|t-2)&(2-t|8<>8|t-2)&(2-t|8<>((t>>8|t-2)&(2-t|8< |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)<]]|[[leute:samuirai]]|dramatic space aliens| |((t>>4)|(t<<4)&0x11111+t/1000)|[[leute:tv]]|Baby-[[https://github.com/krebscode/painload/tree/master/K%C3%BCbelwagen|Kübelwagen]]-Alarm-Therapist #x1 [pre]| |t<700000?((t/2000%2?t<<3:t<<2)>>(t/10000%3)<>(t/1000)|t/(800000-t) :t<805000?t<<(t/500) :/*"fin"*/1/(t-t)|[[leute:tv]]|Alarm-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)))|tito|Boss 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)