[Question]
  [
[Bytebeat](http://canonical.org/~kragen/bytebeat/) is a style of music one can compose by writing a simple C program that's output is piped to `aplay` or `/dev/dsp`.
```
main(t){for(;;t++)putchar(((t<<1)^((t<<1)+(t>>7)&t>>12))|t>>(4-(1^7&(t>>19)))|t>>7);}
```
There is a good deal of information on the [bytebeat site](http://canonical.org/~kragen/bytebeat/), a [javascript implementation](http://wurstcaptures.untergrund.net/music/), and more demos and example compositions in [this thread](http://www.metafilter.com/111959/Todays-formulaic-music).
Very simple rules : Try to write a pretty sounding composition. Most up votes wins since that's obviously subjective, although not that subjective considering the usual results.
  
[Answer]
(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](http://snd.sc/zFYrxo))
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));}`
[Answer]
The [ruler function](http://oeis.org/A001511) 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;
}
```
[Answer]
```
main(t){for(;;t+=(t%6)?1:2)putchar((((t<<t^(t>>8))|(t<<7))*((t<<t&(t>>12))|(t<<10))));}
```
[Answer]
Emphasising "beat" over "byte":
```
#include<math.h>
double s(double,double);double r(double,double);double d(double);double f(double);
char bytebeat(int t){return (d(f(t/4000.)/3) + 1) * 63;}
double f(double t){
  double sn=s(1./2,t-1); sn*=(sn*sn);
  return 3*s(1./4,1/s(1,t))+3*s(4,1/sn)/2+s(4,1/(sn*sn*sn*sn*sn))/4
       +2*s(55+18.3*r(1./2,t),t)+s(110+s(5,t)/4000,t)*s(1,t)+s(220+110*r(1,t)+55*r(3,t),t)/5
       +s(880+440*r(1./2,t)-220*r(1,t)+110*r(2,t)+s(5,t)/4000,t)
       *(2+s(1760+438*r(3./2,t)-1234*r(2,t)+423*r(5,t),t))/9
       +s(s(1,t)+s(1./2,t)+s(1./4,t)+s(1./8,t),t)*s(s(1,t)+s(1./2,t)+s(1./4,t)+s(1./8,t)+1,t)
       +r(264+11*r(1./20,t),t)*s(1./20,t);
}
double s(double f,double t){return d(sin(f*3.14159265*(t+999)));}
double r(double f,double t){return s(f,t)<0;}
double d(double a){return tanh(a+a*a/4);}
main(t){for(;;++t)putchar(bytebeat(t));}
```
To be used at 8 kHz, uint8 mono. Sounds best over decently bass-capable loudspeakers.
[Answer]
```
main(){for(;;)putchar(rand());}
```
Sounds like the ocean ;-)
[Answer]
Combined melody and harmony:
```
r=3,
r=3,
m=(t*(t>>12|t>>13|t>>14|t>>15|t>>16|t>>17|t>>18))&63,
h= ((t&t>>7&t>>6)|t*5&t>>8-c^t*6&t>>9-c|t*7&t>>12-c^t*9&t>>11-c^t*11&t>>22^t*19&t>>20^t*14&t>>20|t*23&t>>15-c|t*12&t>>9|t*30&t>>30|t>>5|t>>4)-31, m|h
```
]