-->
Page 7 of 27

Re: Demo: I2S sound output and MP3 decoding in an ESP8266

PostPosted: Wed Jun 17, 2015 11:37 am
by wzab
mikewen wrote:Hi Sprite_tm ,

Any plan to add I2S input in near future?


I'm also interested in the I2S input for my "wireless system for electric guitar" ( http://www.esp8266.com/viewtopic.php?f=11&t=2985 )

Thanks & regards,
Wojtek

Re: Demo: I2S sound output and MP3 decoding in an ESP8266

PostPosted: Wed Jun 17, 2015 7:55 pm
by Sprite_tm
armSeb: Mind sharing the code? I've been planning on getting the stereo synth to work myself, would be great to share efforts. Also, your solution is a very shaky one: it 'works' because of undefinded compiler behaviour: you're not supposed to not return something in a non-void function. You should be able to get the same behaviour in a 'valid' way by dramatically lowering the ADD_DEL_BUFFPERSAMP (to eg 5) or by disabling that functionality all together.

I2S input is something I'd like to show you, but at the moment my focus is somewhere else; also there's some internal hardware in developement that should be able to help us there but isn't finished yet. Please be patient, eventually we should get around to creating an example for it.

Re: Demo: I2S sound output and MP3 decoding in an ESP8266

PostPosted: Thu Jun 18, 2015 2:36 am
by armSeb
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=1

But 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.

Re: Demo: I2S sound output and MP3 decoding in an ESP8266

PostPosted: Thu Jun 18, 2015 8:43 am
by alonewolfx2
Sprite_tm any progress for 512kb flash?