OK, I'll try quickly the clean way
I just made a vimdiff between the two synth files and made changes to get it compile. I don't know if I have to make some other modifications.
Here is my method to parse http headers :
Code: Select allint ICACHE_FLASH_ATTR getIcyMetaint(int sock) {
int n, i;
char buf[1];
char wbuf[64];
int icy_interval;
memset(wbuf, '\0', sizeof(wbuf));
i=0;
while(1) {
n = read(sock, buf, 1);
if (n>0) {
if (buf[0]=='\n') {
// If we detect a newline
if (i>0) {
// printf(wbuf);
// printf("\n");
if(strncmp(wbuf, "icy-metaint:", 12)==0) {
icy_interval=atoi(wbuf+12);
// printf("%i\n",icy_interval);
return icy_interval;
}
} else {
// printf("Empty line\n");
// If this is an empty line : end of headers.
return 0;
}
memset(wbuf, '\0', sizeof(wbuf));
i=0;
} else {
if (buf[0]!='\r') {
// printf("Appending data\n");
wbuf[i]=buf[0];
i++;
}
}
}
}
}
This is not the cleanest method but it works. To get icy metadata, you need to add the following header to your request :
Code: Select allwrite(sock, "\r\nIcy-MetaData: 1", 17);
Here is the stereo synth :
https://www.dropbox.com/s/l2i8ipkl7gwdoj4/synth_stereo.c?dl=1But I only made basic modifications, to be able to compile it. I don't know ho I can get two pwm signals instead of one.