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?
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:
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.
I'm not a musician, so this is just my understanding of the changes as a programmer and after trial and error.
The '<<' and '>>' are bit-wise shift operators[1].
The '>>' is a right-shift which is equivalent to dividing by a factor of two. e.g. t>>n == t/(2^n) This can be used to generate a beat.
The '<<' is a left-shift which is equivalent to multiplying by a factor of two. e.g. t<<n == t[asterisk](2^n) This tends to shift the pitch
The modulo operator[2], '%', has very little effect, in combinations it can generate a looping set of ranged variance, which is particularly pronounced when combined with a division operator to create clear stepping. It monotonically increases to n, and then falls back to 0 and starts increasing again. e.g. t[asterisk](t%16/64) This increases through 16 phases, holding for 4 periods.
Addition, '+', and subtraction, '-' haven't been very useful for me except when using sin(t) or cos(t) which oscillate between -1 and 1 resulting in some interesting changes to the beat. e.g.t>>4+cos(t) is shifting between t>>3 and t>>5.
The AND '&', OR '|', a short circuiting OR, '||' come in during composition. Plain OR tends to generate better results, but that's trial and error talking. Honestly, too tired to think about this.
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))