Simply Mono Short Playback;

This commit is contained in:
lwvmobile
2024-03-24 12:28:26 -04:00
parent 89ad0f17e3
commit 9249b7a943
10 changed files with 158 additions and 34 deletions

View File

@@ -994,6 +994,8 @@ void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot); //floa
void agsm (dsd_opts * opts, dsd_state * state, short * input, int len); //short gain control for analog things
void analog_gain (dsd_opts * opts, dsd_state * state, short * input, int len); //manual gain handling for analong things
//new short stuff
void playSynthesizedVoiceMS (dsd_opts * opts, dsd_state * state); //short mono mix
void playSynthesizedVoiceMSR (dsd_opts * opts, dsd_state * state); //short mono mix R (needed for OSS 48k input/output)
void playSynthesizedVoiceSS (dsd_opts * opts, dsd_state * state); //short stereo mix
void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state); //short stereo mix 3v2 DMR
void playSynthesizedVoiceSS4 (dsd_opts * opts, dsd_state * state); //short stereo mix 4v2 P25p2

View File

@@ -478,7 +478,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
{
processMbeFrame (opts, state, NULL, ambe_fr[i], NULL);
if (opts->floating_point == 0)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1)
playSynthesizedVoiceFM(opts, state);
}

View File

@@ -724,6 +724,128 @@ void playSynthesizedVoiceFM (dsd_opts * opts, dsd_state * state)
}
//Mono - Short (SB16LE) - Drop-in replacement for playSyntesizedVoice, but easier to manipulate
void playSynthesizedVoiceMS (dsd_opts * opts, dsd_state * state)
{
int i;
size_t len = state->audio_out_idx;
//debug
// fprintf (stderr, " L LEN: %d", len);
short mono_samp[len];
memset (mono_samp, 0, len*sizeof(short));
if (opts->slot1_on == 0)
goto MS_END;
if (len == 160)
{
for (i = 0; i < len; i++)
mono_samp[i] = state->s_l[i];
}
else if (len == 960)
{
state->audio_out_buf_p -= 960; //rewind first
for (i = 0; i < len; i++)
{
mono_samp[i] = *state->audio_out_buf_p;
state->audio_out_buf_p++;
}
}
if (opts->use_hpf_d == 1)
hpf_dL(state, state->s_l, len);
if (opts->audio_out_type == 0) //Pulse Audio
pa_simple_write(opts->pulse_digi_dev_out, mono_samp, len*2, NULL);
if (opts->audio_out_type == 8) //UDP Audio
udp_socket_blaster (opts, state, len*2, mono_samp);
if (opts->audio_out_type == 1 || opts->audio_out_type == 2 || opts->audio_out_type == 5) //STDOUT or OSS
write (opts->audio_out_fd, mono_samp, len*2);
MS_END:
//run cleanup since we pulled stuff from processAudio
state->audio_out_idx = 0;
//set short temp buffer to baseline
memset (state->s_l, 0, sizeof(state->s_l));
if (state->audio_out_idx2 >= 800000)
{
state->audio_out_float_buf_p = state->audio_out_float_buf + 100;
state->audio_out_buf_p = state->audio_out_buf + 100;
memset (state->audio_out_float_buf, 0, 100 * sizeof (float));
memset (state->audio_out_buf, 0, 100 * sizeof (short));
state->audio_out_idx2 = 0;
}
}
//Mono - Short (SB16LE) - Drop-in replacement for playSyntesizedVoiceR, but easier to manipulate
void playSynthesizedVoiceMSR (dsd_opts * opts, dsd_state * state)
{
int i;
size_t len = state->audio_out_idxR;
//debug
// fprintf (stderr, " R LEN: %d", len);
short mono_samp[len];
memset (mono_samp, 0, len*sizeof(short));
if (opts->slot2_on == 0)
goto MS_ENDR;
if (len == 160)
{
for (i = 0; i < len; i++)
mono_samp[i] = state->s_r[i];
}
else if (len == 960)
{
state->audio_out_buf_pR -= 960; //rewind first
for (i = 0; i < len; i++)
{
mono_samp[i] = *state->audio_out_buf_pR;
state->audio_out_buf_pR++;
}
}
if (opts->use_hpf_d == 1)
hpf_dR(state, mono_samp, len);
if (opts->audio_out_type == 0) //Pulse Audio
pa_simple_write(opts->pulse_digi_dev_out, mono_samp, len*2, NULL);
if (opts->audio_out_type == 8) //UDP Audio
udp_socket_blaster (opts, state, len*2, mono_samp);
if (opts->audio_out_type == 1 || opts->audio_out_type == 2 || opts->audio_out_type == 5) //STDOUT or OSS
write (opts->audio_out_fd, mono_samp, len*2);
MS_ENDR:
//run cleanup since we pulled stuff from processAudioR
state->audio_out_idxR = 0;
//set short temp buffer to baseline
memset (state->s_r, 0, sizeof(state->s_r));
if (state->audio_out_idx2R >= 800000)
{
state->audio_out_float_buf_pR = state->audio_out_float_bufR + 100;
state->audio_out_buf_pR = state->audio_out_bufR + 100;
memset (state->audio_out_float_bufR, 0, 100 * sizeof (float));
memset (state->audio_out_bufR, 0, 100 * sizeof (short));
state->audio_out_idx2R = 0;
}
}
//Stereo Mix - Short (SB16LE) -- When Playing Short FDMA samples when setup for stereo output
void playSynthesizedVoiceSS (dsd_opts * opts, dsd_state * state)
{
@@ -731,7 +853,7 @@ void playSynthesizedVoiceSS (dsd_opts * opts, dsd_state * state)
int i;
int encL;
short stereo_samp1[320]; //8k 2-channel stereo interleave mix
memset (stereo_samp1, 1, sizeof(stereo_samp1));
memset (stereo_samp1, 0, sizeof(stereo_samp1));
//enc checkdown for whether or not to fill the stereo sample or not for playback or writing
encL = 0;

View File

@@ -134,7 +134,7 @@ void playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
if (opts->audio_out == 1 && opts->floating_point == 0)
{
playSynthesizedVoice (opts, state);
playSynthesizedVoiceMS (opts, state);
}
if (opts->floating_point == 1)
{
@@ -174,7 +174,7 @@ void playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
if (opts->audio_out == 1 && opts->floating_point == 0)
{
playSynthesizedVoice (opts, state);
playSynthesizedVoiceMS (opts, state);
}
if (opts->floating_point == 1)
{
@@ -1084,7 +1084,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
}
if (opts->audio_out == 1 && opts->floating_point == 0 && opts->audio_out_type == 5 && opts->slot1_on == 1) //for OSS 48k 1 channel configs -- relocate later if possible
{
playSynthesizedVoice (opts, state); //it may be more beneficial to move this to each individual decoding type to handle, but ultimately, let's just simpifly mbe handling instead
playSynthesizedVoiceMS (opts, state); //it may be more beneficial to move this to each individual decoding type to handle, but ultimately, let's just simpifly mbe handling instead
}
}
@@ -1161,7 +1161,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
}
if (opts->audio_out == 1 && opts->floating_point == 0 && opts->audio_out_type == 5 && opts->slot2_on == 1) //for OSS 48k 1 channel configs -- relocate later if possible
{
playSynthesizedVoiceR (opts, state);
playSynthesizedVoiceMSR (opts, state);
}
}

View File

@@ -115,7 +115,7 @@ void soft_mbe (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char amb
PrintAMBEData (opts, state, ambe_d);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoiceFM(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
@@ -138,7 +138,7 @@ void soft_mbe (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char amb
PrintAMBEData (opts, state, ambe_d);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoiceFM(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)

View File

@@ -93,7 +93,7 @@ void nxdn_voice (dsd_opts * opts, dsd_state * state, int voice, uint8_t dbuf[182
memcpy (state->f_l, state->audio_out_temp_buf, sizeof(state->f_l));
if (opts->floating_point == 0 )
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1)
playSynthesizedVoiceFM(opts, state);
}

View File

@@ -60,7 +60,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -74,7 +74,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -95,7 +95,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -116,7 +116,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -137,7 +137,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -158,7 +158,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -179,7 +179,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -200,7 +200,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -261,7 +261,7 @@ processLDU1 (dsd_opts* opts, dsd_state* state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)

View File

@@ -65,7 +65,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -79,7 +79,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -100,7 +100,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -121,7 +121,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -142,7 +142,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -163,7 +163,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -184,7 +184,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoiceFM(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 2)
@@ -203,7 +203,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)
@@ -264,7 +264,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state)
#endif
process_IMBE (opts, state, &status_count);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 0 && opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
if (opts->floating_point == 1 && opts->pulse_digi_out_channels == 1)

View File

@@ -214,12 +214,12 @@ void processProVoice (dsd_opts * opts, dsd_state * state)
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1);
if (opts->floating_point == 0)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1)
playSynthesizedVoiceFM(opts, state);
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr2);
if (opts->floating_point == 0)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1)
playSynthesizedVoiceFM(opts, state);
@@ -392,12 +392,12 @@ void processProVoice (dsd_opts * opts, dsd_state * state)
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1);
if (opts->floating_point == 0)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1)
playSynthesizedVoiceFM(opts, state);
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr2);
if (opts->floating_point == 0)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if (opts->floating_point == 1)
playSynthesizedVoiceFM(opts, state);

View File

@@ -737,7 +737,7 @@ void ysf_ehr (dsd_opts * opts, dsd_state * state, uint8_t dbuf[180], int start,
writeSynthesizedVoice (opts, state);
if (opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if(opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
@@ -1027,7 +1027,7 @@ void processYSF(dsd_opts * opts, dsd_state * state)
if (opts->wav_out_f != NULL)
writeSynthesizedVoice (opts, state);
if (opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if(opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);
@@ -1147,7 +1147,7 @@ void processYSF(dsd_opts * opts, dsd_state * state)
writeSynthesizedVoice (opts, state);
if (opts->pulse_digi_out_channels == 1)
playSynthesizedVoice(opts, state);
playSynthesizedVoiceMS(opts, state);
if(opts->pulse_digi_out_channels == 2)
playSynthesizedVoiceSS(opts, state);