@@ -361,20 +361,22 @@ class AudioDriverAD1938Class : public AudioDriver {
361
361
bool end (void ) override { return ad1938.end (); }
362
362
bool setMute (bool mute) override { return ad1938.setMute (mute); }
363
363
// mutes an individual DAC: valid range (0:3)
364
- bool setMute (bool mute, int line) {
365
- if (line > 3 ) return false ;
366
- return ad1938.setVolumeDAC (line, mute ? 0.0 : (static_cast <float >(volumes[line]) / 100 .0f ));
364
+ bool setMute (bool mute, int line) {
365
+ if (line > 3 ) return false ;
366
+ return ad1938.setVolumeDAC (
367
+ line, mute ? 0.0 : (static_cast <float >(volumes[line]) / 100 .0f ));
367
368
}
368
369
369
370
// / Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
370
371
bool setVolume (int volume) override {
371
372
this ->volume = volume;
372
- for (int j= 0 ;j< 8 ; j++){
373
+ for (int j = 0 ; j < 8 ; j++) {
373
374
volumes[j] = volume;
374
375
}
375
376
return ad1938.setVolume (static_cast <float >(volume) / 100 .0f );
376
377
}
377
- // / Defines the Volume per DAC (in %) if volume is 0, mute is enabled,range is 0-100.
378
+ // / Defines the Volume per DAC (in %) if volume is 0, mute is enabled,range is
379
+ // / 0-100.
378
380
bool setVolume (int volume, int line) {
379
381
if (line > 7 ) return false ;
380
382
volumes[line] = volume;
@@ -783,7 +785,7 @@ class AudioDriverES8388Class : public AudioDriver {
783
785
bool setMute (bool mute) {
784
786
line_active[0 ] = !mute;
785
787
line_active[1 ] = !mute;
786
- return es8388_set_voice_mute (mute) == RESULT_OK;
788
+ return es8388_set_voice_mute (mute) == RESULT_OK;
787
789
}
788
790
// mute individual line: lines start at 0 (valid range 0:1)
789
791
bool setMute (bool mute, int line) {
@@ -815,8 +817,13 @@ class AudioDriverES8388Class : public AudioDriver {
815
817
}
816
818
817
819
bool setInputVolume (int volume) {
818
- // map values from 0 - 100 to 0 to 10
819
- es_mic_gain_t gain = (es_mic_gain_t )(limitValue (volume) / 10 );
820
+ // map values from 0 - 100 to 0 to 9 MIC_GAIN_MIN = -1,
821
+ es_mic_gain_t gains[] = {MIC_GAIN_0DB, MIC_GAIN_3DB, MIC_GAIN_6DB,
822
+ MIC_GAIN_9DB, MIC_GAIN_12DB, MIC_GAIN_15DB,
823
+ MIC_GAIN_18DB, MIC_GAIN_21DB, MIC_GAIN_24DB,
824
+ MIC_GAIN_MAX};
825
+ int idx = limitValue (volume / 10 , 9 );
826
+ es_mic_gain_t gain = gains[idx];
820
827
AD_LOGD (" input volume: %d -> gain %d" , volume, gain);
821
828
return setMicrophoneGain (gain);
822
829
}
0 commit comments