Exemple #1
0
boolean Adafruit_VS1053_FilePlayer::startPlayingFile(const char *trackname) {
    // reset playback
    sciWrite(VS1053_REG_MODE, VS1053_MODE_SM_LINE1 | VS1053_MODE_SM_SDINEW);
    // resync
    sciWrite(VS1053_REG_WRAMADDR, 0x1e29);
    sciWrite(VS1053_REG_WRAM, 0);

    currentTrack = SD.open(trackname);
    if (!currentTrack) {
        return false;
    }

    // As explained in datasheet, set twice 0 in REG_DECODETIME to set time back to 0
    sciWrite(VS1053_REG_DECODETIME, 0x00);
    sciWrite(VS1053_REG_DECODETIME, 0x00);

    playingMusic = true;

    // wait till its ready for data
    while (!readyForData());


    // fill it up!
    while (playingMusic && readyForData())
        feedBuffer();

//  Serial.println("Ready");

    return true;
}
void Adafruit_VS1053_FilePlayer::pausePlaying(boolean pause) {
    if (pause)
        playingMusic = false;
    else {
        playingMusic = true;
        feedBuffer();
    }
}
Exemple #3
0
boolean Adafruit_VS1053_FilePlayer::playFullFile(const char *trackname) {
    if (!startPlayingFile(trackname)) return false;

    while (playingMusic) {
        // twiddle thumbs
        feedBuffer();
    }
    // music file finished!
    return true;
}
boolean Adafruit_VS1053_FilePlayer::startPlayingFile(const char *trackname) {
  // reset playback
  sciWrite(VS1053_REG_MODE, VS1053_MODE_SM_LINE1 | VS1053_MODE_SM_SDINEW);
  // resync
  sciWrite(VS1053_REG_WRAMADDR, 0x1e29);
  sciWrite(VS1053_REG_WRAM, 0);

  currentTrack = SD.open(trackname);
  if (!currentTrack) {
    return false;
  }
    
  // We know we have a valid file. Check if .mp3
  // If so, check for ID3 tag and jump it if present.
  if (isMP3File(trackname)) {
    currentTrack.seek(mp3_ID3Jumper(currentTrack));
  }

  // don't let the IRQ get triggered by accident here
  noInterrupts();

  // As explained in datasheet, set twice 0 in REG_DECODETIME to set time back to 0
  sciWrite(VS1053_REG_DECODETIME, 0x00);
  sciWrite(VS1053_REG_DECODETIME, 0x00);

  playingMusic = true;

  // wait till its ready for data
  while (! readyForData() ) {
#if defined(ESP8266)
	yield();
#endif
  }

  // fill it up!
  while (playingMusic && readyForData()) {
    feedBuffer();
  }
  
  // ok going forward, we can use the IRQ
  interrupts();

  return true;
}