pschatzmann / arduino-audiokit

Arduino ADF/Audiokit HAL (support for ESP32-A1S, AI-Thinker, LyraT for ES7148, ES7210, ES7243, ES8311, ES8347, ES8388, TAS5805M, AC101 audio chips)
GNU General Public License v3.0
153 stars 40 forks source link

The AI Thinker AudioKit A202 has a low max volume on speakers #45

Closed refob closed 1 year ago

refob commented 1 year ago

I recently bought a ESP32 Audio KIt 2.2 A202 and used it with the basic-a2dp-audiokit example. I found that the max volume on the speakers was too low. The suggested workaround using "AI_THINKER_ES8388_VOLUME_HACK 1" did not change anything for me.

The following code change in es8388.c worked for me using bluetooth from a Samsung S20 phone:

esp_err_t es8388_set_voice_volume(int volume) { KIT_LOGD("es8388_set_voice_volume: %d", volume); esp_err_t res = ESP_OK; if (volume < 0) volume = 0; else if (volume > 100) volume = 100; //volume /= 3;; volume = (volume*63)/100; // dataheet says only 6 bits res = es_write_reg(ES8388_ADDR, ES8388_DACCONTROL24, volume); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL25, volume); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL26, 0); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL27, 0); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL8, 192 >> 2); res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL9, 192 >> 2); return res; }

I found that I could use one more bit for the volume (7 instead of 6 bits documented in the datasheet). I also used ES8388_DACCONTROL8/9 to pump up the volume even a bit more.

Best regards,

Reinhard

pschatzmann commented 1 year ago

You can configure this option now by setting AI_THINKER_ES8388_VOLUME_HACK to 2