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

    Has anyone gotten MP3 streaming to work on Core2?

    Scheduled Pinned Locked Moved SOFTWARE
    3 Posts 1 Posters 1.8k Views 1 Watching
    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.
    • W Offline
      wsanders
      last edited by

      I'm about ready to give up after three days of trial and error. Has anyone gotten MP3 streaming to work on Core2?

      Yesterday, I was able to stream a low-bandwidth station but today even that doesn't work. I posted some examples of what I have tried, in https://github.com/wsanders/M5Core2-Audio-Is-Broken. The sketch WSWebRadio-broken.ino was working yesterday for a low-bandwith (32k) stream, but produced broken distorted audio from a 192k stream. Today none of the programs in my repo produce any audio.

      I haven't seen any posts about working MP3 streaming sketches less than a couple years old, which seems to hint that it just doesn't work. Maybe everyone has switched to MicroPython?

      I am using Arduino IDE, M5Core2 library 0.1.9, ESP8266Audio 1.9.7.

      1 Reply Last reply Reply Quote 0
      • W Offline
        wsanders
        last edited by wsanders

        I got the sketches to work, They will be posted to the above repo shortly. The key changes from some of the existing code out there that does not work anymore:

        After WiFi connects, the delay must be increased to at least 1 sec:

          while ( !WiFi.isConnected() ) delay(100);
          delay(1000);
        

        Preallocating the source buffer seems to be essential:

        const int preallocateBufferSize = 128*1024;
        const int preallocateCodecSize = 85332; // AAC+SBR codec max mem needed
        void *preallocateBuffer = NULL;
        void *preallocateCodec = NULL;
        ...
          // Don't forget to malloc the buffers
          preallocateBuffer = malloc(preallocateBufferSize);
          preallocateCodec = malloc(preallocateCodecSize);
        ...
        srcbuf = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize);
        ...
          // Preallocating the MP3 generator doesn't seem to be essential
          //gen = new AudioGeneratorMP3(preallocateCodec, preallocateCodecSize);
        

        You must call M5.begin with the 6th argument false to disable the M5.Speaker code. With this argument, the skeptch will produce audio, but at half speed and half pitch:

          M5.begin(true, false, true, true, kMBusModeOutput, false);
        

        My M5Core2 library version is 0.1.9. I have 2.0.9 of the M5 board. definitions.

        W 1 Reply Last reply Reply Quote 0
        • W Offline
          wsanders @wsanders
          last edited by wsanders

          This post is deleted!
          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post