sgtl5000 autovolume bad cast for var
lfc7 opened this issue · 1 comments
lfc7 commented
Hello, working on sgtl5000 in found that in control_sgtl5000.cpp in function AudioControlSGTL5000::autoVolumeControl some var are 8 bits but registers to write in are 16.
Due to this autovolume (AVC) is not working as well.
uint8_t thresh=(pow(10,threshold/20)*0.636)*pow(2,15);
uint8_t att=(1-pow(10,-(attack/(20*44100))))*pow(2,19);
uint8_t dec=(1-pow(10,-(decay/(20*44100))))*pow(2,23);
write(DAP_AVC_THRESHOLD,thresh);
write(DAP_AVC_ATTACK,att);
write(DAP_AVC_DECAY,dec);
should be
uint16_t thresh=(pow(10,threshold/20)*0.636)*pow(2,15);
uint16_t att=(1-pow(10,-(attack/(20*44100))))*pow(2,19);
uint16_t dec=(1-pow(10,-(decay/(20*44100))))*pow(2,23);
write(DAP_AVC_THRESHOLD,thresh);
write(DAP_AVC_ATTACK,att);
write(DAP_AVC_DECAY,dec);
as DAP_AVC_THRESHOLD is a full 16bits register and in DAP_AVC_THRESHOLD & DAP_AVC_DECAY levels are coded on 12bits.
--
oliv