diff --git a/libraries/PDM/src/STM32H747_dfsdm/audio.c b/libraries/PDM/src/STM32H747_dfsdm/audio.c index ab8d6e902..23c4cacb1 100644 --- a/libraries/PDM/src/STM32H747_dfsdm/audio.c +++ b/libraries/PDM/src/STM32H747_dfsdm/audio.c @@ -391,7 +391,10 @@ int py_audio_init(size_t channels, uint32_t frequency) void py_audio_gain_set(int gain_db) { - attenuation = 8 - gain_db; + attenuation = 8 - (gain_db / 3); + if (attenuation < 0) { + attenuation = 0; + } } void py_audio_deinit()