Live data from Hacker News

Algorithmic symphonies from one line of code

countercomplex.blogspot.com

21–30 of 38 posts

Re: Algorithmic symphonies from one line of code

#21

I made an HTML5 generator. Check it out: 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%3E...

Cool. 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 beat you to it and 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)

Re: Algorithmic symphonies from one line of code

#23
post #21

I made an HTML5 generator. Check it out: 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%3E...

Cool. 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 beat you to it and 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…

This 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))

Re: Algorithmic symphonies from one line of code

#25
post #21

Earlier quoted context omitted.

Cool. 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 beat you to it and 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…

This 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))

Those 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!

Re: Algorithmic symphonies from one line of code

#27

Earlier quoted context omitted.

This 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))

Those 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…

Some of the really compact formulae are trial-and-error stuff, but it doesn't have to be. You can make an arbitrarily complicated software synthesizer with this thing, and if you just want to compose algorithmic music in a "constructivist" way, you can do something like this:

    SS=function(s,o,r,p){var c=s.charCodeAt((t>>r)%p);return c==32?0:31&t*
    Math.pow(2,c/12-o)},SS("0 0     7 7     037:>12 : 0)
So I've defined a function "SS" which stands for sawtooth wave applied to sequencer -- where a sequencer takes an ASCII representation of notes and a speed and a base octave, and converts them into relative note frequencies, and then the sawtooth wave synth is done by 31&t* -- which is a number that cycles between 0 and 31 at a frequency determined by the multiplier. Just typing "31&t" into the code will give you a sawtooth wave at 8000/32 = 250Hz which is either a flat middle C or a sharp B below that. 8000 being the sample rate, 32 being the number of steps in the wave generated by "t&31".

So one of those is synthesizing a bassline and the other one is an arpeggio that starts and stops when t&4096 is true, which means it's "off" for about half a second and "on" for about half a second (8000/4096 to be precise). Add the bassline to the arpeggio and you get both voices at once.

My version has a textarea just so I could put things like that together. The OP, however, is less interested in the constructivist approach and more in the trial-and-error approach where you find something that can be implemented in 10 bytes of assembler and it magically produces a symphony.

Re: Algorithmic symphonies from one line of code

#29

Reminds me of the audio equivalent of the argument put forth in Wolfram's NKS.

Someone over on reddit.com/r/coding put together a version that graphs the output:

http://langtons.atspace.com/audio/waveform.html

Enter something like t^(t%127) and the similarities are even more striking. :)

Re: Algorithmic symphonies from one line of code

#30
post #27

Earlier quoted context omitted.

Those 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…

Some of the really compact formulae are trial-and-error stuff, but it doesn't have to be. You can make an arbitrarily complicated software synthesizer with this thing, and if you just want to compose algorithmic music in a "constructivist" way, you can do something like this: SS=function(s,o,r,p){var c=s.charCodeAt((t>>r)%p);return c==32?0:31&t* Math.pow(2,c/12-o)},SS("0 0 7 7 037: >12 : 0) So I've defined a function…

My mind is blown! I have a zillion more questions -- if it's fun for you to talk about this please email me (address in my profile). Either way, thanks -- this is absolutely fascinating.
Post reply on HN