Hacker News new | past | comments | ask | show | jobs | submit login

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:<<",6,10,32) + (t&4096?SS(
    "037",4,8,3)*(4096-(t&4095))>>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*<multiplier> -- 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.




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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: