From 04621cb54e562214a9b6f7576bc3ac258e326c97 Mon Sep 17 00:00:00 2001 From: boblark Date: Wed, 19 Jan 2022 12:21:57 -0800 Subject: [PATCH] Added setFMScale to radioModulatedGenerator_F32 --- radioModulatedGenerator_F32.cpp | 2 +- radioModulatedGenerator_F32.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/radioModulatedGenerator_F32.cpp b/radioModulatedGenerator_F32.cpp index e1cf524..73c5864 100644 --- a/radioModulatedGenerator_F32.cpp +++ b/radioModulatedGenerator_F32.cpp @@ -69,7 +69,7 @@ void radioModulatedGenerator_F32::update(void) { if(doPM) // Phase in inPhaseFreq->data[i] is scaled for (0.0, 2*PI) phaseS += (phaseIncrement0 + K512ON2PI*inPhaseFreq->data[i]); else if(doFM) - phaseS += kp*(freq + inPhaseFreq->data[i]); // kp=512.0/sample_rate_Hz + phaseS += kp*(freq + deviationFMScale*inPhaseFreq->data[i]); // kp=512.0/sample_rate_Hz else phaseS += phaseIncrement0; // No PM or FM alteration to carrier phase diff --git a/radioModulatedGenerator_F32.h b/radioModulatedGenerator_F32.h index c024966..07836cc 100644 --- a/radioModulatedGenerator_F32.h +++ b/radioModulatedGenerator_F32.h @@ -12,7 +12,7 @@ * * For PM or FM (only one at a time) the input goes to the 1 channel. For PM, * the input level corresponds to radians of phase change, + or -. For FM, - * the input correspondss to Hz of deviation. + * the input correspondss to Hz of deviation (or as modified by deviationFMMultiplier). * * For digital modulation, such as QAM, there can be both phase and amplitude * modulation. This would be set by @@ -104,6 +104,13 @@ public: return; } + // A deviationFMScale of 1000.0 causes the deviation in FM to + // * be 1000 Hz/unit instead of 1 Hz/unit. + // */ + void setFMScale(float mult) { + deviationFMScale = mult; + } + // phaseQ_I is the number of radians that the cosine output leads the // sine output. The default is M_PI_2 = pi/2 = 1.57079633 radians, // corresponding to 90.00 degrees cosine leading sine. @@ -159,6 +166,7 @@ public: private: audio_block_f32_t *inputQueueArray_f32[2]; float32_t freq = 10000.0f; // Center frequecy, Hz + float32_t deviationFMScale = 1.0f; // Hz is default, 1000.0 is kHz, not Hz float32_t phaseS = 0.0f; float32_t phaseQ_I = 128.00; float32_t amplitudeQ_I = 1.0f;