Write the prettiest bytebeat composition

(Signed 16-bit little endian, 8000Hz mono (--format=S16_LE))

Music

Much better than before! (although it's quite long)

main(t){for(;;t++)putchar(((7&(((t>>17)+1)>>2)+((t>>10)&1+2*(t>>18&1))*(("23468643"[7&t>>12]-48)+(3&t>>11))+((3&t>>17)>0)*(3&t>>9)*!(1&t>>10)*(((2+t>>10&3)^(2+t>>11&3))))*t*"@06+"[3&t>>15]/32));}

(You can listen this at here)

I wrote this, but even I don't know how some part works, like >0 and (especially) the first 7&.

Change for loop to for(;!(t>>22);t++)... to listen it 'once'. I don't know whether it "loops" exactly the same way, however.

Melody (base of above music)

I love this melody I made (C-G-A-F ftw), but it's too 'plain'...

main(t){for(;;t++)putchar(((t>>10)&1)*(t*("23468643"[7&t>>12]-48)+t*(3&t>>11))*"@06+"[3&t>>15]/32);}

Simple music (which I made before)

main(t){for(;;t++)putchar(t*(3&t>>11)+(t&t>>11)*4*!((t>>11)%3));}


The ruler function in C minor:

#include <math.h>
#include <stdio.h>

#define PI 3.14159265358979323846

#define step(freq, n) ((freq) * pow(2, (n) / 12.0))
#define note(n)       step(440, n)
#define MIDDLE_C      note(-9)

int count_zeros(unsigned int n)
{
    int count = 0;
    for (; (n & 1) == 0; n >>= 1)
        count++;
    return count;
}

int minor_note(int note)
{
    int octave = note / 7;
    int scale[] = {0, 2, 3, 5, 7, 8, 10};

    note %= 7;
    if (note < 0) {
        note += 7;
        octave--;
    }

    return scale[note] + octave*12;
}

int main(void) {
    double t = 0.0;
    double freq = MIDDLE_C * 2;
    double step = PI * 2 / 8192;
    int n = 0;
    int i = 0;

    for (i = 1;; t += step, i++) {
        if (i == 1024) {
            i = 0;
            n++;
            freq = step(MIDDLE_C, minor_note(count_zeros(n)));
        }

        putchar(sin(t * freq) * 50.0 + 128.0);
    }

    return 0;
}

main(t){for(;;t+=(t%6)?1:2)putchar((((t<<t^(t>>8))|(t<<7))*((t<<t&(t>>12))|(t<<10))));}