SomeoneFromGermany
Well-known member
Hello,
I want to use an ESP32 as an bluetooth audio reciver.
I found this https://github.com/dvxlab/esp32_bt_music_receiver library which is easy to use and can strem audio directly to the ESP32's I2S connection.
In theorie it should work, but it didn't.
The reason is that the ESP32 sends data not synced to the clock.
The BCLK from the teensy is at 2.8 MHz, but it should be (44.1kHz * 16 * 2) 1.41 MHz.
How can I fix this issue?
Teensys code:
ESP32's code
The I2S config
I want to use an ESP32 as an bluetooth audio reciver.
I found this https://github.com/dvxlab/esp32_bt_music_receiver library which is easy to use and can strem audio directly to the ESP32's I2S connection.
In theorie it should work, but it didn't.
The reason is that the ESP32 sends data not synced to the clock.
The BCLK from the teensy is at 2.8 MHz, but it should be (44.1kHz * 16 * 2) 1.41 MHz.
How can I fix this issue?
Teensys code:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=246,239.00000190734863
AudioOutputAnalogStereo dacs1; //xy=369.00000381469727,239.00000381469727
AudioConnection patchCord1(i2s1, 0, dacs1, 0);
AudioConnection patchCord2(i2s1, 1, dacs1, 1);
// GUItool: end automatically generated code
void setup() {
AudioMemory(20);
}
void loop() {
}
ESP32's code
Code:
#include <arduino.h>
#include "esp32_bt_music_receiver.h"
BlootoothA2DSink a2d_sink;
void setup() {
a2d_sink.start("MyMusic");
Serial.begin(115200);
}
unsigned long last = 0;
void loop() {
if ((millis() - last) > 100) {
last = millis();
Serial.println(a2d_sink.get_audio_state());
}
}
The I2S config
Code:
i2s_config = {
.mode = (i2s_mode_t) (I2S_MODE_SLAVE | I2S_MODE_TX),
.sample_rate = 44100,
.bits_per_sample = (i2s_bits_per_sample_t)16,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = false
};
Last edited: