From 62a82f13c286e3a3362f2f7818ad7467ab670aca Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 17 Sep 2012 09:19:05 -0400 Subject: [PATCH] making the files write straight to /dev/audio --- Makefile | 13 ++++++++----- audio.c | 14 ++++++++++++++ audio.h | 4 ++++ f1.c | 5 ++++- f2.c | 8 +++++++- f3.c | 8 ++++++-- f4.c | 4 +++- f5.c | 7 +++++-- f6.c | 5 ++++- 9 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 audio.c create mode 100644 audio.h diff --git a/Makefile b/Makefile index 1a43909..33920f0 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ -FILES := $(basename $(wildcard *.c)) +MUSIC_FILES := $(basename $(wildcard f*.c)) +TMP_FILES := $(wildcard *~) $(wildcard *.o) -all: $(FILES) +all: $(MUSIC_FILES) -%: %.c - $(CC) -o $@ $< +audio.o: audio.c audio.h + +%: %.c audio.o + $(CC) -static -s -o $@ $^ clean: - rm -rf $(FILES) *.o *~ + rm -rf $(MUSIC_FILES) $(TMP_FILES) diff --git a/audio.c b/audio.c new file mode 100644 index 0000000..8c45c5f --- /dev/null +++ b/audio.c @@ -0,0 +1,14 @@ + +#include + +const char* audio_dev = "/dev/audio"; +FILE* audio; + +void init() { + audio = fopen(audio_dev, "w"); +} + +void p(int i) { + fputc(i, audio); +} + diff --git a/audio.h b/audio.h new file mode 100644 index 0000000..49d63c0 --- /dev/null +++ b/audio.h @@ -0,0 +1,4 @@ + +void init(); +void p(int i); + diff --git a/f1.c b/f1.c index 4b43af5..1711db2 100644 --- a/f1.c +++ b/f1.c @@ -1,7 +1,10 @@ +#include "audio.h" + int main() { + init(); int t; for (t = 0;;t++) { - putchar((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7)); + p((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7)); } } diff --git a/f2.c b/f2.c index 8705604..63d970c 100644 --- a/f2.c +++ b/f2.c @@ -1 +1,7 @@ -main(t){for(t=0;;t++)putchar(t*(((t>>12)|(t>>8))&(63&(t>>4))));} +#include "audio.h" +int main(t){ + init(); + for(t=0;;t++) { + p(t*(((t>>12)|(t>>8))&(63&(t>>4)))); + } +} diff --git a/f3.c b/f3.c index 32304af..3e9a66e 100644 --- a/f3.c +++ b/f3.c @@ -1,4 +1,8 @@ +#include "audio.h" main(int t) { - for(;;t++) - putchar(t*9&t>>4|t*5&t>>7|t*3&t/1024)-1; + init(); + for(;;t++) { + p(t*9&t>>4|t*5&t>>7|t*3&t/1024); + + } } diff --git a/f4.c b/f4.c index 1d39fa3..6c73431 100644 --- a/f4.c +++ b/f4.c @@ -1,10 +1,12 @@ +#include "audio.h" int main(int t) { + init(); for (t = 0;;t++) { int i; i = (t>>7-(t>>15)&-t>>7-(t>>15)); if (i==0) continue; - putchar(t>>4|t&(t>>5)/i); + p(t>>4|t&(t>>5)/i); } } diff --git a/f5.c b/f5.c index 754f37b..b8f1f11 100644 --- a/f5.c +++ b/f5.c @@ -1,4 +1,7 @@ +#include "audio.h" main(t){ - for(t=0;;t++) - putchar(((t*("36364689"[t>>13&7]&15))/12&128)+(((((t>>12)^(t>>12)-2)%11*t)/4|t>>13)&127)); + init(); + for(t=0;;t++) { + p(((t*("36364689"[t>>13&7]&15))/12&128)+(((((t>>12)^(t>>12)-2)%11*t)/4|t>>13)&127)); + } } diff --git a/f6.c b/f6.c index 9006333..0b63bc1 100644 --- a/f6.c +++ b/f6.c @@ -1,5 +1,8 @@ +#include "audio.h" main(t){ int y,x; + + init(); for(t=0;;t++) { x=t*"6689"[t>>16&3]/24&127; @@ -7,6 +10,6 @@ main(t){ if (y==0 || x==0) continue; - putchar((30000000000/(y)&1)*35+(x)*y/400000000+((t>>8^t>>10|1>>14|x)&63)); + p((30000000000/(y)&1)*35+(x)*y/400000000+((t>>8^t>>10|1>>14|x)&63)); } }