-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: audio3d
action: commit
revision:
path_from:
revision_from: f66f7ae2247c9bdf838852ad36e37932cd038b2f:
path_to:
revision_to:

git.thebackupbox.net

audio3d

git://git.thebackupbox.net/audio3d

commit f66f7ae2247c9bdf838852ad36e37932cd038b2f
Author: epoch <epoch@thebackupbox.net>
Date:   Wed Jun 3 22:50:37 2020 -0500

    junk

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..19a53d20a9d58696c88bf82e61881da9ce75feb6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+all: wave bouncepan monofy
+
+wave: LDLIBS=-lm
+
+bouncepan: LDLIBS=-lm
diff --git a/applypan.c b/applypan.c
new file mode 100644
index 0000000000000000000000000000000000000000..35df7502d4a066a9e6fe97380f45f589e3b50de4
--- /dev/null
+++ b/applypan.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+int main(int argc,char *argv) {
+  unsigned char in[2];
+  unsigned char out[2];
+  while(read(0,in,1) > 0 && read(0,in+1,1) > 0) {//we're reading in an audio byte and a pan byte.
+    in[0];//we need to move this byte left or right depending on value of buf[1]
+    in[1];//if this is 255, we need it full right-channel, if 0 we need full left-channel
+    out[0]=(in[0] * (in[1])) / 256;
+    out[1]=(in[0] * (255-in[1])) / 256;
+    write(1,out,2);
+  }
+}
diff --git a/audio3d.c b/audio3d.c
new file mode 100644
index 0000000000000000000000000000000000000000..40da68284144a138378e991205d86456b35ae554
--- /dev/null
+++ b/audio3d.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <idc.h>
+#include <string.h>
+#include <unistd.h>
+
+extern struct idc_global idc;
+
+void stream_handler(struct shit *me,char *line) {//we don't want to read lines...
+  if(line == 0) {//eof probably.
+    close(me->fd);
+    return;
+  }
+  char buffer[4096];
+  int r=read(me->fd,buffer,sizeof(buffer));
+  write(1,buffer,r);
+}
+
+void accept_handler(struct shit *me,char *line) {
+  struct sockaddr_in sa;
+  int i;
+  int derp=sizeof(sa);
+  int fd=accept(me->fd,(struct sockaddr *)&sa,&derp);
+  if(fd != -1) {
+    //getpeeraddr(fd)
+    i=add_fd(fd,stream_handler);
+    idc.fds[i].read_lines_for_us=0;
+  } else {
+    fprintf(stderr,"error accepting\n");
+  }
+  fprintf(stderr,"derp\n");
+}
+
+int main(int argc,char *argv[]) {
+  int i=0;
+  struct sockaddr_in sa;
+  memset(&sa,0,sizeof(struct sockaddr_in));
+  sa.sin_addr.s_addr = inet_addr("0.0.0.0");
+  sa.sin_port = htons(2600);
+  for(i=0;i<100;i++) {
+    idc.fds[i].fd=-1;
+  }
+  idc.shitlen=0;
+  int s=socket(AF_INET,SOCK_STREAM,6);//6 is TCP
+  if(bind(s,(struct sockaddr*)&sa,sizeof(sa)) != 0) {
+    perror("bind");
+    return 2;
+  }
+  if(listen(s,0) != 0) {
+    perror("listen");
+    return 1;
+  }
+  i=add_fd(s,accept_handler);
+  idc.fds[i].read_lines_for_us=0;
+  select_on_everything();
+}
diff --git a/bouncepan.c b/bouncepan.c
new file mode 100644
index 0000000000000000000000000000000000000000..a02cb22416f44fb01cfa7da2ac94f2ef67e8d8ce
--- /dev/null
+++ b/bouncepan.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <math.h>
+#include <unistd.h>
+
+int main(int argc,char *argv[]) {
+  double d,d2;
+  int i,j;
+  unsigned char s;
+  unsigned char p;
+  int length=5;//5 seconds
+  int bits=8;//8bit audio
+  //int rate=8000;//8khz samples per second
+  int rate=44100;
+  int k=0;
+  while(1) {
+  for(i=0;i<length;i++) {
+    for(j=0;j<rate;j++) {
+      read(0,&s,1);
+      d2=cos((float)k * (float)0.5 * M_PI * 2.0 / (float)rate) * 127.0 + 128.0; //8bit panning
+      p=(unsigned char)d2;
+      write(1,&s,1);//"left" channel is actual audio
+      write(1,&p,1);//all right.
+      //"right" channel is left-right pan
+      //write(1,"\0",1);//empty byte.
+      //if the freq is 1 hz, it start at 0, go to 1, go to 0, go to -1, and back to 0
+      k++;
+    }
+  }
+  }
+}
diff --git a/icy-client.c b/icy-client.c
new file mode 100644
index 0000000000000000000000000000000000000000..ad2fd3f5db502e9d727af4067e97feb91f61504b
--- /dev/null
+++ b/icy-client.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main() {
+  struct sockaddr_in sa;
+  memset(&sa,0,sizeof(sa));
+  sa.sin_addr.s_addr=inet_addr(argv[1]);
+  sa.sin_port=htons(argv[2]));
+  s=socket(AF_INET,SOCK_STREAM,6);
+  connect(s,(sturct sockaddr *)&sa,sizeof(sa));
+  req="GET / HTTP/1.1\r\nIcy-MetaData: 1\r\n\r\n";
+  write(s,req,strlen(req));
+  //now we need to parse the http response... bleh.
+  //what was the point of me writing an icy-client?
+  //to get bare audio and icy data separated... right.
+}
diff --git a/monofy.c b/monofy.c
new file mode 100644
index 0000000000000000000000000000000000000000..3401b8aceca7f1cef61981bcbc5ad34ca3756e00
--- /dev/null
+++ b/monofy.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int main() {
+  unsigned char buf[2];
+  while(fread(buf,sizeof(buf[0]),1,stdin) > 0 && fread(buf+1,sizeof(buf[0]),1,stdin)) {
+    buf[0]/=2;
+    buf[1]/=2;
+    buf[0]+=buf[1];
+    fwrite(buf,sizeof(buf[0]),1,stdout);
+  }
+}
diff --git a/monofy_s16le.c b/monofy_s16le.c
new file mode 100644
index 0000000000000000000000000000000000000000..8c907c890febd6a87228e3eb7cd4561c5c060b63
--- /dev/null
+++ b/monofy_s16le.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int main() {
+  signed short buf[2];
+  while(fread(buf,sizeof(buf[0]),1,stdin) > 0 && fread(buf+1,sizeof(buf[0]),1,stdin)) {
+    buf[0]/=2;
+    buf[1]/=2;
+    buf[0]+=buf[1];
+    fwrite(buf,sizeof(buf[0]),1,stdout);
+  }
+}
diff --git a/visual.c b/visual.c
new file mode 100644
index 0000000000000000000000000000000000000000..49332d315fe13096383d88659fb2d5b2bc609c12
--- /dev/null
+++ b/visual.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int main(int argc,char *argv[]) {
+  unsigned char x;
+  int i;
+  while(read(0,&x,1) > 0) {
+    for(i=0;i<x;i+=2) {
+      write(1,"X",1);
+    }
+    write(1,"\n",1);
+  }
+}
diff --git a/wave.c b/wave.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d9b9dd09a7cbd16d97d3af27f54a1614a818790
--- /dev/null
+++ b/wave.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <math.h>
+#include <unistd.h>
+
+int main(int argc,char *argv[]) {
+  double d,d2;
+  int i,j;
+  unsigned char s;
+  unsigned char p;
+  int length=5;//5 seconds
+  int freq = atoi(argv[1]);
+  int bits=8;//8bit audio
+  //int rate=8000;//8khz samples per second
+  int rate=44100;
+  int k=0;
+  while(1) {
+  for(i=0;i<length;i++) {
+    for(j=0;j<rate;j++) {
+      //read(0,&s,1);
+      d2=cos((float)k * (float)freq * M_PI * 2.0 / (float)rate) * 127.0 + 128.0; //8bit panning
+      p=(unsigned char)d2;
+      //write(1,&s,1);//"left" channel is actual audio
+      //"right" channel is left-right pan
+      write(1,&p,1);//all right.
+      //write(1,"\0",1);//empty byte.
+      //if the freq is 1 hz, it start at 0, go to 1, go to 0, go to -1, and back to 0
+      k++;
+    }
+  }
+  }
+}

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 11:07:55 2024