turn on and off mpx generation (carrier wave only)
This commit is contained in:
parent
a0eca75b12
commit
3f0c3a3035
|
|
@ -193,6 +193,12 @@ ResultAndArg poll_control_pipe() {
|
|||
printf("\n");
|
||||
resarg.res = CONTROL_PIPE_PILVOL_SET;
|
||||
resarg.arg = arg;
|
||||
} else if(fifo[0] == 'M' && fifo[1] == 'P' && fifo[2] == 'X') {
|
||||
int mpx = ( strcmp(arg, "ON") == 0 );
|
||||
printf("Set Generate MPX to ");
|
||||
if(mpx) printf("ON\n"); else printf("OFF\n");
|
||||
resarg.res = CONTROL_PIPE_MPXGEN_SET;
|
||||
resarg.arg_int = mpx;
|
||||
}
|
||||
}
|
||||
return resarg;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#define CONTROL_PIPE_RDSVOL_SET 17
|
||||
#define CONTROL_PIPE_PAUSE_SET 18
|
||||
#define CONTROL_PIPE_PILVOL_SET 19 //fitting
|
||||
#define CONTROL_PIPE_MPXGEN_SET 20
|
||||
|
||||
typedef struct {
|
||||
int res;
|
||||
|
|
|
|||
|
|
@ -200,9 +200,9 @@ 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 enablecompressor, int rds_ct_enabled, float rds_volume, int paused, float pilot_volume) {
|
||||
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, int rds_ct_enabled, float rds_volume, int paused, float pilot_volume, int generate_multiplex) {
|
||||
int stereo_capable = (channels > 1) && (!disablestereo); //chatgpt
|
||||
if(!drds) get_rds_samples(mpx_buffer, length, stereo_capable, rds_ct_enabled, rds_volume);
|
||||
if(!drds && generate_multiplex) get_rds_samples(mpx_buffer, length, stereo_capable, rds_ct_enabled, rds_volume);
|
||||
|
||||
if(inf == NULL) return 0; // if there is no audio, stop here
|
||||
|
||||
|
|
@ -326,6 +326,7 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
|||
// Generate the stereo mpx
|
||||
if( channels > 1 ) {
|
||||
if(!disablestereo) {
|
||||
if(generate_multiplex) {
|
||||
if(1) {
|
||||
mpx_buffer[i] += 4.05*(out_left+out_right) + // Stereo sum signal
|
||||
4.05 * carrier_38[phase_38] * (out_left-out_right) + // Stereo difference signal
|
||||
|
|
@ -343,18 +344,23 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds, float compressor_decay, floa
|
|||
phase_3125++;
|
||||
if(phase_3125 >= 6) phase_3125 = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(generate_multiplex) {
|
||||
mpx_buffer[i] =
|
||||
mpx_buffer[i] +
|
||||
4.05*(out_left+out_right); // Unmodulated L+R signal
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(generate_multiplex) {
|
||||
mpx_buffer[i] =
|
||||
mpx_buffer[i] +
|
||||
4.05*out_left; // Unmodulated monophonic signal
|
||||
}
|
||||
}
|
||||
|
||||
audio_pos++;
|
||||
|
||||
|
|
|
|||
|
|
@ -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, int enablecompressor, int rds_ct_enabled, float rds_volume, int paused, float pilot_volume);
|
||||
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, int rds_ct_enabled, float rds_volume, int paused, float pilot_volume, int generate_multiplex);
|
||||
extern int fm_mpx_close();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ fatal(char *fmt, ...)
|
|||
terminate(0);
|
||||
}
|
||||
|
||||
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, 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, int rds_ct_enabled, float rds_volume, float pilot_volume) {
|
||||
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, 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, int rds_ct_enabled, float rds_volume, float pilot_volume, int disablestereo) {
|
||||
// Catch all signals possible - it is vital we kill the DMA engine
|
||||
// on process exit!
|
||||
// for (int i = 0; i < 64; i++) {
|
||||
|
|
@ -72,7 +72,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
int data_len = 0;
|
||||
int data_index = 0;
|
||||
|
||||
int disablestereo = 0;
|
||||
int generate_multiplex = 1;
|
||||
|
||||
//set the power
|
||||
padgpio gpiopad;
|
||||
|
|
@ -187,10 +187,12 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
paused = pollResult.arg_int;
|
||||
} else if(pollResult.res == CONTROL_PIPE_PILVOL_SET) {
|
||||
pilot_volume = std::stof(pollResult.arg);
|
||||
} else if(pollResult.res == CONTROL_PIPE_MPXGEN_SET) {
|
||||
generate_multiplex = pollResult.arg_int;
|
||||
}
|
||||
}
|
||||
|
||||
if( fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip, disablestereo, gaim, enablecompressor, rds_ct_enabled, rds_volume, paused, pilot_volume) < 0 ) {
|
||||
if( fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip, disablestereo, gaim, enablecompressor, rds_ct_enabled, rds_volume, paused, pilot_volume, generate_multiplex) < 0 ) {
|
||||
terminate(0);
|
||||
}
|
||||
data_len = DATA_SIZE;
|
||||
|
|
@ -377,6 +379,6 @@ int main(int argc, char **argv) {
|
|||
int FifoSize=DATA_SIZE*2;
|
||||
//fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin); //you can mod
|
||||
fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false);
|
||||
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, 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, ct, rds_volume, pilot_volume);
|
||||
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, 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, ct, rds_volume, pilot_volume, 0);
|
||||
terminate(errcode);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue