compressor adjustable
This commit is contained in:
parent
55735c9afc
commit
2005117a2c
|
|
@ -194,7 +194,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) {
|
||||
int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip) {
|
||||
if(!drds) get_rds_samples(mpx_buffer, length);
|
||||
|
||||
if(inf == NULL) return 0; // if there is no audio, stop here
|
||||
|
|
@ -274,10 +274,7 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds) {
|
|||
// Don't expect this simple code to match the
|
||||
// performance of commercial broadcast equipment.
|
||||
float left_abs, right_abs;
|
||||
float compressor_decay=0.999995;
|
||||
float compressor_attack=1.0;
|
||||
// Setting attack to anything other than 1.0 could cause overshoot.
|
||||
float compressor_max_gain_recip=0.01;
|
||||
left_abs=fabsf(out_left);
|
||||
if( left_abs>left_max )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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, float gain);
|
||||
extern int fm_mpx_get_samples(float *mpx_buffer, int drds);
|
||||
extern int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, float compressor_attack, float compressor_max_gain_recip);
|
||||
extern int fm_mpx_close();
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
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) {
|
||||
// Catch all signals possible - it is vital we kill the DMA engine
|
||||
// on process exit!
|
||||
for (int i = 0; i < 64; i++) {
|
||||
|
|
@ -187,7 +187,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
varying_ps = 0;
|
||||
}
|
||||
|
||||
if( fm_mpx_get_samples(data, drds) < 0 ) {
|
||||
if( fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip) < 0 ) {
|
||||
terminate(0);
|
||||
}
|
||||
data_len = DATA_SIZE;
|
||||
|
|
@ -213,6 +213,9 @@ int main(int argc, char **argv) {
|
|||
char *rt = "Broadcasting on a Raspberry Pi: Simply Advanced";
|
||||
uint16_t pi = 0x1234;
|
||||
int pty = 0;
|
||||
float compressor_decay = 0.999995;
|
||||
float compressor_attack = 1.0;
|
||||
float compressor_max_gain_recip = 0.01;
|
||||
int ta = 0;
|
||||
int tp = 0;
|
||||
int af_size = 0;
|
||||
|
|
@ -254,6 +257,15 @@ int main(int argc, char **argv) {
|
|||
} else if(strcmp("-ppm", arg)==0 && param != NULL) {
|
||||
i++;
|
||||
ppm = atof(param);
|
||||
} else if(strcmp("-compressordecay", arg)==0 && param != NULL) {
|
||||
i++;
|
||||
compressor_decay = atof(param);
|
||||
} else if(strcmp("-compressorattack", arg)==0 && param != NULL) {
|
||||
i++;
|
||||
compressor_attack = atof(param);
|
||||
} else if(strcmp("-compressormaxgainrecip", arg)==0 && param != NULL) {
|
||||
i++;
|
||||
compressor_max_gain_recip = atof(param);
|
||||
} else if(strcmp("-pty", arg)==0 && param != NULL) {
|
||||
i++;
|
||||
pty = atoi(param);
|
||||
|
|
@ -336,6 +348,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);
|
||||
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);
|
||||
terminate(errcode);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue