## Experimental music from very short C programs

**category:**code [glöplog]

#countercomplex @ IRCnet is there for more immediate collaboration!

Whoa that's nice :D

Very annoying horrorfilm soundtrack :)

t*((((t>>10)^42)>>3)^42)

t*((((t>>10)^42)>>3)^42)

scratching

(sin(t/8100+sin(t/855))*t^t&0)

(sin(t/8100+sin(t/855))*t^t&0)

laser battle

t*((((t>>2)^42)>>3)^42)

t*((((t>>3)^42)>>3)^42)

quite impressive variety

t*((((t>>6)^442)>>2)^42)*(t>>16)

t*((((t>>2)^42)>>3)^42)

t*((((t>>3)^42)>>3)^42)

quite impressive variety

t*((((t>>6)^442)>>2)^42)*(t>>16)

kind of green beret (cpc version) rhythm

sample rate 8000

(1/t&0x1^t/99>>2/t)+(661110&t>>1/2)/0.1*(t/(16*sin(t/600)^3) >>t/160)

sample rate 8000

(1/t&0x1^t/99>>2/t)+(661110&t>>1/2)/0.1*(t/(16*sin(t/600)^3) >>t/160)

recharging some kind of lazer-weapon: (t*0.1)*cos(t*.002)

HeLLoWorld: lol at your horror film soundtrack :)

For some reason (I guess 8khz is interpolated poorly), multiplying t by 80/441 and sampling at 44.1khz improves the quality of every example I tried immensly without changing the character of the sound.

I would think the the 8khz and the strecthed 44.1khz musix would sound absolutely identical.

I would think the the 8khz and the strecthed 44.1khz musix would sound absolutely identical.

QUINTIX: Bad interpolation might be a part of it. 44100/8000=5.5125, which is not a very nice round number. But this would mainly manifest itself in aliasing artifacts, i.e. extra harmonics.

What you're hearing is more likely the Nyquist filter used when upsampling. Per the Nyquist theorem, audio sampled at 8 kHz can't contain frequencies above 4 kHz. So in the upsampling process, the audio is low-passed at 4 kHz. This may be unwanted for oneliners, but a natural sound would sound slightly distorted without this filter.

Then there's of course possible that there's some aliasing in the actual generation of the sound, in particular when it comes to the oh so popular bitwise operations which only work on integers. For example, if your 8 kHz audio stream would output the two samples 1,2 your multiplied audio stream might contain 1,1,1,1,1,1,2,2,2,2,2 i.e. 6*1 and 5*2. (The ratio is ~5.5 so two samples must be converted to approximately 11 samples.) You might hear this as a minor change of timbre in the sound.

What you're hearing is more likely the Nyquist filter used when upsampling. Per the Nyquist theorem, audio sampled at 8 kHz can't contain frequencies above 4 kHz. So in the upsampling process, the audio is low-passed at 4 kHz. This may be unwanted for oneliners, but a natural sound would sound slightly distorted without this filter.

Then there's of course possible that there's some aliasing in the actual generation of the sound, in particular when it comes to the oh so popular bitwise operations which only work on integers. For example, if your 8 kHz audio stream would output the two samples 1,2 your multiplied audio stream might contain 1,1,1,1,1,1,2,2,2,2,2 i.e. 6*1 and 5*2. (The ratio is ~5.5 so two samples must be converted to approximately 11 samples.) You might hear this as a minor change of timbre in the sound.

Here's a really nice one: it has many layers (well, 8) of overlapping patterns, with the tempo of each pattern going up by powers of 2, but also the amplitude goes down as the tempo goes up, so you can't hear the fastest ones. There's also a hard-sync sort of effect to keep it interesting.

t&t>>4&t>>6&t*t>>8

t&t>>4&t>>6&t*t>>8

Here's a couple variations: the first sounds like LFO weirdness, the second more like a melody.(t<<2|t<<(t>>10))*(t>>6&t>>11)

(t<<2|t<<(t>>10))*(t>>10&t>>11)

(t<<2|t<<(t>>10))*(t>>10&t>>11)

someone got inspired and put it on an AVR..

http://hackaday.com/2011/10/03/avr-chiptune-project-turns-this-simple-code-into- music/

http://hackaday.com/2011/10/03/avr-chiptune-project-turns-this-simple-code-into- music/

this one was interesting:

((t>>1)^(t>>2)/(t>>9))*((t>>10&t>>14)+(5&( 0xbadeaffe>>(t>>15&31))))

((t>>1)^(t>>2)/(t>>9))*((t>>10&t>>14)+(5&( 0xbadeaffe>>(t>>15&31))))

just the bassline, for reference:

(t>>4)*(13&(0x8898a989>>(t>>11&30)))

i'm not sure if the shift-register-as-step-sequencer violates the spirit of the whole thing, but making it a bit more controllable seems like a good move overall.

(t>>4)*(13&(0x8898a989>>(t>>11&30)))

i'm not sure if the shift-register-as-step-sequencer violates the spirit of the whole thing, but making it a bit more controllable seems like a good move overall.

A nice riff, somehow sounds like string instruments, with a metallic triangle

(t>>(t&7))|(t<<(t&42))|(t>>7)|(t<<5)

(t>>(t&7))|(t<<(t&42))|(t>>7)|(t<<5)

That one, would totally fit in some dramatic 1ko demo O_o

(t>>(t&0xcccc))|(t<<(t&0xbebe))|(t>>3)|(t<<6)

That one and the one I posted just before have the same pattern, just different parameters. Change the constants, and you'll get many nice tunes. I found maybe ten cool ones with that line.

(t>>(t&0xcccc))|(t<<(t&0xbebe))|(t>>3)|(t<<6)

That one and the one I posted just before have the same pattern, just different parameters. Change the constants, and you'll get many nice tunes. I found maybe ten cool ones with that line.

t*(t>>((t&4096)?((t*t)/4096):(t/4096)))|(t<<(t/256))|(t>>4 )

Reminds me a bit about the music for a C64 game, can't remember which at the moment...

Reminds me a bit about the music for a C64 game, can't remember which at the moment...

The shift register trick is a good one, here, have some chip arpeggio that eats itself:

(((t>>1)*(15&(0x234568a0>>((t>>8)&28))))|((t>>1) >>(t>>11))^(t>>12))+((t>>4)&(t&24))

(((t>>1)*(15&(0x234568a0>>((t>>8)&28))))|((t>>1) >>(t>>11))^(t>>12))+((t>>4)&(t&24))

great, kb_ :)

These are amazing and inspired me to make a jeskola buzz generator to do the same thing. I guess a musician could play with adding small effects to the sounds for a 4k or such if you can fit it in, but mainly it's because I like droning noises....

Anyway, you can find an alpha version here: http://www.buzzchurch.com/viewtopic.php?t=8150

Anyway, you can find an alpha version here: http://www.buzzchurch.com/viewtopic.php?t=8150