6 ms·
Algorithmic symphonies from one line of code
- eternalmatt 15y agoLong live the demoscene.
- geogra4 15y agoYeah this is awesome. Party like it's 1985
- losethos 15y agohttp://www.losethos.com/code/AudioMath.html http://www.losethos.com/code/AudioMath.html You want to keep it continuous when changing frequencies. Come to think of it, I think I just kept it at the same phase position in the waveforms. Oh well. http://www.losethos.com/code/SndFile.html http://www.losethos.com/code/SndFile.html I looked for an uncompressed audio file format. Found ".SND". A minor annoyance is it's big-endian, but a more serious problem is 8kHz is the limit.
- thmzlt 15y agoWhere is /dev/audio on OS X?
- a1k0n 15y agoI think you'd have to write some kind of CoreAudio stub. But if you just want to play with this stuff, see the Javascript version here: http://wurstcaptures.untergrund.net/music/ http://wurstcaptures.untergrund.net/music/
- Ogre 15y agoI don't know if there's a way to play it real-time. I was trying to install sox from homebrew, but it can't grab its libogg dependency, downloads.xiph.org isn't working right now, seemingly. However, you can do this: $ ./soundprog > temp.au hit CTRL-C (Hit it fast! You don't need it to run very long, and it will write to the resulting file very very quickly! Consider modifying the code to have a limit on the for loop.) Then open the resulting .au file in Audacity (http://audacity.sourceforge.net/ http://audacity.sourceforge.net/). It'll play fine. Not as simple just writing to a sound device, but it works.
- Ogre 15y agoOk, looks like xiph.org was just having a hiccup. You can do it real time with sox. First, Get sox. I prefer homebrew for Unix type stuff (http://mxcl.github.com/homebrew/ http://mxcl.github.com/homebrew/), but it's likely MacPorts, Fink, and other sources have sox available too. If using Homebrew, just: $ brew install sox Compile your program. Run it like this: $ ./soundprog | sox -r 8000 -t u8 - -d Voila, just like having a sound device. You can play with the 8000 to make it faster or slower (modifying the pitch as well).
- spiralganglion 15y agoFirstly, this sounds quite a bit like the Symphony For Dot Matrix Printers. If you haven't heard it, I urge you to find a copy. I've linked to some video below, but it is significantly better as an album. It has all the compositional richness of a classical symphony, performed in realtime by an orchestra of printers. I dare say, it is my single favourite musical work. Secondly, I'm reminded of the cassette tapes that computer programs used to come on (Commodore 64, etc). My friend had a box full of these cassettes, but I can't remember what machine they were for. We used to listen to the tapes and jam along with our laptops. It was a bit like having a garage band, I guess, but for tech-heads. Symphony #1 For Dot Matrix Printers (video excerpt): http://vimeo.com/6868193 http://vimeo.com/6868193 Symphony #2 For Dot Matrix Printers (full concert video): http://vimeo.com/16207657 http://vimeo.com/16207657 #1 is my favourite, but #2 is also fascinating. #1 has more immediate textural/tonal exploration, while #2 is a more gradual evolution. Feel free to skip around the videos to get a sense of the breadth of sounds in these symphonies.
- delinka 15y agoThose are indeed fascinating. I do find this a bit of a stretch: "Leaving the constituent elements untouched, the process imposes a new order upon them, reorganizing the sounds along a musical structure." There are parts in there that are almost certainly slowed after recording. The deep thud of the carriage changing direction (starting at 1:47 in video #1) is one such sound that I believe has been slowed. I could certainly be mistaken.
- spiralganglion 15y agoWhat you're hearing is almost certainly the Proximity Effect: http://en.wikipedia.org/wiki/Proximity_effect_(audio) http://en.wikipedia.org/wiki/Proximity_effect_(audio) I used to record music for a living. I was really big on using natural sounds in unexpected ways. There are a lot of things you can do with creative use of microphones.
- dnielF 15y agoawesome, could i do this on ubuntu ?
- dharmatech 15y agoOn Ubuntu 10.10: sound.c: #include <stdio.h> #include <math.h> int main() { int t; for ( t=0; ; t++ ) putchar( t*((t>>9|t>>13)&25&t>>6) ); } Then to compile and run: $ gcc sound.c && ./a.out | aplay -
- a3_nm 15y agoIf you're using Pulseaudio, replace $ ./a.out > /dev/dsp with $ ./a.out | pacat --rate=8192
- stygianguest 15y agoThat doesn't work for their example: main(t){for(t=0;;t++)putchar(t*(((t>>12)|(t>>8))&(63&(t>>4))));} use this in stead: ./a.out | pacat --rate=8000 --channels=1 --format=u8 Note that the rate only changes the speed, just like the RPM of a record would.
- Cieplak 15y agoThanks!
- gtklocker 15y agot * ((t>>sin(7)|t>>cos(10))&tan(3221)&t>>44) Alarm clock?
- simcop2387 15y agoI think t * ((t>>0|t>>1)&tan(3221)&t>>46) Works a little better, or it's more like a phone ringer.
- Cieplak 15y agoIf you're using ALSA, ./a.out | aplay
- oleg_kikin 15y agoI made an HTML5 generator. Check it out: http://www.olegkikin.com/audio/audio.html http://www.olegkikin.com/audio/audio.html You can pass custom formulas in a hash tag: http://www.olegkikin.com/audio/audio.html#(t%3E%3E12|t%3E%3E8)&63&(Math.sin(t/100000.0)*t)%3E%3E4 http://www.olegkikin.com/audio/audio.html#(t%3E%3E12|t%3E%3E...
- a1k0n 15y agoCool. But yours outputs 16-bit signed audio whereas by default /dev/dsp outputs 8kHz 8-bit unsigned audio, so it sounds a little bit different. Also, http://www.bemmu.com/music/index.html http://www.bemmu.com/music/index.html beat you to it and http://wurstcaptures.untergrund.net/music/ http://wurstcaptures.untergrund.net/music/ also does URL-formulas :). (As an aside, bemmu's is creating a 16-bit signed .WAV data from 8-bit signed functions, so it isn't doing it quite right either. Why not just create an 8-bit WAV data block? I've done so here: http://a1k0n.net/code/audiogen.html http://a1k0n.net/code/audiogen.html)
- phaedrus 15y agoThis simple formula produces an interesting sound in your a1k0n.net player: (t % 1000) & t Multiplying the whole thing by t adds to it. Edit: t >> (t % 8) also produces an interesting sound; changing the number 8 changes the pitch. Edit 2: On the theory that primes might create an interesting beat frequency, I tried this which almost sounds like a 3 part harmony: (t >> (t % 7)) & (t >> (t % 5)) & (t >> (t % 3))
- jordanlev 15y agoThose are really cool! Is there any way to explain what the different symbols and operators are doing? I'm a web developer and have a very vague understanding of a little bit of the code but am also a musician and would love to understand a little more so I could try to make my own (without just randomly typing numbers and symbols). For example, is there some correlation between adding a ">>" or "%" operator and how that effects the timing? I saw some of the super basic formulas referenced in the blog post, and see that t[asterisk]4 generates a tone, t[asterisk]5 generates a higher tone, etc. -- is there a way, for example, to put those one after the other to compose something (or is that defeating the purpose of this exercise)? Maybe another way to ask the question, is in your 3-part harmony example, do certain portions of the code correspond to certain parts of the generated tone? Or is this all just totally random, trial-and-error stuff? Thanks!
- bane 15y agomust've been lost in the rush http://news.ycombinator.com/item?id=3061884 http://news.ycombinator.com/item?id=3061884
- RodgerTheGreat 15y agoHere's a basic Java skeleton for experimenting with these code snippets: http://pastebin.com/C0pKEjyN http://pastebin.com/C0pKEjyN
- spyder 15y agosome dubstep thing: http://wurstcaptures.untergrund.net/music/?oneliner=t%7C((t%2F80)%7C(t%2F40))%26(t%2F5)%7C(t%2F160)%7C(t%2F240)%2F8%3C%3C(sin(t%2F3.43)*2)&rate=11025 http://wurstcaptures.untergrund.net/music/?oneliner=t%7C((t%...
- mkramlich 15y agoReminds me of the audio equivalent of the argument put forth in Wolfram's NKS.
- a1k0n 15y agoSomeone over on reddit.com/r/coding put together a version that graphs the output: http://langtons.atspace.com/audio/waveform.html http://langtons.atspace.com/audio/waveform.html Enter something like t^(t%127) and the similarities are even more striking. :)
- stephth 15y agomade a 2-line remix of miiro's 1-line symphony [1]: Side A: http://tinyurl.com/3uejhum http://tinyurl.com/3uejhum Side B: http://tinyurl.com/3mfaogd http://tinyurl.com/3mfaogd [1] http://www.youtube.com/watch?v=qlrs2Vorw2Y&feature=player_detailpage#t=134s http://www.youtube.com/watch?v=qlrs2Vorw2Y&feature=playe...
- JonnieCache 15y agoFor anyone doubting that this would ever be recognised as "music," think again - http://www.youtube.com/watch?v=A8QLkThdzmA http://www.youtube.com/watch?v=A8QLkThdzmA
- extension 15y agoMy attempt at a complex melody: http://tinyurl.com/453z7w2 http://tinyurl.com/453z7w2 xor seems to be really good for that
- trebor 15y agoExcept for the high pitch squeals that nearly gave me a headache.
- cplhenshaw 15y agoThis one is really good. I think it's much more interesting when something resembling a melody emerges from the code.
- kragen 15y agoThis one, from HAKMEM's circle-drawing hack, generates a simple pure sine wave: main(t,u){for(t=u=85;;t+=u>>2,u-=t>>2)putchar(t+128);} BTW, I think the comments saying that aplay or pacat are equivalent to /dev/audio are slightly mistaken. /dev/audio is μ-law, like aplay -f MU_LAW. aplay defaults to linear unsigned 8-bit. With the sine wave above, the difference is very noticeable. With the various distorted sawtooths and white-noises in the original videos, it's harder to tell, but I'm reasonably sure that they're using μ-law, not linear. BTW, aplay refuses to play 8-bit audio on my Logitech USB speakers. So I ended up using sox to convert: ./viznut1 | sox -r 8000 -U -t u8 - -t s16 - | aplay -f S16_LE -D hw:1,0 The -U specifies μ-law conversion. I created a Git repository for these programs at https://github.com/kragen/viznut-music https://github.com/kragen/viznut-music.
- charltones 15y agoI'm hooked (t>>2|t>>6)*(t>>5|t>>7)