logo

bytemedia

Home to byte-level sounds, images, videos, … git clone https://anongit.hacktivis.me/git/bytemedia.git/

novembeat2020-01.c (833B)


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