From 6b467168601393b2dc423afaed65aeaa7743877b Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Tue, 5 Aug 2025 13:21:40 +0200 Subject: [PATCH] remove polar stereo fix --- .vscode/.server-controller-port.log | 2 +- modulation/stereo_encoder.c | 13 ++++--------- modulation/stereo_encoder.h | 3 +-- src/fm95.c | 8 ++++---- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.vscode/.server-controller-port.log b/.vscode/.server-controller-port.log index e58d1f2..3f3b590 100644 --- a/.vscode/.server-controller-port.log +++ b/.vscode/.server-controller-port.log @@ -1,5 +1,5 @@ { "port": 13452, - "time": 1754309288735, + "time": 1754390686374, "version": "0.0.3" } \ No newline at end of file diff --git a/modulation/stereo_encoder.c b/modulation/stereo_encoder.c index 7a6802f..71f8637 100644 --- a/modulation/stereo_encoder.c +++ b/modulation/stereo_encoder.c @@ -1,10 +1,9 @@ #include "stereo_encoder.h" -// Multiplier is the multiplier to get to 19 khz, or 31.25 if polar -void init_stereo_encoder(StereoEncoder* st, uint8_t multiplier, Oscillator* osc, uint8_t polar, float mono_volume, float pilot_volume, float stereo_volume) { +// Multiplier is the multiplier to get to 19 khz +void init_stereo_encoder(StereoEncoder* st, uint8_t multiplier, Oscillator* osc, float mono_volume, float pilot_volume, float stereo_volume) { st->multiplier = multiplier; st->osc = osc; - st->polar = polar; st->mono_volume = mono_volume; st->pilot_volume = pilot_volume; st->stereo_volume = stereo_volume; @@ -17,11 +16,7 @@ float stereo_encode(StereoEncoder* st, uint8_t enabled, float left, float right) float side = (left-right) * 0.5f; float signalx1 = get_oscillator_sin_multiplier_ni(st->osc, st->multiplier); + float signalx2 = get_oscillator_sin_multiplier_ni(st->osc, st->multiplier * 2.0f); - if(!st->polar) { - float signalx2 = get_oscillator_sin_multiplier_ni(st->osc, st->multiplier * 2.0f); - return (mid*st->mono_volume) + (signalx1*st->pilot_volume) + ((side*signalx2) * st->stereo_volume); - } else { - return (mid*st->mono_volume) + (((side+0.2f)*signalx1) * st->stereo_volume); // Polar stereo does not contain a pilot, but it contains a -14 db carrier wave on the stereo subcarrier - } + return (mid*st->mono_volume) + (signalx1*st->pilot_volume) + ((side*signalx2) * st->stereo_volume); } \ No newline at end of file diff --git a/modulation/stereo_encoder.h b/modulation/stereo_encoder.h index 53a29dd..58e4307 100644 --- a/modulation/stereo_encoder.h +++ b/modulation/stereo_encoder.h @@ -7,12 +7,11 @@ typedef struct { uint8_t multiplier; Oscillator* osc; - uint8_t polar; float mono_volume; float pilot_volume; float stereo_volume; } StereoEncoder; -void init_stereo_encoder(StereoEncoder *st, uint8_t multiplier, Oscillator *osc, uint8_t polar, float mono_volume, float pilot_volume, float stereo_volume); +void init_stereo_encoder(StereoEncoder *st, uint8_t multiplier, Oscillator *osc, float mono_volume, float pilot_volume, float stereo_volume); float stereo_encode(StereoEncoder* st, uint8_t enabled, float left, float right); diff --git a/src/fm95.c b/src/fm95.c index e2f4188..3ae1c86 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -40,7 +40,7 @@ typedef struct typedef struct { FM95_Volumes volumes; - uint8_t stereo; + bool stereo; uint8_t rds_streams; @@ -222,7 +222,7 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) { mpx = stereo_encode(&runtime->stencode, config.stereo, l, r); - if(rds_on && config.stereo != 2) { // disable rds on polar stereo + if(rds_on) { float rds_level = config.volumes.rds; for(uint8_t stream = 0; stream < config.rds_streams; stream++) { uint8_t osc_stream = 12 + stream; @@ -437,7 +437,7 @@ void init_runtime(FM95_Runtime* runtime, FM95_Config config, bool rds_on) { init_oscillator(&runtime->osc, (config.calibration == 2) ? 60 : 400, config.sample_rate); return; } - else init_oscillator(&runtime->osc, (config.stereo == 2) ? 7812.5 : 4750, config.sample_rate); + else init_oscillator(&runtime->osc, 4750, config.sample_rate); if(config.lpf_cutoff != 0) { runtime->lpf_l = iirfilt_rrrf_create_prototype(LIQUID_IIRDES_CHEBY2, LIQUID_IIRDES_LOWPASS, LIQUID_IIRDES_SOS, config.lpf_order, (config.lpf_cutoff/config.sample_rate), 0.0f, 1.0f, 60.0f); @@ -456,7 +456,7 @@ void init_runtime(FM95_Runtime* runtime, FM95_Config config, bool rds_on) { if(config.tilt != 0) tilt_init(&runtime->tilter, (float)config.tilt / 127.0f); - init_stereo_encoder(&runtime->stencode, 4.0f, &runtime->osc, (config.stereo == 2), config.volumes.mono, config.volumes.pilot, config.volumes.stereo); + init_stereo_encoder(&runtime->stencode, 4.0f, &runtime->osc, config.volumes.mono, config.volumes.pilot, config.volumes.stereo); if(config.agc_max != 0.0) { last_gain = 1.0f;