bmillier
Well-known member
Teensyduino vers: 1.29
The SGTL5000 AutoVolumeControl function does not work as described. There are 3 incorrect lines in the code which result in the Threshold (16-bit), Attack(12-bit) and Decay(12-bit) registers of the SCTL5000 being loaded incorrectly.
In the file "control_sgtl5000.cpp" the following 3 lines
Line#
844 uint8_t thresh = (pow(10, threshold / 20)*0.636)*pow(2, 15);
845 uint8_t att=(1-pow(10,-(attack/(20*44100))))*pow(2,19);
846 uint8_t dec=(1-pow(10,-(decay/(20*44100))))*pow(2,23);
should be replaced with
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);
This loads the registers with the proper 16, 12-bit values, and when I tested it out on the Audioshield, the AVC now works properly.
The SGTL5000 AutoVolumeControl function does not work as described. There are 3 incorrect lines in the code which result in the Threshold (16-bit), Attack(12-bit) and Decay(12-bit) registers of the SCTL5000 being loaded incorrectly.
In the file "control_sgtl5000.cpp" the following 3 lines
Line#
844 uint8_t thresh = (pow(10, threshold / 20)*0.636)*pow(2, 15);
845 uint8_t att=(1-pow(10,-(attack/(20*44100))))*pow(2,19);
846 uint8_t dec=(1-pow(10,-(decay/(20*44100))))*pow(2,23);
should be replaced with
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);
This loads the registers with the proper 16, 12-bit values, and when I tested it out on the Audioshield, the AVC now works properly.