working towards unifying the sounds to a single command

This commit is contained in:
Vincent Batts 2012-11-19 14:42:33 -05:00
parent ec9844054b
commit 2ddb925d27
11 changed files with 93 additions and 54 deletions

View File

@ -6,8 +6,9 @@ LDFLAGS += -static -s
all: $(MUSIC_FILES) all: $(MUSIC_FILES)
audio.o: audio.c audio.h audio.o: audio.c audio.h
sounds.o: sounds.c sounds.h
%: %.c audio.o %: %.c audio.o sounds.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
clean: clean:

9
all.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
#include <unistd.h>
int main(int ac, char** av) {
//init();
return 0;
}
// vim:set sw=2 sts=2 et ai:

View File

@ -4,8 +4,12 @@
const char* audio_dev = "/dev/audio"; const char* audio_dev = "/dev/audio";
FILE* audio; FILE* audio;
void init() { void init(char* dev_file_name) {
audio = fopen(audio_dev, "w"); if (dev_file_name != NULL) {
audio = fopen(dev_file_name, "a");
} else {
audio = stdout;
}
} }
void p(int i) { void p(int i) {
@ -13,3 +17,4 @@ void p(int i) {
putchar(i); putchar(i);
} }
// vim:set sw=2 sts=2 et ai:

11
f1.c
View File

@ -1,10 +1,5 @@
#include "audio.h" #include "sounds.h"
int main() { int main() {
//init(); sound_loop_1(sound_1,0);
int t;
for (t = 0;;t++) {
p((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7));
}
} }
// vim:set sw=2 sts=2 et ai:

10
f2.c
View File

@ -1,7 +1,5 @@
#include "audio.h" #include "sounds.h"
int main(t){ int main(){
//init(); sound_loop_1(sound_2,0);
for(t=0;;t++) {
p(t*(((t>>12)|(t>>8))&(63&(t>>4))));
}
} }
// vim:set sw=2 sts=2 et ai:

11
f3.c
View File

@ -1,8 +1,5 @@
#include "audio.h" #include "sounds.h"
main(int t) { int main() {
//init(); sound_loop_1(sound_3,0);
for(;;t++) {
p(t*9&t>>4|t*5&t>>7|t*3&t/1024);
}
} }
// vim:set sw=2 sts=2 et ai:

6
f4.c
View File

@ -1,6 +1,6 @@
#include "audio.h" #include "audio.h"
int main(int t) { int main() {
//init(); int t;
for (t = 0;;t++) { for (t = 0;;t++) {
int i; int i;
i = (t>>7-(t>>15)&-t>>7-(t>>15)); i = (t>>7-(t>>15)&-t>>7-(t>>15));
@ -9,4 +9,4 @@ int main(int t) {
p(t>>4|t&(t>>5)/i); p(t>>4|t&(t>>5)/i);
} }
} }
// vim:set sw=2 sts=2 et ai:

10
f5.c
View File

@ -1,7 +1,5 @@
#include "audio.h" #include "sounds.h"
main(t){ main(){
//init(); sound_loop_1(sound_5,0);
for(t=0;;t++) {
p(((t*("36364689"[t>>13&7]&15))/12&128)+(((((t>>12)^(t>>12)-2)%11*t)/4|t>>13)&127));
}
} }
// vim:set sw=2 sts=2 et ai:

6
f6.c
View File

@ -1,6 +1,7 @@
#include "audio.h" #include "audio.h"
main(t){
int y,x; main(int ac, char** av){
long t, y, x;
//init(); //init();
for(t=0;;t++) for(t=0;;t++)
@ -13,3 +14,4 @@ main(t){
p((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));
} }
} }
// vim:set sw=2 sts=2 et ai:

26
sounds.c Normal file
View File

@ -0,0 +1,26 @@
#include "audio.h"
#include "sounds.h"
void sound_loop_1(int (*sp)(int i), int t) {
for (t = 0;;t++) {
p((*sp)(t));
}
}
int sound_1(int t) {
return (t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7);
}
int sound_2(int t) {
return (t*(((t>>12)|(t>>8))&(63&(t>>4))));
}
int sound_3(int t) {
return (t*9&t>>4|t*5&t>>7|t*3&t/1024);
}
int sound_5(int t) {
return (((t*("36364689"[t>>13&7]&15))/12&128)+(((((t>>12)^(t>>12)-2)%11*t)/4|t>>13)&127));
}
// vim:set sw=2 sts=2 et ai:

8
sounds.h Normal file
View File

@ -0,0 +1,8 @@
void sound_loop_1(int (*sp)(int i), int t);
int sound_1(int t);
int sound_2(int t);
int sound_3(int t);
int sound_5(int t);
// vim:set sw=2 sts=2 et ai: