Frank's MP3 Player2 Question

Status
Not open for further replies.

jshooks

Well-known member
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 :

Frank_B_MPG3_Player2_Messages.PNG

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?
 

Attachments

  • Frank_B_MPG3_Player2.ino
    8.6 KB · Views: 74
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.
 
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();
}
 
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.
 
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.
 
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.
 
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:
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.
 
- 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/Arduino-Teensy-Codec-lib/tree/master/examples/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.
 
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?
 
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.
 
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?
 
Sorry to revive an old thread, did you ever review this? I experienced the exact same issue as above. I actually spent about 2hrs trying to figure out what I'd done wrong! I Loaded up the Mp3FilePlayer.ino - mp3's playing fine now. Seems like the advanced sketch gets stuck / hangs in the "while is playing loop" - it doesn't actually seem to start playing or even get into the update controls part of the while loop. Also noticed that in the sketch (for me anyway), it is searching for ".MP3" files, it doesn't find any until I changed the search to ".mp3" - lowercase I'll try piece together (I'm a real beginner - lol) an advanced player using the 2.ino files that have been made available by Frank. Thanks Frank!!
 
So it seems like the advanced sketch is super picky about the file name length. The 8.3 rule still seems to stand - even now in 2021!! I changed the file names to super short (8 characters before the dot) and all is working now - Strange that the Mp3FilePlayer.ino works with long file names though... Hope this helps anyone else that gets stuck with this.
 
So it seems like the advanced sketch is super picky about the file name length. The 8.3 rule still seems to stand - even now in 2021!! I changed the file names to super short (8 characters before the dot) and all is working now - Strange that the Mp3FilePlayer.ino works with long file names though... Hope this helps anyone else that gets stuck with this.

This should be fixed with the latest Teensyduino 1.54.
(i hope?)
 
Unfortunately, it's still the same.
Just gets stuck on songs with long filenames.
Also seems to be making duplicates with a ._ filename of each track on the sd card.
So it plays one track, then tries to play the same one (with dot, underscore) again, but gets stuck there as there's no such file.
I specifically purchased a T4 with audio board to make a kick ass mp3player, so...
I'm a bit sad to discover the limited functionality of mp3 playback (no long names / id3 tags).
Especially considering the T4 is not even working hard in the slightest.
Oh well, Im sure I'll find another use for it sometime down the line.
Thanks again for your input.
.
 
Unfortunately, it's still the same.
Just gets stuck on songs with long filenames.
Also seems to be making duplicates with a ._ filename of each track on the sd card.
So it plays one track, then tries to play the same one (with dot, underscore) again, but gets stuck there as there's no such file.
I specifically purchased a T4 with audio board to make a kick ass mp3player, so...
I'm a bit sad to discover the limited functionality of mp3 playback (no long names / id3 tags).
Especially considering the T4 is not even working hard in the slightest.
Oh well, Im sure I'll find another use for it sometime down the line.
Thanks again for your input.
.

Had no time to try the sketch, but i briefly looked over it:
char playthis[15];
could be the problem. Perhaps try 128 instead.
If it still not works,, I can take a look tomorrrow.

Anyway, these are examples only. The Idea is, that you write your own code ;)
 
128 made no difference either. I've been learning the code by watching videos (lots of them!!)
and using bits of examples to piece together a functional piece of code for my purposes.
My plan is to utilise the line input of the audio board, signal coming in from external dj mixer running through the teensy, out to a balanced op-amp circuit.
Then have an mp3 player (which I'm working on now) with 16x2 lcd / keypad board, that I could browse the music on sd card. Select a mp3 and keep it paused as a backup.
2 rotary pots to control each mixer gain, so if the dj software gives hassles or freezes, I quickly turn down that volume & play the backup track that was paused.
I think I've made good progress so far, I can now mix the line input with mp3's from the sd card.
I've been trying my best to figure out how the filenames are being delt with in this code, but this is still a bit above my level.
I figured out that the numbers in brackets[] related to the ascii table with [15] being "shift in" and [128] being an "extended code".
I just don't understand what relevance unusual characters like that has on the actual file names.
I still have a lot to learn, trying to learn from watching youtube videos & playing around with the code is one way to learn,
but it's painfully slow and always leaves the potential for learning something wrong. Most people are not willing to share their knowledge.
So I really do appreciate your input Frank. I'll take whatever I can get.
 
Status
Not open for further replies.
Back
Top