forked from Mirrors/badapplefetch
i hate shellscripting :(
Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
parent
e6419975df
commit
8ffe38dc1f
4 changed files with 33 additions and 15 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@ images/*
|
||||||
frames
|
frames
|
||||||
frames/*
|
frames/*
|
||||||
*.mp4
|
*.mp4
|
||||||
|
audio_generator
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -36,8 +36,9 @@ logos.c: scripts/gen_logos.sh
|
||||||
mkdir -p logos/
|
mkdir -p logos/
|
||||||
bash ./scripts/gen_logos.sh >logos.c
|
bash ./scripts/gen_logos.sh >logos.c
|
||||||
|
|
||||||
audio.c: audio.ogg scripts/gen_audio.sh
|
audio.c: audio.ogg scripts/gen_audio.c
|
||||||
bash ./scripts/gen_audio.sh >audio.c
|
$(CC) -o audio_generator scripts/gen_audio.c -Ofast
|
||||||
|
./audio_generator >audio.c
|
||||||
|
|
||||||
$(OBJ_DIR):
|
$(OBJ_DIR):
|
||||||
mkdir -p $(OBJ_DIR)
|
mkdir -p $(OBJ_DIR)
|
||||||
|
|
29
scripts/gen_audio.c
Normal file
29
scripts/gen_audio.c
Normal 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;
|
||||||
|
}
|
|
@ -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
|
|
Loading…
Add table
Reference in a new issue