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)
audio.o: audio.c audio.h
sounds.o: sounds.c sounds.h
%: %.c audio.o
%: %.c audio.o sounds.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
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:

13
audio.c
View File

@ -4,12 +4,17 @@
const char* audio_dev = "/dev/audio";
FILE* audio;
void init() {
audio = fopen(audio_dev, "w");
void init(char* dev_file_name) {
if (dev_file_name != NULL) {
audio = fopen(dev_file_name, "a");
} else {
audio = stdout;
}
}
void p(int i) {
//fputc(i, audio);
putchar(i);
//fputc(i, audio);
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() {
//init();
int t;
for (t = 0;;t++) {
p((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7));
}
sound_loop_1(sound_1,0);
}
// vim:set sw=2 sts=2 et ai:

10
f2.c
View File

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

11
f3.c
View File

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

20
f4.c
View File

@ -1,12 +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;
p(t>>4|t&(t>>5)/i);
}
int main() {
int t;
for (t = 0;;t++) {
int i;
i = (t>>7-(t>>15)&-t>>7-(t>>15));
if (i==0)
continue;
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"
main(t){
//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));
}
#include "sounds.h"
main(){
sound_loop_1(sound_5,0);
}
// vim:set sw=2 sts=2 et ai:

26
f6.c
View File

@ -1,15 +1,17 @@
#include "audio.h"
main(t){
int y,x;
//init();
for(t=0;;t++)
{
x=t*"6689"[t>>16&3]/24&127;
y=t&16383;
if (y==0 || x==0)
continue;
p((30000000000/(y)&1)*35+(x)*y/400000000+((t>>8^t>>10|1>>14|x)&63));
}
main(int ac, char** av){
long t, y, x;
//init();
for(t=0;;t++)
{
x=t*"6689"[t>>16&3]/24&127;
y=t&16383;
if (y==0 || x==0)
continue;
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: