From 88729d9c1ddabe67ed110ef2ee77a773b57d3313 Mon Sep 17 00:00:00 2001 From: Kuba <132459354+KubaPro010@users.noreply.github.com> Date: Sun, 11 Feb 2024 21:50:08 +0100 Subject: [PATCH] add toggle compressor and compressor max gain recip while runtime --- src/pifmrds/control_pipe.c | 12 ++++++++++++ src/pifmrds/control_pipe.h | 4 +++- src/pifmrds/fm_mpx.c | 2 +- src/pifmrds/pi_fm_rds.cpp | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/pifmrds/control_pipe.c b/src/pifmrds/control_pipe.c index 0e35156..98cc300 100644 --- a/src/pifmrds/control_pipe.c +++ b/src/pifmrds/control_pipe.c @@ -199,6 +199,18 @@ ResultAndArg poll_control_pipe() { if(mpx) printf("ON\n"); else printf("OFF\n"); resarg.res = CONTROL_PIPE_MPXGEN_SET; resarg.arg_int = mpx; + } else if(fifo[0] == 'C' && fifo[1] == 'O' && fifo[2] == 'M') { + int compressor = ( strcmp(arg, "ON") == 0 ); + printf("Set Compressor to "); + if(compressor) printf("ON\n"); else printf("OFF\n"); + resarg.res = CONTROL_PIPE_COMPRESSOR_SET; + resarg.arg_int = compressor; //bool is just a fancy work for 0 or 1, atleast here + } else if(fifo[0] == 'C' && fifo[1] == 'M' && fifo[2] == 'G') { + printf("Set Compressor Max Gain Recip to "); + printf(arg); + printf("\n"); + resarg.res = CONTROL_PIPE_COMPRESSORMAXGAINRECIP_SET; + resarg.arg = arg; } } return resarg; diff --git a/src/pifmrds/control_pipe.h b/src/pifmrds/control_pipe.h index 8fb6d5c..5c8dac3 100644 --- a/src/pifmrds/control_pipe.h +++ b/src/pifmrds/control_pipe.h @@ -23,8 +23,10 @@ #define CONTROL_PIPE_CT_SET 16 #define CONTROL_PIPE_RDSVOL_SET 17 #define CONTROL_PIPE_PAUSE_SET 18 -#define CONTROL_PIPE_PILVOL_SET 19 //fitting +#define CONTROL_PIPE_PILVOL_SET 19 //fitting, isn't it? #define CONTROL_PIPE_MPXGEN_SET 20 +#define CONTROL_PIPE_COMPRESSOR_SET 21 +#define CONTROL_PIPE_COMPRESSORMAXGAINRECIP_SET 23 typedef struct { int res; diff --git a/src/pifmrds/fm_mpx.c b/src/pifmrds/fm_mpx.c index 92833e6..e63024d 100644 --- a/src/pifmrds/fm_mpx.c +++ b/src/pifmrds/fm_mpx.c @@ -363,7 +363,7 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa } if(!generate_multiplex) { mpx_buffer[i] = - 0.0; //nothing, rpitx works like this: theres a array with data and rpitx goes thought it to transmit it, now here the functions with the mpx_buffer such as this one update the array, but what if the array is not updated? well, then it keeps transmitting the exact same thing, it doesnt update whats its transmitting, no really, take a sdr and remove this and turn off the mpx gen, if no music then look at rds + 0.0; //nothing, rpitx works like this (i think): theres a array with data and rpitx goes thought it to transmit it, now here the functions with the mpx_buffer such as this one update the array, but what if the array is not updated? well, then it keeps transmitting the exact same thing, it doesnt update whats its transmitting, no really, take a sdr and remove this and turn off the mpx gen, if no music then look at rds } audio_pos++; diff --git a/src/pifmrds/pi_fm_rds.cpp b/src/pifmrds/pi_fm_rds.cpp index 31c262f..91e57cd 100644 --- a/src/pifmrds/pi_fm_rds.cpp +++ b/src/pifmrds/pi_fm_rds.cpp @@ -190,6 +190,10 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, pilot_volume = std::stof(pollResult.arg); } else if(pollResult.res == CONTROL_PIPE_MPXGEN_SET) { generate_multiplex = pollResult.arg_int; + } else if(pollResult.res == CONTROL_PIPE_COMPRESSOR_SET) { + enablecompressor = pollResult.arg_int; + } else if(pollResult.res == CONTROL_PIPE_COMPRESSORMAXGAINRECIP_SET) { + compressor_max_gain_recip = std::stof(pollResult.arg); } }