diff --git a/plugins/channeltx/modam/ammod.cpp b/plugins/channeltx/modam/ammod.cpp index 17f91e48b..3dc498c58 100644 --- a/plugins/channeltx/modam/ammod.cpp +++ b/plugins/channeltx/modam/ammod.cpp @@ -65,13 +65,16 @@ void AMMod::pull(Sample& sample) { Complex ci; - if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, m_modSample, &ci)) - { - Real t = m_toneNco.next(); - m_modSample.real(((t+1.0f) * m_running.m_modFactor * 16384.0f)); // modulate and scale zero frequency carrier - m_modSample.imag(0.0f); - m_interpolatorDistanceRemain += m_interpolatorDistance; - } + m_interpolator.interpolate(&m_interpolatorDistanceRemain, m_modSample, &m_interpolatorConsumed, &ci); + m_interpolatorDistanceRemain += m_interpolatorDistance; + + if (m_interpolatorConsumed) + { + Real t = m_toneNco.next(); + m_modSample.real(((t+1.0f) * m_running.m_modFactor * 16384.0f)); // modulate and scale zero frequency carrier + m_modSample.imag(0.0f); + m_interpolatorConsumed = false; + } ci *= m_carrierNco.nextIQ(); // shift to carrier frequency @@ -157,7 +160,8 @@ void AMMod::apply() m_settingsMutex.lock(); m_interpolator.create(16, m_config.m_outputSampleRate, m_config.m_rfBandwidth / 2.2); m_interpolatorDistanceRemain = 0; - m_interpolatorDistance = (Real) m_config.m_outputSampleRate / (Real) m_config.m_audioSampleRate; + m_interpolatorConsumed = false; + m_interpolatorDistance = (Real) m_config.m_audioSampleRate / (Real) m_config.m_outputSampleRate; m_settingsMutex.unlock(); } diff --git a/plugins/channeltx/modam/ammod.h b/plugins/channeltx/modam/ammod.h index c0c868ec9..e5625035a 100644 --- a/plugins/channeltx/modam/ammod.h +++ b/plugins/channeltx/modam/ammod.h @@ -114,6 +114,7 @@ private: Interpolator m_interpolator; Real m_interpolatorDistance; Real m_interpolatorDistanceRemain; + bool m_interpolatorConsumed; Lowpass m_lowpass; Real m_magsq;