snapshot
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
## Using the AI Thinker ESP32 Audio Kit as SD Player
|
||||
|
||||
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress and because I was tired of all the wires I had to connect to implement my different scenarios that are possible with my [Arduino Audio Tools Library](https://github.com/pschatzmann/arduino-audio-tools), I thought it to be a good idea to buy this board.
|
||||
|
||||
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
|
||||
|
||||
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies
|
||||
To access the files we use the SD library.
|
||||
|
||||
### Note
|
||||
|
||||
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
You need to install the following libraries:
|
||||
|
||||
- https://github.com/pschatzmann/arduino-audio-tools
|
||||
- https://github.com/pschatzmann/arduino-libhelix
|
||||
- https://github.com/pschatzmann/arduino-audio-driver
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file player-sd-audiokit.ino
|
||||
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/player-sd-audiokit/README.md
|
||||
* Make sure that the pins are set to off, on, on, off, off
|
||||
* @author Phil Schatzmann
|
||||
* @copyright GPLv3
|
||||
*/
|
||||
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/Disk/AudioSourceSD.h" // or AudioSourceIdxSD.h
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
|
||||
const char *startFilePath="/";
|
||||
const char* ext="mp3";
|
||||
AudioSourceSD source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS);
|
||||
AudioBoardStream kit(AudioKitEs8388V1);
|
||||
MP3DecoderHelix decoder; // or change to MP3DecoderMAD
|
||||
AudioPlayer player(source, kit, decoder);
|
||||
|
||||
void next(bool, int, void*) {
|
||||
player.next();
|
||||
}
|
||||
|
||||
void previous(bool, int, void*) {
|
||||
player.previous();
|
||||
}
|
||||
|
||||
void startStop(bool, int, void*) {
|
||||
player.setActive(!player.isActive());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup output
|
||||
auto cfg = kit.defaultConfig(TX_MODE);
|
||||
// sd_active is setting up SPI with the right SD pins by calling
|
||||
// SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
|
||||
cfg.sd_active = true;
|
||||
kit.begin(cfg);
|
||||
|
||||
// setup additional buttons
|
||||
kit.addDefaultActions();
|
||||
kit.addAction(kit.getKey(1), startStop);
|
||||
kit.addAction(kit.getKey(4), next);
|
||||
kit.addAction(kit.getKey(3), previous);
|
||||
|
||||
|
||||
// setup player
|
||||
player.setVolume(0.7);
|
||||
player.begin();
|
||||
|
||||
// select file with setPath() or setIndex()
|
||||
//player.setPath("/ZZ Top/Unknown Album/Lowrider.mp3");
|
||||
//player.setIndex(1); // 2nd file
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
player.copy();
|
||||
kit.processActions();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user