-
-
Notifications
You must be signed in to change notification settings - Fork 327
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
Problem Description
Volume changes are received by the device, but the actual volume doesn't change until the music is paused then played. It doesn't update the volume during streaming.
Based on serial logs, the set_volume inside A2DPVolumeControl doesn't fire when music is playing. Only when you pause the song, will "set_volume" function be fired.
Device Description
ESP32 Wroom https://www.amazon.com/gp/product/B0C7C2HQ7P/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
Sketch
#include "BluetoothA2DPSink.h"
#include "./data/mrhemVolumeControl.h"
BluetoothA2DPSink a2dp_sink;
A2DPMrhemVolumeControl mrhemVolumeControl;
void setup() {
Serial.begin(9600);
int mclkPin=3;
i2s_pin_config_t external_pin_config = {
.mck_io_num = mclkPin,
.bck_io_num =33,
.ws_io_num = 32,
.data_out_num = 22,
.data_in_num = I2S_PIN_NO_CHANGE,
};
static const i2s_config_t externalDAC_config = {
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX),
.sample_rate = 44100, // corrected by info from bluetooth
.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_STAND_MSB,
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = true,
.tx_desc_auto_clear = true, // avoiding noise in case of data unavailability
.mclk_multiple=(i2s_mclk_multiple_t) 256,
};
a2dp_sink.set_volume_control(&mrhemVolumeControl);
a2dp_sink.set_avrc_metadata_callback(avrc_metadata_callback);
bool externalDAC=true;
a2dp_sink.set_pin_config(external_pin_config);
a2dp_sink.set_i2s_config(externalDAC_config);
a2dp_sink.i2s_mclk_pin_select(mclkPin);
a2dp_sink.start("mrhemMusicBasic");
}
./data/mrhemVolumeControl.h:
#include "BluetoothA2DPSink.h"
#include "SoundData.h"
#include "esp_log.h"
class A2DPMrhemVolumeControl : public A2DPVolumeControl {
public: A2DPMrhemVolumeControl() {
volumeFactorMax = 4096;
}
virtual void set_volume(uint8_t volume) override {
constexpr double base = 1.4;
constexpr double bits = 12;
constexpr double zero_ofs = pow(base, -bits);
constexpr double scale = pow(2.0, bits);
double volumeFactorFloat = (pow(base, volume * bits / 127.0 - bits) - zero_ofs) * scale / (1.0 - zero_ofs);
volumeFactor = volumeFactorFloat;
if (volumeFactor > 0x1000) {
volumeFactor = 0x1000;
}
Serial.print("mrhem default Volume is now");
Serial.println(volumeFactor);
}
};
Other Steps to Reproduce
I monitored the serial output in the Arduino IDE's Serial Monitor. I press the volume change buttons on the iphone, but "mrhem default Volume is now" does not output. It only outputs much later with the newest value when I pause the stream.
Provide your Version of the EP32 Arduino Core (or the IDF Version)
esp32 by Espressif: 2.0.11
I have checked existing issues, discussions and online documentation
- I confirm I have checked existing issues, discussions and online documentation
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed