ESP8266Audio
ESP8266Audio copied to clipboard
Integration with external libraries
Hi! I've tried to request a Bluetooth outbput feature, but didn't get any response. I clearly understabd that you have lot of work and don't ask you to do it for me. But I would be thankful if you give me a piece of advice.
I've found a solution on how to send data to bluetooth speaker from esp32. Here's my sample program. Can you please advice me how to pack it as AudioOutputBluetooth for your library?
As soon as I will manage doing it I'll make you a pull request. Thanks in advice for yout answer.
#include "BluetoothA2DPSource.h"
BluetoothA2DPSource a2dp_source;
#include "BluetoothA2DPSource.h"
#include <math.h>
#define c3_frequency 230.81
int i=0;
double getMusicData(){
double m_amplitude = 10000.0;
i++;
if (i>2990) i=0;
return m_amplitude * i;
}
int32_t get_data_channels(Frame *frame, int32_t channel_len) {
// из этой функции библиотека запрашивает данные на channel_len тактов вперед
for (int sample = 0; sample < channel_len; ++sample) {
frame[sample].channel1 = getMusicData();
frame[sample].channel2 = frame[sample].channel1;
}
return channel_len;
}
void setup() {
a2dp_source.start("JBL TUNE750BTNC", get_data_channels);
Serial.println("connected");
a2dp_source.set_volume(20);
}
void loop() {
delay(10);
}
P.S. code is using https://github.com/pschatzmann/ESP32-A2DP