🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Updated version, working Core2 web radio player, M5Stack

    Core 2
    10
    22
    30.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      homeuser33
      last edited by homeuser33

      Re: [CORE2 as Web radio](without extra hardware ?)

      I made a few GUI changes, and checked into the library used for the decoding.

      I think it's worth noting that the actual library for the functions came from:
      Earle Philhower III
      Who credits his library in part to : StellaPlayer and libMAD
      https://github.com/earlephilhower/ESP8266Audio

      Looking through the library so far I can not tell if there is extra information extracted from the stream that we can make use of.

      Here is the latest code:

      /*
         March 28, 2021
         Made changes to the Example Core2 Web Radio Player from:
         https://www.hackster.io/tommyho/arduino-web-radio-player-c4cb23
      
          Wish List: 
          slightly organized the code into better sections (Done)
          Nicer Fonts (Done)
          Use 2nd CPU Core to handle GUI and button's so we keep it responsive
          Add bluetooth output to Bluetooth speakers / headest
          Get more information from the stream,  Album art, etc.
            --  Checked into what comes into the stream So far I don't see extra data
          Get track length and have a progress bar for the track
            -- Again I don't see if this information comes in from the library
          Have an interface to select WiFi network and enter password
          -- Store password in EEPROM
          Better mehod of selecting stations
          ? Maybe web interface for setting up station lists?
      
          I see that the actual library for the functions came from:
          Earle Philhower III
          Who credits his library to :  StellaPlayer and libMAD
          https://github.com/earlephilhower/ESP8266Audio
      
      
      */
      
      //
      //  m5StreamTest Version 2020.12b (Source/Buffer Tester)
      //  Board: M5StackCore2 (esp32)
      //  Author: tommyho510@gmail.com
      //  Required: Arduino library ESP8266Audio 1.60
      //
      
      #include <M5Core2.h>
      #include <driver/i2s.h>
      #include <WiFi.h>
      #include <AudioFileSourceICYStream.h>
      #include <AudioFileSource.h>
      #include <AudioFileSourceBuffer.h>
      #include <AudioFileSourceSPIRAMBuffer.h>
      #include <AudioGeneratorMP3.h>
      #include <AudioOutputI2S.h>
      #include "Free_Fonts.h"
      //#include <spiram-fast.h>
      
      const int bufferSize = 128 * 1024; // buffer size in byte
      
      
      // Enter your WiFi, Station, button settings here:
      
      const char *SSID = "ENTER_SSID_HERE";
      const char *PASSWORD = "ENTER_WIFI_PASSWORD_HERE";
      
      
      // Added Charlie FM in Portland Oregon
      //http://24083.live.streamtheworld.com:80/KYCHFM_SC
      //
      //Removed these from the list:
      //  {"Mega Shuffle", "http://jenny.torontocast.com:8134/stream"},
      //  {"Way Up Radio", "http://188.165.212.154:8478/stream"},
      //  {"Asia Dream", "https://igor.torontocast.com:1025/;.-mp3"},
      //  {"KPop Way Radio", "http://streamer.radio.co/s06b196587/listen"},
      //  {"SomaFM", "http://ice2.somafm.com/christmas-128-mp3"}
      
      const int stations = 7;// Change Number here if you add feeds!
      char * stationList[stations][2] = {
        {"Charlie FM", "http://24083.live.streamtheworld.com:80/KYCHFM_SC"},
        {"MAXXED Out", "http://149.56.195.94:8015/steam"},
        {"Orig. Top 40", "http://ais-edge09-live365-dal02.cdnstream.com/a25710"},
        {"Smooth Jazz", "http://sj32.hnux.com/stream?type=http&nocache=3104"},
        {"Smooth Lounge", "http://sl32.hnux.com/stream?type=http&nocache=1257"},
        {"Classic FM", "http://media-ice.musicradio.com:80/ClassicFMMP3"},
        {"Lite Favorites", "http://naxos.cdnstream.com:80/1255_128"}
      };
      
      float audioGain = 0.0;
      float gainfactor = 0.08;
      int currentStationNumber = 0;
      unsigned long disUpdate = millis();
      
      AudioGeneratorMP3 *mp3;
      AudioFileSourceICYStream *filemp3;
      AudioFileSourceBuffer *buffmp3;
      AudioOutputI2S *out, *outmp3;
      
      
      // Draw a + mark centred on x,y
      void drawDatumMarker(int x, int y)
      {
        M5.Lcd.drawLine(x - 5, y, x + 5, y, TFT_GREEN);
        M5.Lcd.drawLine(x, y - 5, x, y + 5, TFT_GREEN);
      }
      
      /// WIFI Routines *********************
      
      void initwifi() {
      
        M5.Lcd.setTextColor(TFT_BLUE, TFT_BLACK);
        
        M5.Lcd.setTextSize(2);
        M5.Lcd.setTextDatum(BC_DATUM);
        M5.Lcd.setFreeFont(FSB12);   
        M5.Lcd.drawString("Connecting..", M5.Lcd.width()/2, 200, GFXFF);
      
        WiFi.disconnect();
        WiFi.softAPdisconnect(true);
        WiFi.mode(WIFI_STA);
        WiFi.begin(SSID, PASSWORD);
        // Try forever
        int i = 0;
        while (WiFi.status() != WL_CONNECTED) {
          Serial.print("STATUS(Connecting to WiFi) ");
          delay(1500);
          i = i + 1;
          if (i > 15) {
            ESP.restart();
          }
        }
        Serial.println("\nWiFi Connected!\n");
      }
      
      
      // Display network information on the LCD
      void displayWiFiInformation() {
        M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
        M5.Lcd.setTextSize(1);
        M5.Lcd.setFreeFont(FSS9);    
        M5.Lcd.setTextDatum(BL_DATUM); 
        M5.Lcd.drawString("Network: ", 10, 165, GFXFF);
        M5.Lcd.drawString("IP: " , 10, 190, GFXFF);
        M5.Lcd.drawString(SSID, 90, 165, GFXFF);
        M5.Lcd.drawString(WiFi.localIP().toString(),40,190,GFXFF);
      }
      
      
      // Update WiFi Signal Strength
      void updateWiFiSignal() {
        // Display the WiFi Signal Strength
        M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
        M5.Lcd.setTextSize(1);
        M5.Lcd.setFreeFont(FSS9);    
        M5.Lcd.setTextDatum(BL_DATUM); 
        M5.Lcd.drawString("WiFi Signal: ", 10, 215, GFXFF);
        M5.Lcd.fillRect(112,195,30,20,BLACK);
        uint16_t clr = GREEN;
        clr = (WiFi.RSSI() < -70) ? TFT_RED : TFT_GREEN;
        M5.Lcd.setTextColor(clr, TFT_BLACK);  
        M5.Lcd.drawString(String(WiFi.RSSI()),115, 215, GFXFF);
      }
      
      
      /// Battery ***************************
      
      // Calculate Battery Useable range  (3.2 to 4.1 Volts)
      void displayBattery() {
        M5.Lcd.setTextSize(1);
        M5.Lcd.setFreeFont(FSS9);  
        int maxVolts = 410;  // Battery Max volts * 100
        int minVolts = 320;  // Battery Min Volts * 100
        M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
        
        M5.Lcd.setTextSize(1);
        char battInfo[5];
        dtostrf(M5.Axp.GetBatVoltage(),1,2,battInfo); 
        String btInfo = "Batt: " + String(battInfo);
        M5.Lcd.setTextDatum(BL_DATUM);  
        M5.Lcd.drawString(btInfo, 230, 215, GFXFF);
      //  drawDatumMarker(230,215);
          
        int batt = map(M5.Axp.GetBatVoltage() * 100, minVolts, maxVolts, 0 , 10000) / 100.0;
      
        // Draw Battery bar(s) on the right side of the screen
        uint16_t clr = GREEN;
        for (int x = 9; x >= 0; x--) {
          if (x < 3) clr = RED;
          else if (x < 6) clr = YELLOW;   
          M5.Lcd.fillRoundRect(314, (216 - (x * 24)), 6, 21, 2, (batt > (x * 10)) ? clr : BLACK);
          M5.Lcd.drawRoundRect(314, (216 - (x * 24)), 6, 21, 2, TFT_LIGHTGREY);
        }
      }
      
      
      // MISC  ****************************
      
      
      // Remove the Track information (While changing stations)
      void clearTrack() {
        M5.Lcd.fillRect(10, 55, 300, 70, TFT_DARKGREY); // Clear the area of old data
        M5.Lcd.drawRect(10, 55, 300, 70, BLUE); // Draw a box around the Track Information
      }
      
      
      // Identify buttons at the bottom of screen
      void drawButtons() {
        M5.Lcd.fillRect(10,220,300,25,YELLOW);
        M5.Lcd.setTextColor(TFT_BLACK);  
        M5.Lcd.setTextSize(1);
        M5.Lcd.setTextDatum(TC_DATUM);
        M5.Lcd.setFreeFont(FSB12);   
        M5.Lcd.drawString("Volume", 55,220, GFXFF);
        M5.Lcd.drawString("Station", M5.Lcd.width()/2,220, GFXFF);
        M5.Lcd.drawString("Mute", 270 ,220, GFXFF);  
      }
      
      
      // Get the Split String Value Used for Band or Track
      String getValue(String data, char separator, int index) {
        int found = 0;
        int strIndex[] = {0, -1};
        int maxIndex = data.length() - 1;
      
        for (int i = 0; i <= maxIndex && found <= index; i++) {
          if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i + 1 : i;
          }
        }
        return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
      }
      
      
      // MP3, Audio etc.  ****************************
      
      // Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc.
      void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string) {
        const char *ptr = reinterpret_cast<const char *>(cbData);
        (void) isUnicode; // Punt this ball for now
        // Note that the type and string may be in PROGMEM, so copy them to RAM for printf
        char s1[32], s2[64];
        strncpy_P(s1, type, sizeof(s1));
        s1[sizeof(s1) - 1] = 0;
        strncpy_P(s2, string, sizeof(s2));
        s2[sizeof(s2) - 1] = 0;
      
        String band  = getValue(s2, '-', 0);
        band.trim();
        String track = getValue(s2, '-', 1);
        track.trim();
      
        if(band.length() > 30) band = band.substring(0, 30);
        if(track.length() > 30) track = track.substring(0, 30);
      
      //  Serial.printf("Band: %s   Track:  %s  \n", band.c_str(), track.c_str());
        Serial.printf("METADATA(%s) '%s' = '%s'\n", ptr, s1, s2);
        M5.Lcd.setTextSize(1);
      
        M5.Lcd.setTextColor(TFT_BLACK, TFT_DARKGREY );
        
        clearTrack();
        M5.Lcd.setTextDatum(MC_DATUM);
        M5.Lcd.setFreeFont(FSS9); 
        if(band.length() < 20) M5.Lcd.setFreeFont(FSS12);                              // Select the font
        M5.Lcd.drawString(band, M5.Lcd.width()/2, 72, GFXFF);
        M5.Lcd.setFreeFont(FSS9);
        if(track.length() < 20) M5.Lcd.setFreeFont(FSS12);
      //  M5.Lcd.setTextDatum(MC_DATUM);
        M5.Lcd.drawString(track, M5.Lcd.width()/2, 107, GFXFF);
        Serial.flush();
        // Make sure the new song information does not overwrite the battery
        displayBattery();
      }
      
      
      // Called when there's a warning or error (like a buffer underflow or decode hiccup)
      void StatusCallback(void *cbData, int code, const char *string) {
        const char *ptr = reinterpret_cast<const char *>(cbData);
        // Note that the string may be in PROGMEM, so copy it to RAM for printf
        char s1[64];
        strncpy_P(s1, string, sizeof(s1));
        s1[sizeof(s1) - 1] = 0;
        Serial.printf("STATUS(%s) '%d' = '%s'\n", ptr, code, s1);
        Serial.flush();
      }
      
      
      void stopPlaying() {
        Serial.printf("Stopping MP3...\n");
        if (mp3) {
          mp3->stop();
          delete mp3;
          mp3 = NULL;
        }
        Serial.printf("MP3 Stopped, Stopping Buffer...\n");
        if (buffmp3) {
          buffmp3->close();
          delete buffmp3;
          buffmp3 = NULL;
        }
        Serial.printf("Buffer stopped... Stopping File ...\n");
        if (filemp3) {
          filemp3->close();
          delete filemp3;
          filemp3 = NULL;
        }
        if (outmp3) {
          //    filemp3->close();
          delete outmp3;
          outmp3 = NULL;
        }
      
        Serial.printf("STATUS(Stopped)\n");
        Serial.flush();
      }
      
      
      // Update the Station Label
      void updateStation(String message) {
        M5.Lcd.fillRect(10, 10, 300, 35, BLACK); // Clear out other information on the line
        M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK);
        M5.Lcd.setTextSize(1);
        M5.Lcd.setTextDatum(TC_DATUM);
      
        M5.Lcd.setFreeFont(FSB18);
        M5.Lcd.drawString(message, M5.Lcd.width()/2, 10, GFXFF);
      }
      
      
      // Change to the next station
      void changeStation() {
        updateStation("Changing..Wait..");
        currentStationNumber++;
        if (currentStationNumber >= stations) currentStationNumber = 0;
        Serial.printf("\n******** Changing to channel number: %i\n", currentStationNumber);
      }
      
      
      // Change the volume level
      // Update the volume graphic
      void changeVolume() {
        audioGain += 1.0;
        if (audioGain > 10.0) {
          audioGain = 1.0;
        }
        if (audioGain < 0.0) {
          audioGain = 0.0;
        }
        
        int xtPos = 260; // X Position for the Volume indication
        outmp3->SetGain(audioGain * gainfactor); // Change Volume to new level
      
      //---------New Volume Bar on left side of LCD  *******************
        // Draw Volume bar(s) on the left side of the screen
        uint16_t clr = RED;
        for (int x = 9; x >= 0; x--) {
          if (x < 5) clr = GREEN;
          else if (x < 8) clr = TFT_ORANGE;   
          M5.Lcd.fillRoundRect(0, (216 - (x * 24)), 6, 21, 2, (audioGain > x ) ? clr : BLACK);
          M5.Lcd.drawRoundRect(0, (216 - (x * 24)), 6, 21, 2, TFT_LIGHTGREY);
        }
      
        // Alternate Draw the Volume Indicator (Triangle)
      //  M5.Lcd.fillTriangle(xtPos, 20, xtPos + 50, 20, xtPos + 50, 0, BLACK); // Clear out old Meter
      //  if (audioGain > 9) { // If we are full, draw red, blue and green
      //    M5.Lcd.fillTriangle(xtPos, 20, xtPos + (5 * audioGain), 20, xtPos + (5 * audioGain), 20 - (2 * audioGain), RED);
      //    M5.Lcd.fillTriangle(xtPos, 20, xtPos + (5 * 9), 20, xtPos + (5 * 9), 20 - (2 * 9), BLUE);
      //    M5.Lcd.fillTriangle(xtPos, 20, xtPos + (5 * 6), 20, xtPos + (5 * 6), 20 - (2 * 6), GREEN);
      //  }
      //  else if (audioGain >= 6) { // if above 5, draw blue and green
      //    M5.Lcd.fillTriangle(xtPos, 20, xtPos + (5 * audioGain), 20, xtPos + (5 * audioGain), 20 - (2 * audioGain), BLUE);
      //    M5.Lcd.fillTriangle(xtPos, 20, xtPos + (5 * 6), 20, xtPos + (5 * 6), 20 - (2 * 6), GREEN);
      //  }
      //  else if (audioGain >= 1)
      //    M5.Lcd.fillTriangle(xtPos, 20, xtPos + (5 * audioGain), 20, xtPos + (5 * audioGain), 20 - (2 * audioGain), GREEN);
      }
      
      
      /*
         Setup output to I2S Device
         Set Pins and Gain
         Set FileSource as web radio station
         Join FileSource to get MetaData
         Create Buffer for data
         Register Callback for...?
         Begin the MP3 playback
      */
      void playMP3() {
        outmp3 = new AudioOutputI2S(0, 0); // Output to builtInDAC
        outmp3->SetPinout(12, 0, 2);
        outmp3->SetOutputModeMono(true);
        outmp3->SetGain(audioGain * gainfactor);
        filemp3 = new AudioFileSourceICYStream(stationList[currentStationNumber][1]);
        filemp3->RegisterMetadataCB(MDCallback, (void*)"ICY"); // ID3TAG  // ICY
        // StreamTitle
        buffmp3 = new AudioFileSourceBuffer(filemp3, bufferSize);
        buffmp3->RegisterStatusCB(StatusCallback, (void*)"buffer");
        mp3 = new AudioGeneratorMP3();
        mp3->RegisterStatusCB(StatusCallback, (void*)"mp3");
        mp3->begin(buffmp3, outmp3);
        Serial.printf("STATUS(URL) %s %s\n", stationList[currentStationNumber][0], stationList[currentStationNumber][1]);
        Serial.flush();
        updateStation(String(stationList[currentStationNumber][0]));
      }
      
      
      void loopMP3() {
        if (mp3 != NULL) {  // To avoid crash while changing stationsI
          if (mp3->isRunning()) {
            if (!mp3->loop()) mp3->stop();
          } else {
            Serial.printf("Status(Stream) Stopped \n");
            clearTrack();
            changeStation();
            //      stopPlaying();
            delay(1000);
            playMP3();
          }
        }
      }
      
      
      // General Arduino Routines
      
      void setup() {
        Serial.begin(115200);
      
        M5.begin();
        M5.Axp.SetSpkEnable(true);
        //  M5.Lcd.setRotation(3);
        M5.Lcd.fillScreen(BLACK);
        M5.Lcd.setTextWrap(false);
      
        M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK);
        M5.Lcd.setTextSize(1);
        M5.Lcd.setTextDatum(TC_DATUM);
        M5.Lcd.setFreeFont(FSB18);   
        M5.Lcd.drawString("Core2 Web Radio", M5.Lcd.width()/2, 20, GFXFF);
      
        initwifi();
        delay(500);
        M5.Lcd.clear();
        drawButtons();
        playMP3();
        changeVolume();  // To update Volume setting and graphic
        displayWiFiInformation();
      }
      
      
      void loop() {
        loopMP3();
        M5.update();
      
        if (m5.BtnA.wasPressed()) { //Change Volume(Button A)
          changeVolume();
        }
      
        if (m5.BtnB.wasPressed()) { //Change Station(Button B)
          clearTrack();
          changeStation();
          stopPlaying();
          playMP3();
        }
      
        if (m5.BtnC.wasPressed()) { //Mute  (Button C)
          audioGain = -1.0;
          changeVolume();
        }
      
        // Update the battery voltage, and WiFi Signal every second
        if ((disUpdate + 1000) < millis()) {
          disUpdate = millis();
          displayBattery();
          updateWiFiSignal();
        }
      }
      
      
      
      

      But this is a slightly nicer interface.

      R 1 Reply Last reply Reply Quote 0
      • R
        raychmond @homeuser33
        last edited by

        @homeuser33
        Thanks for the updates. The new version gave me compiling error because the font not found. Then I added #include "Free_Fonts.h", now it's working.
        I really like this web radio player, especially the stations you chose. I play this all day by my laptop.
        Looking forward to seeing the new updates.

        H 1 Reply Last reply Reply Quote 0
        • H
          homeuser33 @raychmond
          last edited by homeuser33

          @raychmond
          Thank you, I've added the include now in the program, not sure why it worked for me without it.

          I'll make the changes in the program listing above. Thank you.

          Yes, I like Charlie FM : https://worldradiomap.com/us-or/play/kych_live
          If you click the 'Listen with your player' button it downloads a .PLS file that has links to their station. I have not found many good stations with this option.

          https://www.radio.com/charliefm

          world101W 1 Reply Last reply Reply Quote 0
          • world101W
            world101 @homeuser33
            last edited by

            @homeuser33

            Just a suggestion... Instead of posting your code and updates here, can you please upload them to Github so change management and commits are easier to track? I apologize if you already have it on Github... maybe I missed it.

            H 2 Replies Last reply Reply Quote 0
            • H
              homeuser33 @world101
              last edited by

              @world101
              No, It's a good point. Generally I have not shared much code since I'm still fairly new to the M5Stack hardware. I was thinking this would be a one off since I found the answer for the media player. But its a good point. I'll check into that.
              Thank you.

              1 Reply Last reply Reply Quote 0
              • H
                homeuser33 @world101
                last edited by

                @world101

                Okay, that seemed easier than I thought.
                Link: https://github.com/bwbguard/M5Stack-Core2-MediaPlayer

                world101W 2 Replies Last reply Reply Quote 0
                • world101W
                  world101 @homeuser33
                  last edited by

                  @homeuser33

                  👍🏻👍🏻👍🏻 Thanks!

                  1 Reply Last reply Reply Quote 0
                  • world101W
                    world101 @homeuser33
                    last edited by

                    @homeuser33

                    Two things based on my testing.

                    1. The program works with latest ESP8266Audio v1.8.1 library as well.
                    2. I had to disable PSRAM in the Arduino board settings to get the program to work. When enabled, Arduino would flash the program and reset, but nothing would happen after that. Here is my board setup for Arduino on my Mac.

                    0_1616950951750_Screen Shot 2021-03-28 at 1.01.24 PM.png

                    Thanks!

                    H 1 Reply Last reply Reply Quote 0
                    • H
                      homeuser33 @world101
                      last edited by

                      @world101
                      I'm not sure what to say about that, PSRAM is enabled on my Linux setup and so far seems to be working.

                      1 Reply Last reply Reply Quote 0
                      • R
                        raychmond
                        last edited by

                        I think it's the matter of the board selection. When I first tried homeuser33's code I used the M5Stack OEM board: M5Stack Arduino>M5Stack-Core2(The PSRAM is enabled). It kept rebooting itself. I then switched to ESP32 Arduino>M5Stack-Core2(The PSRAM is enabled as well), it then worked.
                        Today, I tried different combinations. It ended up with that the only scenario that it's not working if you use M5Stack Arduino>M5Stack-Core2 with PSRAM enabled. M5Stack Arduino>M5Stack-Core2 with PSRAM disabled works perfectly like world101 said. But if you use ESP32 Arduino>M5Stack-Core2, both enabled and disabled work. So I guess this is the matter of selecting different boards.

                        Thanks!

                        H 1 Reply Last reply Reply Quote 1
                        • H
                          homeuser33 @raychmond
                          last edited by

                          @raychmond
                          Thanks for the update, It's been awhile sine I added the Core2 board manager so I don't remember which source I used. If I find it I'll update here. Thank you.

                          1 Reply Last reply Reply Quote 1
                          • B
                            bhupiister
                            last edited by

                            @homeuser33 I tried downloading your code and running. It compiles and load on Core2 but then the touch does not work and cannot hear any Audio, it feels like the program has halted. It does try to play something as i can hear a sound but after that it stops.

                            P 1 Reply Last reply Reply Quote 0
                            • C
                              clairlune
                              last edited by

                              @homeuser33 said in Updated version, working Core2 web radio player, M5Stack:

                              Hello, the code runs but it is stuck on the "Connecting" screen from the initwifi() function. I put the correct SSID and password it is still not working. Please try to help me out.

                              P 1 Reply Last reply Reply Quote 0
                              • P
                                perlix @bhupiister
                                last edited by

                                @bhupiister
                                I had a similar problem. You could try to remove the line 'Serial.begin(115200);' in setup(). It has already been called by M5Core2.cpp from the library. Calling it a second time makes a couple of my sketches hang.

                                W 1 Reply Last reply Reply Quote 0
                                • P
                                  perlix @clairlune
                                  last edited by

                                  @clairlune
                                  See my reply @bhupiister (after it has been approved). Hope it solves your problem.

                                  1 Reply Last reply Reply Quote 0
                                  • J
                                    jdonth
                                    last edited by

                                    Attempting to compile the web radio player on a Core2. I am getting the following errors. Any help would be appreciated.
                                    Joe

                                    Arduino: 1.8.19 (Windows 10), Board: "M5Stack-Core2, Enabled, Default (2 x 6.5 MB app, 3.6 MB SPIFFS), 240MHz (WiFi/BT), 1500000, None"

                                    C:\Users\jld\Documents\Arduino\MediaPlayer\MediaPlayer.ino:61:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

                                    };

                                    ^

                                    In file included from C:\Users\jld\Documents\Arduino\libraries\ESP8266Audio\src\AudioGeneratorMIDI.cpp:65:

                                    C:\Users\jld\Documents\Arduino\libraries\ESP8266Audio\src\libtinysoundfont/tsf.h: In function 'void tsf_channel_midi_control(tsf*, int, int, int)':

                                    C:\Users\jld\Documents\Arduino\libraries\ESP8266Audio\src\libtinysoundfont/tsf.h:2100:1: error: insn does not satisfy its constraints:

                                    }

                                    ^

                                    (insn 858 343 344 51 (set (reg:SF 19 f0 [407])

                                    (mem/u/c:SF (symbol_ref/u:SI ("*.LC248") [flags 0x2]) [0 S4 A32])) "C:\Users\jld\Documents\Arduino\libraries\ESP8266Audio\src\libtinysoundfont/tsf.h":2053 47 {movsf_internal}

                                    (nil))

                                    during RTL pass: postreload

                                    C:\Users\jld\Documents\Arduino\libraries\ESP8266Audio\src\libtinysoundfont/tsf.h:2100:1: internal compiler error: in extract_constrain_insn, at recog.c:2210

                                    Please submit a full bug report,

                                    with preprocessed source if appropriate.

                                    See https://gcc.gnu.org/bugs/ for instructions.

                                    exit status 1

                                    Error compiling for board M5Stack-Core2.

                                    1 Reply Last reply Reply Quote 0
                                    • N
                                      nerdlogger
                                      last edited by

                                      @jdonth Had the exact same problem.........after 3 hours of googling, finally found the issue. Take a look at this diff file:

                                      https://git.koehlerweb.org/frodovdr/Sonoff-Tasmota/commit/8a764f86ee9f1129507f4654d07c7a7cb24cc87e

                                      It's totally unrelated to this project. Just a bug that freaks out the IDE. Anyhow......a couple of lines need to be changed in :

                                      \libraries\ESP8266Audio\src\libtinysoundfont\tsf.h

                                      Hopefully it makes sense......Hope it helps....

                                      1 Reply Last reply Reply Quote 0
                                      • A
                                        analog_man
                                        last edited by

                                        Before I get too involved uploading code or showing library versions I'm using, can anyone else on this thread verify whether their Core2 player still streams correctly?

                                        I bought a new Core2 last week and was happy to find bwbguard's code. I removed some of the stations that don't exist anymore, but left in these three:

                                        {"Orig. Top 40", "http://ais-edge09-live365-dal02.cdnstream.com/a25710"},
                                        {"Classic FM", "http://media-ice.musicradio.com:80/ClassicFMMP3"},
                                        {"Lite Favorites", "http://naxos.cdnstream.com:80/1255_128"}

                                        The Classic FM sounds decent, but the other two are greatly distorted and sound like they're playing at 1/4 or 1/2 rate or so. I have tried other MP3 url's, and those sound distorted too so it definitely seems the norm and not the exception.

                                        VLC showed me the bit rates of the 3 above are 128 kb/s, 32 bits/sample, 44.1 kHz sample rate.

                                        What's more, this Core2 web player seems to change stations on its own sometimes and occasionally restart.

                                        This happens with latest ESP8266Audio 1.9.7 library, but I have tried previous as well. I'm using 0.1.4 M5Stack_Core2 library.

                                        I read this thread and tried toggling the PSRAM enable, and tried the Core2 board from M5stack as well as ESP32, but the one from ESP32 would not compile.I've tried 160 and 240 MHz which makes no difference.

                                        I even tried the code from this thread, the 'original' thread, and the code from bwbguard's github site.

                                        Can anyone offer some suggestions?

                                        Thanks!

                                        N 1 Reply Last reply Reply Quote 0
                                        • N
                                          nerdlogger @analog_man
                                          last edited by

                                          @analog_man I know this is more than a year old, but maybe you'll see it (or someone else will). I just installed the player code on my core2 device. I grabbed the github version. I have M5Core2 version 0.1.8 installed and initially I had the exact same issues you're describing. The two stations that worked sounded like they were playing at half or quarter speed.

                                          See here for discussion: https://github.com/m5stack/M5Core2/issues/110

                                          The short of it:

                                          replace "M5.begin();" in setup() with "M5.begin(true, true, true, true, kMBusModeOutput, false); ".......

                                          Pretty much perfect playback. I use the following links:

                                          const int stations = 9;// Change Number here if you add feeds!
                                          char * stationList[stations][2] = {
                                          {"Orig. Top 40", "http://ais-edge09-live365-dal02.cdnstream.com/a25710"},
                                          {"Lite Favorites", "http://naxos.cdnstream.com:80/1255_128"},
                                          {"ORF O3", "http://ors-sn02.ors-shoutcast.at/oe3-q2a"},
                                          {"ORF Salzburg", "http://ors-sn07.ors-shoutcast.at/sbg-q2a"},
                                          {"CBC Music #1", "http://26423.live.streamtheworld.com/CBLFM_CBC_SC"},
                                          //{"CBC Music #2", "http://19003.live.streamtheworld.com/CBLFM_CBC_SC"},
                                          //{"CBC Music #3", "http://18063.live.streamtheworld.com/CBLFM_CBC_SC"},
                                          {"WETA Classical #1", "http://17643.live.streamtheworld.com/WETAFM_SC"},
                                          //{"WETA Classical #2", "http://26103.live.streamtheworld.com/WETAFM_SC"},
                                          //{"WETA Classical #3", "http://26153.live.streamtheworld.com/WETAFM_SC"},
                                          //{"Classic FM", "http://media-ice.musicradio.com:80/ClassicFMMP3"},
                                          {"Radio Classique", "http://radioclassique.ice.infomaniak.ch/radioclassique-high.mp3"},
                                          {"Concertgebouw Live", "http://i1.cdn.jetstre.am:8000/sz=RCOLiveWebradio=mp3-192"}
                                          };

                                          I'm right now listening to these and they all work like a charm. Even the 192Kb/s RCO Live (Concertgebouw Live) works. You can check the stream links in VLC to make sure.

                                          Hope this helps.....

                                          A 1 Reply Last reply Reply Quote 0
                                          • A
                                            analog_man @nerdlogger
                                            last edited by

                                            @nerdlogger Thank you so much for passing this along! I haven't done much with this in the last year, so forgot where I was at with it, but it will be nice to formally fix the problem as listed in that discussion.

                                            As an aside, I did have to get a new Core2 from Mouser (after discussion with M5Stack, who paid for the replacement), because my display on first Core2 started 'fogging up' / going bad around the edges. I had left it on for a while, so not sure if that was related. Anyhow, it makes me wonder about the display quality on these. I had attempted to help M5Stack out as best I could by providing the serial # of bad unit, but I had finally tossed my box a few weeks before this happened. The serial # is not embedded in any of the M5Stack memory/firmware, so that's unfortunate for them. It's only on the box it arrives in.

                                            Finally, I realize the fun of programming a Core2 or other development board with whatever a programmer wants to do with it (which is why we buy these!), but for somebody who wants a pure streaming internet radio player that pretty much embodies what a person could eventually turn a Core2 into, check out the Yoto Player or Yoto Mini player. It is designed for children, but uses RFID cards that are inserted on top. Point is that you can program radio station URLs onto a card and select whatever station you want. Custom icons on small display, great speaker(s), excellent WIFI connectivity, and great battery life. I own both of those (well, my children do!) and can attest to the great ability as a streaming radio player. This performance is much better than portable offerings from Sangean, Lemega, Ocean Digital, etc.

                                            Thanks again!

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post