From 98a31df28ddac5086c10dadaa7015a49870f4e5f Mon Sep 17 00:00:00 2001 From: probonopd Date: Fri, 18 Apr 2025 22:05:10 +0200 Subject: [PATCH] Prevent PCM510x has a zero-data detect from kicking in (#843) The PCM510x has a zero-data detect function. When the device detects continuous zero data, it enters a full analog mute condition. The PCM510x counts zero data over 1024LRCKs (21ms @ 48kHz) before setting analog mute. This caused audible artifacts. Hence we are generating an inaudibly small signal to prevent the analog mute from kicking in. Thanks @soyersoyer Similar to soyersoyer#5 --- src/minidexed.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 4d9a53c..f49c840 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -1309,6 +1309,15 @@ void CMiniDexed::ProcessSound (void) arm_fill_q15(0, tmp_int, nFrames*Channels); } + // Prevent PCM510x analog mute from kicking in + for (uint8_t tg = 0; tg < Channels; tg++) + { + if (tmp_int[(nFrames - 1) * Channels + tg] == 0) + { + tmp_int[(nFrames - 1) * Channels + tg]++; + } + } + if (m_pSoundDevice->Write (tmp_int, sizeof(tmp_int)) != (int) sizeof(tmp_int)) { LOGERR ("Sound data dropped"); @@ -1394,6 +1403,12 @@ void CMiniDexed::ProcessSound (void) arm_fill_q15(0, tmp_int, nFrames * 2); } + // Prevent PCM510x analog mute from kicking in + if (tmp_int[nFrames * 2 - 1] == 0) + { + tmp_int[nFrames * 2 - 1]++; + } + if (m_pSoundDevice->Write (tmp_int, sizeof(tmp_int)) != (int) sizeof(tmp_int)) { LOGERR ("Sound data dropped");