1
0
Fork 0

i hate shellscripting :(

Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
Ari Archer 2024-05-04 02:09:28 +03:00
parent e6419975df
commit 8ffe38dc1f
No known key found for this signature in database
GPG key ID: A50D5B4B599AF8A2
4 changed files with 33 additions and 15 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ images/*
frames
frames/*
*.mp4
audio_generator

View file

@ -36,8 +36,9 @@ logos.c: scripts/gen_logos.sh
mkdir -p logos/
bash ./scripts/gen_logos.sh >logos.c
audio.c: audio.ogg scripts/gen_audio.sh
bash ./scripts/gen_audio.sh >audio.c
audio.c: audio.ogg scripts/gen_audio.c
$(CC) -o audio_generator scripts/gen_audio.c -Ofast
./audio_generator >audio.c
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)

29
scripts/gen_audio.c Normal file
View file

@ -0,0 +1,29 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
int main(void) {
int fd;
off_t size, idx;
unsigned char *buf;
fd = open("audio.ogg", O_RDONLY);
size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
buf = malloc(size);
read(fd, buf, size);
puts("#include <stdint.h>\nconst unsigned char audio[]={");
for (idx = 0; idx < size; ++idx)
printf("%u,", buf[idx]);
puts("};const uint64_t audio_size=sizeof(audio);");
free(buf);
return 0;
}

View file

@ -1,13 +0,0 @@
#!/usr/bin/env sh
set -eu
main() {
echo "#include <stdint.h>"
echo "const unsigned char audio[] = {"
od -An -vtu1 <audio.ogg | awk '{for (i=1; i<=NF; i++) printf "0x%s, ", $i}'
echo "};"
echo "const uint64_t audio_size = sizeof(audio);"
}
main