novembeat2020-01.c (833B)
- // cat ./novembeat2020-01.c | tcc -run ./novembeat2020-01.c | mpv -
- #define _POSIX_C_SOURCE 200809L
- #include <stdio.h> // getchar()
- #include <inttypes.h> // uint32_t
- #include "au.h"
- int
- main(void)
- {
- // Use AU defaults
- struct au_header header = {
- .offset = 24, // no-annotation, in octets
- .lenght = 0xFFFFFFFF, // unknown data size
- .encoding = 02, // unsigned 8-bit linear PCM
- .samplerate = 8000, // Hz
- .channels = 1
- };
- // fd 1 is stdout
- write_au_header(1, &header);
- int c = 0, t = 0, o = 0;
- while((c = getchar()) != -1) {
- int dur = 8000/14;
- o = 1; // Magic number
- if(c >= 'a' && c <= 'z') { dur = 8000/15; o=c-'a'+1; }
- if(c >= '0' && c <= '9') { dur = 8000/16; o=c-'0'+1; }
- if(c >= 'A' && c <= 'Z') { dur = 8000/17; o=c-'a'+1; }
- for(int i = 0;i<dur;i++,t++)
- putchar(t++*o%30);
- }
- return 0;
- }