From 345c087fc28ecbcd2a9d43ac0c51f25d1bbb05b0 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sun, 3 Aug 2025 20:34:16 +0200 Subject: [PATCH] small optimazations --- README.md | 7 +------ filter/bs412.c | 4 ++-- filter/bs412.h | 6 +++--- filter/gain_control.c | 2 +- filter/gain_control.h | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1323d0d..6e9ac0d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ Supports these inputs: - Audio (via Pulse) - MPX (via Pulse, basically passthrough, i don't recommend this unless you have something else than rds or sca to modulate, you could run chimer95 via here) - RDS (via Pulse, expects unmodulated RDS, rds95 is recommended here, in modulation this is quadrature to the pilot, number of channels is specified by the argument, each of the channels (max 4) go on these freqs: 57, 66.5, 71.25, 76) -- SCA (via Pulse, by default on 67 khz with a 7 khz deviation) and one output: @@ -41,11 +40,7 @@ Should run completly fine on a pi 5, fine on a pi 3b (30% cpu, 45% with lpf) ## Other Apps -FM95 also includes some other apps, such as chimer95 which generates GTS tones each half hour, and dcf95 which creates a DCF77 compatible signal, and vban95 now which is a buffered VBAN receiver - -## FM95 Calibration - -FM95 features a calibration mode `-V` which instead of outputing the MPX just outputs a 400 hz tone, use that tone to match the deviation on your transmitter +FM95 also includes some other apps, such as chimer95 which generates GTS tones each half hour, and dcf95 which creates a DCF77 compatible signal, and vban95 now which is a buffered VBAN receiver. And now also SCA generation was moved to sca95 from fm95! ## Usage of other projects diff --git a/filter/bs412.c b/filter/bs412.c index 6e3ac60..5fe378e 100644 --- a/filter/bs412.c +++ b/filter/bs412.c @@ -11,7 +11,7 @@ inline float deviation_to_dbr(float deviation) { return 10.0f * (log2f(deviation) - LOG2_19000) * 0.30103f; } -void init_bs412(BS412Compressor* mpx, float mpx_deviation, float target_power, float attack, float release, float max, int sample_rate) { +void init_bs412(BS412Compressor* mpx, uint32_t mpx_deviation, float target_power, float attack, float release, float max, uint32_t sample_rate) { mpx->mpx_deviation = mpx_deviation; mpx->average_counter = 0; mpx->average = 0; @@ -26,7 +26,7 @@ void init_bs412(BS412Compressor* mpx, float mpx_deviation, float target_power, f #endif } -float soft_clip_tanh(float sample, float threshold) { +inline float soft_clip_tanh(float sample, float threshold) { if (fabsf(sample) <= threshold) { return sample; // Linear region } diff --git a/filter/bs412.h b/filter/bs412.h index ec606b6..cfb0bbb 100644 --- a/filter/bs412.h +++ b/filter/bs412.h @@ -13,8 +13,8 @@ typedef struct { - int mpx_deviation; - int average_counter; + uint32_t mpx_deviation; + uint32_t average_counter; uint32_t sample_rate; float target; float attack; @@ -27,5 +27,5 @@ typedef struct float dbr_to_deviation(float dbr); float deviation_to_dbr(float deviation); -void init_bs412(BS412Compressor *mpx, float mpx_deviation, float target_power, float attack, float release, float max, int sample_rate); +void init_bs412(BS412Compressor *mpx, uint32_t mpx_deviation, float target_power, float attack, float release, float max, uint32_t sample_rate); float bs412_compress(BS412Compressor *mpx, float average); \ No newline at end of file diff --git a/filter/gain_control.c b/filter/gain_control.c index a3e4022..8596456 100644 --- a/filter/gain_control.c +++ b/filter/gain_control.c @@ -1,6 +1,6 @@ #include "gain_control.h" -void initAGC(AGC* agc, int sampleRate, float targetLevel, float minGain, float maxGain, float attackTime, float releaseTime) { +void initAGC(AGC* agc, uint32_t sampleRate, float targetLevel, float minGain, float maxGain, float attackTime, float releaseTime) { agc->targetLevel = targetLevel; agc->minGain = minGain; agc->maxGain = maxGain; diff --git a/filter/gain_control.h b/filter/gain_control.h index 5d3b5cc..09b9b2c 100644 --- a/filter/gain_control.h +++ b/filter/gain_control.h @@ -21,5 +21,5 @@ typedef struct { float rmsBeta; } AGC; -void initAGC(AGC* agc, int sampleRate, float targetLevel, float minGain, float maxGain, float attackTime, float releaseTime); +void initAGC(AGC* agc, uint32_t sampleRate, float targetLevel, float minGain, float maxGain, float attackTime, float releaseTime); float process_agc(AGC* agc, float sidechain); \ No newline at end of file