Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: Frank's MPG3 Player2 Question

  1. #1

    Frank's MPG3 Player2 Question

    I'm trying to test Frank B's MPG3 Player2 example code and cannot hear any sound out of the audio line output which I assume would be present when running the sketch with recorded MPG3 music on the SD card. However, no sound is present and the monitor lists each of the 5 songs being accessed is rapped sequence. I have not altered the code except to comment out the setup and main loop reference at the bottom (see attached sketch). The monitor lists the following which :

    Click image for larger version. 

Name:	Frank_B_MPG3_Player2_Messages.PNG 
Views:	13 
Size:	12.7 KB 
ID:	16024

    Also, I'm wondering about the usage of EEPROM to store the track position:

    void playFileMP3(const char *filename)
    {
    Serial.print("Playing file: ");
    Serial.print(track);
    Serial.print(" - ");
    Serial.println(filename);
    trackchange = true; //auto track change is allowed.
    // Start playing the file. This sketch continues to
    // run while the file plays.
    EEPROM.write(0,track); //meanwhile write the track position to eeprom address 0
    playMp31.play(filename);


    // Simply wait for the file to finish playing.
    while (playMp31.isPlaying()) {
    // update controls!
    controls();
    serialcontrols();
    }
    }

    If the track # is written every time a new track is accessed and code is run over a long period of time, wouldn't this reduce EEPROM life expectancy? It seems a RAM location could be used instead. Any thoughts on this?
    Attached Files Attached Files

  2. #2
    Sorry, I'm using the T3.2 with Audio Shield and running Arduino 1.8.5 with Duino 1.4.2. Audio Shield is stacked on T3.2.

  3. #3
    Wondering about something that might explain issue of not playing songs. In Frank's setup code he is looking for file extension with 1st character .M for MP3 or .A for AAC (see code segment below). If the file name does not have this extension, could that cause the file not play even though the monitor prints MP3 for type? Windows directory listing does not show this extension, but maybe it is really there.

    while(true) {

    File files = root.openNextFile();
    if (!files) {
    //If no more files, break out.
    break;
    }
    String curfile = files.name(); //put file in string
    //look for MP3 or AAC files
    int m = curfile.lastIndexOf(".MP3");
    int a = curfile.lastIndexOf(".AAC");
    int a1 = curfile.lastIndexOf(".MP4");
    int a2 = curfile.lastIndexOf(".M4A");
    //int w = curfile.lastIndexOf(".WAV");

    // if returned results is more then 0 add them to the list.
    if(m > 0 || a > 0 || a1 > 0 || a2 > 0 ){

    tracklist[tracknum] = files.name();
    if(m > 0) trackext[tracknum] = 1;
    if(a > 0) trackext[tracknum] = 2;
    if(a1 > 0) trackext[tracknum] = 2;
    if(a2 > 0) trackext[tracknum] = 2;
    // if(w > 0) trackext[tracknum] = 3;
    Serial.print(m);
    tracknum++;
    }
    // close
    files.close();
    }

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,566
    The file extension must be present, and correct.
    It plays all files if they are encoded correctly:
    44100Hz, max two channels, 16bit. Sometimes metadata like included pictures can cause trouble. remove them with a tool of your choice. If you still have trouble playing a file, please contact me via mail and send me that file.

  5. #5
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,566
    Quote Originally Posted by Frank B View Post
    The file extension must be present, and correct.
    It plays all files if they are encoded correctly:
    44100Hz, max two channels, 16bit. Sometimes metadata like included pictures can cause trouble. remove them with a tool of your choice. If you still have trouble playing a file, please contact me via mail and send me that file.
    Edit: Some time ago, I added testfiles - you can find them in examples/testfiles.

  6. #6
    Frank, thanks for your support on this issue. I look under File/Examples and did not find "testfiles" as a listing in the Arduino IDE menu. I'm running Arduino 1.8.5 with Teensyduino 1.4.2. Do I need to update the software or is this on forum.pjrc.com? I tried converting a .wav file to .mp3 and .aac format using Switch Plus audio converter by NCH with audio tags turn off, but same results as before. I would think a wave file would have no metadata embedded in it, but maybe it does.

    In any event, is there code that can be used to automatically ignore or skip over any metadata before play begins. The reason I'm asking this is if I'm designing a product that the general public will use, I wouldn't want them to have to use software to strip out embedded metadata just to play a prerecorded song.

  7. #7
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    2,952
    Maybe you need to get the updated library. It looks like there are 4 MP3 files in examples/testfiles that were added 4 months ago:

  8. #8
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,566
    I wrote "sometimes".. that means yes, it tries to skip metadata.
    Without having one of your not working files, i can't help you.
    95%of problems with this lib were wrong usage.
    Do you have enough RAM free?
    Last edited by Frank B; 03-02-2019 at 08:35 PM.

  9. #9
    Frank, I updated Teensyduino to version 1.4.5 and searched for File/Examples/Testfiles under the drop down menu. Still could not find them listed. In any event, I tried to upload a couple of the mp3 audio files for you to test in a zip file, but could not with "manage attachments". Not sure why this is happening. Maybe the only way to get them to you is via email, but don't have your email to send them.

    I have tried to convert these .mp3 files to .aac using the Switch Plus converter from NCH with audio tags turned off which I think would eliminate metadata, but maybe not. Of course, converted Wave files of these songs work fine with the normal audio.h library.

  10. #10
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,566
    - The CODECS lib is NOT part of teensyduino
    - No, mp3 files are not displayed in the Arduino menu.. of course not - would that make any sense? Open the explorer and go the libs subdirectory. On Github, they are here: https://github.com/FrankBoesing/Ardu...ples/testfiles
    - Upload:Yes, I wrote "send a mail"... it's everywhere.Ok... for the spammers :-( here it is again: f.boesing -AT- gmx -DOT- de - and now please don't say you don't understand this syntax... please send only one file. - But please test the testfiles first!
    - I don't know the "Switch Plus" converter, and have never used it.

  11. #11
    I downloaded the 4 example/testfiles, tested them to make sure they played the songs, tranferred them on a Sandisk 16 GB SD card, compiled and programmed the Frank_B_MP3_Player2 sketch on a new Teensy 3.2 and Audio Shield board. The same rapid listing in serial monitor of files being accessed, but not played. So it appears it is not the .mp3 files that is the problem. I tried this on another set of SD card (same example songs), Teensy 3.2 and Audio Shield. I don't have the 3 buttons connected on the breadboard for next, previous or pause to inputs 2, 3 and 4. But since they are pull high, I don't think that would prevent it from playing the songs. As to your comment about free RAM, since this is an un-modified sketch (except for the "user" main loop and setup at the bottom) I don't think should be a problem either. Any ideas?

  12. #12
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,566
    Quote Originally Posted by jshooks View Post
    I downloaded the 4 example/testfiles, tested them to make sure they played the songs, tranferred them on a Sandisk 16 GB SD card, compiled and programmed the Frank_B_MP3_Player2 sketch on a new Teensy 3.2 and Audio Shield board. The same rapid listing in serial monitor of files being accessed, but not played. So it appears it is not the .mp3 files that is the problem. I tried this on another set of SD card (same example songs), Teensy 3.2 and Audio Shield. I don't have the 3 buttons connected on the breadboard for next, previous or pause to inputs 2, 3 and 4. But since they are pull high, I don't think that would prevent it from playing the songs. As to your comment about free RAM, since this is an un-modified sketch (except for the "user" main loop and setup at the bottom) I don't think should be a problem either. Any ideas?
    No. Maybe try the other example?
    Open Mp3FilePlayer.ino and edit the filenames.

  13. #13
    Now it works with the Mp3FilePlayer program and same songs! Not quite sure what that means as far as the more advanced Frank_B_MP3_Player2? I would prefer the latter as it has more functions like auto loading file names. I suppose I could start integrating those features into the Mp3FilePlayer and see where it starts malfunctioning. Is that your advise?

  14. #14
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,566
    Hm, looks like we should review it.. It was a contribution by a user.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •