0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00

remove polar stereo

fix
This commit is contained in:
2025-08-05 13:21:40 +02:00
parent 12e54f44e2
commit 6b46716860
4 changed files with 10 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
{
"port": 13452,
"time": 1754309288735,
"time": 1754390686374,
"version": "0.0.3"
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;