From 5a534aca370dd4b4c7b3e07c02a68ff70bbb2988 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sun, 3 Aug 2025 21:11:59 +0200 Subject: [PATCH] add reload warnings and run clock at 1187.5 khz instead of 4750 --- .vscode/.server-controller-port.log | 2 +- src/fm95.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.vscode/.server-controller-port.log b/.vscode/.server-controller-port.log index 9eb6188..87558b2 100644 --- a/.vscode/.server-controller-port.log +++ b/.vscode/.server-controller-port.log @@ -1,5 +1,5 @@ { "port": 13452, - "time": 1754228131242, + "time": 1754247434245, "version": "0.0.3" } \ No newline at end of file diff --git a/src/fm95.c b/src/fm95.c index 704d784..33937d8 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -98,6 +98,13 @@ typedef struct { FM95_DeviceNames* devices; } FM95_SetupContext; +bool compare_dvs(const FM95_DeviceNames *a, const FM95_DeviceNames *b) { + return strcmp(a->input, b->input) == 0 && + strcmp(a->output, b->output) == 0 && + strcmp(a->mpx, b->mpx) == 0 && + strcmp(a->rds, b->rds) == 0; +} + static void stop(int signum) { (void)signum; printf("\nReceived stop signal.\n"); @@ -219,8 +226,8 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) { if(rds_on && config.stereo != 2) { // disable rds on polar stereo float rds_level = config.volumes.rds; for(uint8_t stream = 0; stream < config.rds_streams; stream++) { - uint8_t osc_stream = 12 + stream; - if(osc_stream == 13) osc_stream++; + uint8_t osc_stream = 48 + (stream*4); + if(osc_stream >= 52) osc_stream += 4; mpx += (runtime->rds_in[config.rds_streams * i + stream] * get_oscillator_cos_multiplier_ni(&runtime->osc, osc_stream)) * rds_level; @@ -431,7 +438,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, (config.stereo == 2) ? 1953.125 : 1187.5, 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); @@ -450,7 +457,7 @@ void init_runtime(FM95_Runtime* runtime, FM95_Config config, bool rds_on) { if(config.tilt != 0) tilt_init(&runtime->tilter, config.tilt); - 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, 16.0f, &runtime->osc, (config.stereo == 2), config.volumes.mono, config.volumes.pilot, config.volumes.stereo); if(config.agc_max != 0.0) { last_gain = 1.0f; @@ -511,6 +518,7 @@ int main(int argc, char **argv) { .mpx = "\0", .rds = "\0" }; + FM95_DeviceNames old_dv_names = dv_names; int err; err = parse_arguments(argc, argv, &config); @@ -560,6 +568,9 @@ int main(int argc, char **argv) { printf("Could not parse the config file. (error code as return code)\n"); return err; } + if(!compare_dvs(&dv_names, &old_dv_names)) printf("Warning! Audio Device name changes are not reloaded, please restart for that to take effect.\n"); + old_dv_names = dv_names; + if(config.rds_streams != old_streams) printf("Warning! change of rds_streams requires a restart, not a reload.\n"); config.rds_streams = old_streams; cleanup_runtime(&runtime, config); init_runtime(&runtime, config, rds_on);