commit: 08a6d819807266914eabc6481f76fb81b4050571
parent cc4b14511416485e04233349abe6079b39ce1c62
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 2 Nov 2020 08:00:24 +0100
novembeat2020-01.c: New entry
Diffstat:
1 file changed, 37 insertions(+), 0 deletions(-)
diff --git a/C/novembeat2020-01.c b/C/novembeat2020-01.c
@@ -0,0 +1,37 @@
+// 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;
+}