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

add a audio preamp value to fm95

This commit is contained in:
2025-07-06 21:59:15 +02:00
parent 1bdb7bb35b
commit f9465cd1f5
2 changed files with 8 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
{ {
"port": 13452, "port": 13452,
"time": 1751186600809, "time": 1751831842961,
"version": "0.0.3" "version": "0.0.3"
} }

View File

@@ -36,6 +36,7 @@
#define DEFAULT_MASTER_VOLUME 1.0f // Volume of everything combined, for calibration #define DEFAULT_MASTER_VOLUME 1.0f // Volume of everything combined, for calibration
#define DEFAULT_AUDIO_VOLUME 1.0f // Audio volume, before clipper #define DEFAULT_AUDIO_VOLUME 1.0f // Audio volume, before clipper
#define DEFAULT_AUDIO_PREAMP 1.0f // Audio volume, but before all the filters
#define MONO_VOLUME 0.45f // 45% #define MONO_VOLUME 0.45f // 45%
#define PILOT_VOLUME 0.09f // 9% #define PILOT_VOLUME 0.09f // 9%
@@ -60,6 +61,7 @@ typedef struct
float mpx_deviation; float mpx_deviation;
float master_volume; float master_volume;
float audio_volume; float audio_volume;
float audio_preamp;
uint32_t sample_rate; uint32_t sample_rate;
@@ -199,8 +201,8 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) {
for (uint16_t i = 0; i < BUFFER_SIZE; i++) { for (uint16_t i = 0; i < BUFFER_SIZE; i++) {
float mpx = 0.0f; float mpx = 0.0f;
float ready_l = apply_preemphasis(&preemp_l, audio_stereo_input[2*i+0]); float ready_l = apply_preemphasis(&preemp_l, audio_stereo_input[2*i+0]*config.audio_preamp);
float ready_r = apply_preemphasis(&preemp_r, audio_stereo_input[2*i+1]); float ready_r = apply_preemphasis(&preemp_r, audio_stereo_input[2*i+1]*config.audio_preamp);
iirfilt_rrrf_execute(lpf_l, ready_l, &ready_l); iirfilt_rrrf_execute(lpf_l, ready_l, &ready_l);
iirfilt_rrrf_execute(lpf_r, ready_r, &ready_r); iirfilt_rrrf_execute(lpf_r, ready_r, &ready_r);
@@ -320,6 +322,8 @@ static int config_handler(void* user, const char* section, const char* name, con
pconfig->master_volume = strtof(value, NULL); pconfig->master_volume = strtof(value, NULL);
} else if (MATCH("fm95", "audio_volume")) { } else if (MATCH("fm95", "audio_volume")) {
pconfig->audio_volume = strtof(value, NULL); pconfig->audio_volume = strtof(value, NULL);
} else if (MATCH("fm95", "audio_preamp")) {
pconfig->audio_preamp = strtof(value, NULL);
} else if (MATCH("fm95", "deviation")) { } else if (MATCH("fm95", "deviation")) {
pconfig->master_volume *= (strtof(value, NULL) / 75000.0f); pconfig->master_volume *= (strtof(value, NULL) / 75000.0f);
} else if(MATCH("advanced", "lpf_order")) { } else if(MATCH("advanced", "lpf_order")) {
@@ -427,6 +431,7 @@ int main(int argc, char **argv) {
.mpx_deviation = DEFAULT_MPX_DEVIATION, .mpx_deviation = DEFAULT_MPX_DEVIATION,
.master_volume = DEFAULT_MASTER_VOLUME, .master_volume = DEFAULT_MASTER_VOLUME,
.audio_volume = DEFAULT_AUDIO_VOLUME, .audio_volume = DEFAULT_AUDIO_VOLUME,
.audio_preamp = DEFAULT_AUDIO_PREAMP,
.sample_rate = DEFAULT_SAMPLE_RATE, .sample_rate = DEFAULT_SAMPLE_RATE,