Home Forums Sparkfun MP3 Shield Library Support Forum Looping between a few tracks?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2368
    Anonymous
    Inactive

    I’m working on a project where I will be using sound inside an art installation. I would love to program the arduino using your mp3shield (with your library) and looping through 8 tracks. I don’t need serial monitoring since I will be powering it using a DC charger, and won’t need to alter it once I’ve loaded the code (It’s pretty much self-contained and straightforward).

    Frankly, I don’t know where to start. I was trying to sort of reverse engineer your example to remove the code I don’t need and keep only the minimal code, but I just can’t figure it out. Any help would be appreciated thanks!

    #2376

    Not sure if you question was answered with the other post.

    Whereas if you are going to simply play a sequence of tracks. The quick start is a good place along with the use of MP3player.isPlaying() function as to tell when a track is finished. Where something like the below would be a quick attempt to play track000.mp3 through track009.mp3

    for (int n = 0; n < 9 ; n++)
    {
    MP3player.playTrack(key_command);
    while (MP3player.isPlaying());
    }

     

    #2379
    Anonymous
    Inactive

    Thank you. Is there a way of tracking which track is currently playing? For example if track 1 is playing do this, or if track 8 is playing do that. Basically I’m asking if there’s a method that does that in the library. Thanks!

    Currently I’m just playing a track, initiating my action (turn on led) adding a delay (as long as the track is) stopping the track, and then playing the next track in a similar fashion.

    #2382

    There was a minor typo in the above example. Where “n” is the track number you are calling.

    for (int n = 0; n < 9 ; n++)
    {
    MP3player.playTrack(n);
    while (MP3player.isPlaying());
    }

    And since it is called by the loop the loop “n” knows which track is playing.

    More advanced one could rely on the SdFat Library to know which filename is playing.  The below code is the key components for it

    SdFile file;
    char filename[13];
    file.getFilename(filename);

    But it has been awhile since I have used them. So it would take some trails to get it going. But likely not too difficult.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.