oh that's why (controlpipe.h)

This commit is contained in:
Kuba 2023-11-01 08:14:07 +00:00
parent fe28322de8
commit c78711ae18
4 changed files with 13 additions and 9 deletions

View File

@ -18,8 +18,8 @@
#define CONTROL_PIPE_DEVIATION_SET 11
#define CONTROL_PIPE_STEREO_SET 12
#define CONTROL_PIPE_GAIN_SET 13
#define CONTROL_PIPE_COMPRESSORDECAY_SET 13
#define CONTROL_PIPE_COMPRESSORATTACK_SET 13
#define CONTROL_PIPE_COMPRESSORDECAY_SET 14
#define CONTROL_PIPE_COMPRESSORATTACK_SET 15
typedef struct {
int res;

View File

@ -193,7 +193,7 @@ int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int raw
// samples provided by this function are in 0..10: they need to be divided by
// 10 after.
int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int disablestereo, float gain) {
int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int disablestereo, float gain, int enablecompressor) {
if(!drds) get_rds_samples(mpx_buffer, length);
if(inf == NULL) return 0; // if there is no audio, stop here
@ -306,9 +306,9 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
else if( left_max < right_max )
left_max=right_max;
}
out_right=out_right/(right_max+compressor_max_gain_recip);
if(enablecompressor) out_right=out_right/(right_max+compressor_max_gain_recip);
}
out_left= out_left/(left_max+compressor_max_gain_recip); // Adjust volume with limited maximum gain
if(enablecompressor) out_left= out_left/(left_max+compressor_max_gain_recip); // Adjust volume with limited maximum gain
if(drds) mpx_buffer[i] = 0; //do not remove this, the bandwidht will go nuts

View File

@ -22,5 +22,5 @@
*/
extern int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int rawSampleRate, int rawChannels, float cutoff_freq);
extern int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int disablestereo, float gain);
extern int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int disablestereo, float gain, int enablecompressor);
extern int fm_mpx_close();

View File

@ -81,7 +81,7 @@ static volatile void *map_peripheral(uint32_t base, uint32_t len)
return vaddr;
}
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim, float compressor_decay, float compressor_attack, float compressor_max_gain_recip) {
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int enablecompressor) {
// Catch all signals possible - it is vital we kill the DMA engine
// on process exit!
for (int i = 0; i < 64; i++) {
@ -208,7 +208,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
}
}
if( fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip, disablestereo, gaim) < 0 ) {
if( fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip, disablestereo, gaim, enablecompressor) < 0 ) {
terminate(0);
}
data_len = DATA_SIZE;
@ -237,6 +237,7 @@ int main(int argc, char **argv) {
float compressor_decay = 0.999995;
float compressor_attack = 1.0;
float compressor_max_gain_recip = 0.01;
int enable_compressor = 1;
int ta = 0;
int tp = 0;
int af_size = 0;
@ -350,6 +351,9 @@ int main(int argc, char **argv) {
} else if(strcmp("-disablerds", arg)==0) {
i++;
drds = 1;
} else if(strcmp("-disablecompressor", arg)==0) {
i++;
enable_compressor = 0;
} else if(strcmp("-preemphasis", arg)==0 && param != NULL) {
i++;
if(strcmp("us", param)==0) {
@ -376,6 +380,6 @@ int main(int argc, char **argv) {
alternative_freq[0] = af_size;
int FifoSize=DATA_SIZE*2;
fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin);
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain, compressor_decay, compressor_attack, compressor_max_gain_recip);
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain, compressor_decay, compressor_attack, compressor_max_gain_recip, enable_compressor);
terminate(errcode);
}