mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-12-04 19:45:02 +01:00
Fix FM audio noise floor, TX gain, and sample wrapping
The 300-2700 Hz bandpass rounded to integer counts after each stage. Stage 1 is -14 dB and stage 2 is +13.6 dB, which left a broadband floor of about 7 counts RMS and a signal-dependent DC offset. It is now one CFMBandpass class that carries 12 fractional bits between stages, uses an int64 accumulate, and rounds once at the output. RF and ext-audio paths both use it. The ext-audio upsampler now multiplies by 3 to restore the 1/3 lost to zero stuffing. The RF/ext audio boost multiplies now saturate instead of wrapping, and the DAC write clamps to 0..4095 rather than only counting overflow. Deploy with ExtAudioBoost=1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e8061763bf
commit
7c736e17ef
@@ -622,16 +622,21 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
||||
for (uint16_t i = 0U; i < length; i++) {
|
||||
q31_t res1 = samples[i] * txLevel;
|
||||
q15_t res2 = q15_t(__SSAT((res1 >> 15), 16));
|
||||
uint16_t res3 = uint16_t(res2 + m_txDCOffset);
|
||||
int32_t res3 = int32_t(res2) + m_txDCOffset;
|
||||
|
||||
// Detect DAC overflow
|
||||
if (res3 > 4095U)
|
||||
// Detect and clamp DAC overflow
|
||||
if (res3 > 4095) {
|
||||
m_dacOverflow++;
|
||||
res3 = 4095;
|
||||
} else if (res3 < 0) {
|
||||
m_dacOverflow++;
|
||||
res3 = 0;
|
||||
}
|
||||
|
||||
if (control == NULL)
|
||||
m_txBuffer.put({res3, MARK_NONE});
|
||||
m_txBuffer.put({uint16_t(res3), MARK_NONE});
|
||||
else
|
||||
m_txBuffer.put({res3, control[i]});
|
||||
m_txBuffer.put({uint16_t(res3), control[i]});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user