Skip to content

Commit

Permalink
FLAC SD example
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Jun 17, 2024
1 parent 58714de commit 14c24a7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @file streams-sd-audiokit.ino
* @author Phil Schatzmann
* @brief Just a small demo, how to use files with the SD library with a streaming decoder
* @version 0.1
* @date 2022-10-09
*
* @copyright Copyright (c) 2022
*
*/
#include <SPI.h>
#include <SD.h>
#include "AudioTools.h"
#include "AudioLibs/AudioBoardStream.h"
#include "AudioCodecs/CodecFLAC.h"


const int chipSelect=PIN_AUDIO_KIT_SD_CARD_CS;
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
FLACDecoder dec;
StreamCopy copier;
File audioFile;

void setup(){
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);

// setup audiokit before SD!
auto config = i2s.defaultConfig(TX_MODE);
config.sd_active = true;
i2s.begin(config);

// setup file
SD.begin(chipSelect);
audioFile = SD.open("/flac/test2.flac");

// setup decoder
dec.setInputStream(audioFile);
dec.setOutputStream(i2s);
dec.begin();

}

void loop(){
dec.copy();
}

0 comments on commit 14c24a7

Please sign in to comment.