Skip to content

Commit 7f27379

Browse files
committed
AudioKit Support and Prepare RP2040
1 parent 3deee1b commit 7f27379

File tree

42 files changed

+2694
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2694
-478
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Using the AI Thinker ESP32 Audio Kit as A2DP Receiver
2+
3+
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress.
4+
5+
<img src="https://pschatzmann.github.io/arduino-audio-tools/resources/audio-toolkit.png" alt="Audio Kit" />
6+
7+
I am using the data callback of the A2DP library to feed the AudioKitStream
8+
9+
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies:
10+
11+
## Dependencies
12+
13+
- https://github.com/pschatzmann/arduino-audio-tools
14+
- https://github.com/pschatzmann/ESP32-A2DP
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#define USE_A2DP
2+
#include "AudioTools.h"
3+
#include "AudioDevices/ESP32AudioKit/AudioKit.h"
4+
5+
BluetoothA2DPSink a2dp_sink;
6+
AudioKitStream kit;
7+
8+
// Write data to AudioKit in callback
9+
void read_data_stream(const uint8_t *data, uint32_t length) {
10+
kit.write(data, length);
11+
}
12+
13+
void setup() {
14+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
15+
16+
// setup output
17+
auto cfg = kit.defaultConfig(TX_MODE);
18+
cfg.default_volume = 50;
19+
kit.begin(cfg);
20+
21+
// register callback
22+
a2dp_sink.set_stream_reader(read_data_stream, false);
23+
a2dp_sink.start("AudioKit");
24+
}
25+
26+
void loop() {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Using the AI Thinker ESP32 Audio Kit as SD Player
2+
3+
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.
4+
5+
<img src="https://pschatzmann.github.io/arduino-audio-tools/resources/audio-toolkit.png" alt="Audio Kit" />
6+
7+
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies:
8+
9+
## Dependencies
10+
11+
- https://github.com/pschatzmann/arduino-audio-tools
12+
- https://github.com/pschatzmann/arduino-libhelix
13+
- https://github.com/greiman/SdFat
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @file player-sd-audiokit.ino
3+
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sd-audiokit/README.md
4+
*
5+
* @author Phil Schatzmann
6+
* @copyright GPLv3
7+
*/
8+
9+
// set this in AudioConfig.h or here after installing https://github.com/pschatzmann/arduino-libhelix.git
10+
#define USE_SDFAT
11+
#define USE_HELIX
12+
#include "AudioTools.h"
13+
#include "AudioDevices/ESP32AudioKit/AudioKit.h"
14+
15+
using namespace audio_tools;
16+
17+
const char *startFilePath="/";
18+
const char* ext="mp3";
19+
int speedMz = 10;
20+
AudioSourceSdFat source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS, speedMz);
21+
AudioKitStream i2s;
22+
MP3DecoderHelix decoder;
23+
AudioPlayer player(source, i2s, decoder);
24+
25+
26+
void setup() {
27+
Serial.begin(115200);
28+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
29+
30+
// setup output
31+
auto cfg = i2s.defaultConfig(TX_MODE);
32+
i2s.begin(cfg);
33+
34+
// setup player
35+
player.begin();
36+
}
37+
38+
void loop() {
39+
player.copy();
40+
}

examples/examples-stream/streams-adc-serial/streams-adc-serial.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ConverterAutoCenter<int16_t> center; // make sure the avg of the signal
2020
void setup(void) {
2121
// Open Serial
2222
Serial.begin(115200);
23+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
2324

2425
AnalogConfig cfg = microphone.defaultConfig(RX_MODE);
2526
microphone.begin(cfg);

examples/examples-stream/streams-ads1015-serial/streams-ads1015-serial.ino

Lines changed: 0 additions & 63 deletions
This file was deleted.

examples/examples-stream/streams-generator-i2s/streams-generator-i2s.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ StreamCopy copier(out, sound); // copies sound into
2222
void setup(void) {
2323
// Open Serial
2424
Serial.begin(115200);
25+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
2526

26-
// start the bluetooth
27+
// start I2S
2728
Serial.println("starting I2S...");
2829
auto config = out.defaultConfig(TX_MODE);
2930
config.sample_rate = sample_rate;
@@ -33,6 +34,7 @@ void setup(void) {
3334

3435
// Setup sine wave
3536
sineWave.begin(channels, sample_rate, N_B4);
37+
Serial.println("started...");
3638
}
3739

3840
// Arduino loop - copy sound to out

examples/examples-stream/streams-generator-serial/streams-generator-serial.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ StreamCopy copier(printer, sound); // copies sound into
2222
void setup(void) {
2323
// Open Serial
2424
Serial.begin(115200);
25+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
2526

2627
// Setup sine wave
2728
sineWave.begin(channels, sample_rate, N_B4);

examples/examples-stream/streams-memory_raw-i2s/streams-memory_raw-i2s.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ StreamCopyT<int16_t> copier(i2s, music); // copies sound into i2s
2323

2424
void setup(){
2525
Serial.begin(115200);
26+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
2627

2728
auto config = i2s.defaultConfig(TX_MODE);
2829
config.sample_rate = sample_rate;

examples/examples-stream/streams-memory_wav-pwm/streams-memory_wav-pwm.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ StreamCopy copier(out, wav); // copy in to out
2525

2626
void setup(){
2727
Serial.begin(115200);
28-
while(!Serial);
2928
AudioLogger::instance().begin(Serial, AudioLogger::Info);
3029

3130
auto config = pwm.defaultConfig();

0 commit comments

Comments
 (0)