-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0e27a0
commit 84d17f4
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
examples/examples-stream/streams-sdmmc_wav-audiokit/streams-sdmmc_wav-audiokit.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @file streams-sdmmc_wav-audiokit.ino | ||
* @author Phil Schatzmann | ||
* @brief A simple example that shows how to play (eg. a 24bit) wav file | ||
* @date 2021-11-07 | ||
* | ||
* @copyright Copyright (c) 2021 | ||
*/ | ||
|
||
|
||
#include "FS.h" | ||
#include "SD_MMC.h" | ||
#include "AudioTools.h" | ||
#include "AudioLibs/AudioKit.h" | ||
|
||
AudioKitStream i2s; | ||
WAVDecoder wav; | ||
EncodedAudioStream encoded(&i2s, &wav); // Decoding stream | ||
File audioFile; | ||
StreamCopy copier(encoded, audioFile); | ||
|
||
void setup(){ | ||
Serial.begin(115200); | ||
AudioLogger::instance().begin(Serial, AudioLogger::Warning); | ||
|
||
// setup audiokit before SD! | ||
auto config = i2s.defaultConfig(TX_MODE); | ||
config.sd_active = false; | ||
i2s.begin(config); | ||
i2s.setVolume(1.0); | ||
|
||
// open sdmmc | ||
if (!SD_MMC.begin("/sdcard", false)){ | ||
Serial.println("SD_MMC Error"); | ||
stop(); | ||
} | ||
// open file | ||
audioFile = SD_MMC.open("/wav24/test.wav"); | ||
if (!audioFile){ | ||
Serial.println("File does not exist"); | ||
stop(); | ||
} | ||
|
||
// start decoder stream | ||
encoded.begin(); | ||
} | ||
|
||
void loop(){ | ||
copier.copy(); | ||
} |