logo

bytemedia

Home to byte-level sounds, images, videos, …
commit: d6df4b00090fbb2e3caf8a8ff6e788309275a94c
parent 6962a6a68324dab4f0b8d2c400e8f08f7a4b3f3e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 27 Oct 2020 09:46:25 +0100

battery_*.c: Create sounds for battery events

Diffstat:

AC/battery_back.c26++++++++++++++++++++++++++
AC/battery_low.c26++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/C/battery_back.c b/C/battery_back.c @@ -0,0 +1,26 @@ +#define _POSIX_C_SOURCE 200809L +#include <stdio.h> +#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); + + for(int t = 0;t<1600;t++)putchar( t++*1 ); + for(int t = 0;t<1600;t++)putchar( t++*2 ); + for(int t = 0;t<2000;t++)putchar( t++*3 ); + + return 0; +} diff --git a/C/battery_low.c b/C/battery_low.c @@ -0,0 +1,26 @@ +#define _POSIX_C_SOURCE 200809L +#include <stdio.h> +#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); + + for(int t = 0;t<1600;t++)putchar( t++*1 ); + for(int t = 0;t<1600;t++)putchar( t++*3 ); + for(int t = 0;t<2000;t++)putchar( t++*2 ); + + return 0; +}