mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-20 12:45:40 -05:00
UDP Audio Output -- Audio Implementation;
This commit is contained in:
@@ -718,22 +718,23 @@ openAudioInDevice (dsd_opts * opts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strncmp(opts->audio_in_dev, "udp", 3) == 0)
|
// else if (strncmp(opts->audio_in_dev, "udp", 3) == 0)
|
||||||
{
|
// {
|
||||||
opts->audio_in_type = 6;
|
// opts->audio_in_type = 6;
|
||||||
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
|
// opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
|
||||||
opts->audio_in_file_info->samplerate=opts->wav_sample_rate;
|
// opts->audio_in_file_info->samplerate=opts->wav_sample_rate;
|
||||||
opts->audio_in_file_info->channels=1;
|
// opts->audio_in_file_info->channels=1;
|
||||||
opts->audio_in_file_info->seekable=0;
|
// opts->audio_in_file_info->seekable=0;
|
||||||
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
|
// opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
|
||||||
opts->udp_file_in = sf_open_fd(opts->udp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
|
// opts->udp_file_in = sf_open_fd(opts->udp_sockfd, SFM_READ, opts->audio_in_file_info, 0);
|
||||||
|
|
||||||
|
// if(opts->udp_file_in == NULL)
|
||||||
|
// {
|
||||||
|
// fprintf(stderr, "Error, couldn't open UDP with libsndfile: %s\n", sf_strerror(NULL));
|
||||||
|
// exit(1);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if(opts->udp_file_in == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Error, couldn't open UDP with libsndfile: %s\n", sf_strerror(NULL));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(strncmp(opts->audio_in_dev, "rtl", 3) == 0)
|
else if(strncmp(opts->audio_in_dev, "rtl", 3) == 0)
|
||||||
{
|
{
|
||||||
#ifdef USE_RTLSDR
|
#ifdef USE_RTLSDR
|
||||||
|
|||||||
@@ -169,6 +169,13 @@ void playSynthesizedVoiceFS3 (dsd_opts * opts, dsd_state * state)
|
|||||||
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp3, 320*4, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp3, 320*4, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
{
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp1);
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp2);
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp3);
|
||||||
|
}
|
||||||
|
|
||||||
//No OSS, since we can't use float output, but STDOUT can with play, aplay, etc
|
//No OSS, since we can't use float output, but STDOUT can with play, aplay, etc
|
||||||
|
|
||||||
if (opts->audio_out_type == 1) //STDOUT (still need these seperated? or not really?)
|
if (opts->audio_out_type == 1) //STDOUT (still need these seperated? or not really?)
|
||||||
@@ -344,6 +351,17 @@ void playSynthesizedVoiceFS4 (dsd_opts * opts, dsd_state * state)
|
|||||||
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp4, 320*4, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp4, 320*4, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
{
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp1);
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp2);
|
||||||
|
//only play these two if not a single 2v or double 2v (minor skip can still occur on a 4v and 2v combo, but will probably only be perceivable if one is a tone)
|
||||||
|
if (memcmp(empty, stereo_samp3, sizeof(empty)) != 0)
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp3);
|
||||||
|
if (memcmp(empty, stereo_samp4, sizeof(empty)) != 0)
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp4);
|
||||||
|
}
|
||||||
|
|
||||||
//No OSS, since we can't use float output, but the STDOUT can with play, aplay, etc
|
//No OSS, since we can't use float output, but the STDOUT can with play, aplay, etc
|
||||||
|
|
||||||
if (opts->audio_out_type == 1) //STDOUT
|
if (opts->audio_out_type == 1) //STDOUT
|
||||||
@@ -429,6 +447,8 @@ void playSynthesizedVoiceFS (dsd_opts * opts, dsd_state * state)
|
|||||||
if (opts->audio_out_type == 0) //Pulse Audio
|
if (opts->audio_out_type == 0) //Pulse Audio
|
||||||
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp1, 320*4, NULL); //switch to sizeof(stereo_samp1) * 2?
|
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp1, 320*4, NULL); //switch to sizeof(stereo_samp1) * 2?
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
udp_socket_blaster (opts, state, 320*4, stereo_samp1);
|
||||||
|
|
||||||
//No OSS, since we can't use float output, but STDOUT can with play, aplay, etc
|
//No OSS, since we can't use float output, but STDOUT can with play, aplay, etc
|
||||||
|
|
||||||
@@ -484,6 +504,9 @@ void playSynthesizedVoiceFM (dsd_opts * opts, dsd_state * state)
|
|||||||
if (opts->audio_out_type == 0)
|
if (opts->audio_out_type == 0)
|
||||||
pa_simple_write(opts->pulse_digi_dev_out, state->f_l, 160*4, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, state->f_l, 160*4, NULL);
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
udp_socket_blaster (opts, state, 160*4, state->f_l);
|
||||||
|
|
||||||
if (opts->audio_out_type == 1 || opts->audio_out_type == 5)
|
if (opts->audio_out_type == 1 || opts->audio_out_type == 5)
|
||||||
write(opts->audio_out_fd, state->f_l, 160*4);
|
write(opts->audio_out_fd, state->f_l, 160*4);
|
||||||
|
|
||||||
@@ -540,6 +563,9 @@ void playSynthesizedVoiceSS (dsd_opts * opts, dsd_state * state)
|
|||||||
if (opts->audio_out_type == 0) //Pulse Audio
|
if (opts->audio_out_type == 0) //Pulse Audio
|
||||||
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp1, 320*2, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp1, 320*2, NULL);
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp1);
|
||||||
|
|
||||||
if (opts->audio_out_type == 1 || opts->audio_out_type == 2) //STDOUT or OSS 8k/2
|
if (opts->audio_out_type == 1 || opts->audio_out_type == 2) //STDOUT or OSS 8k/2
|
||||||
write (opts->audio_out_fd, stereo_samp1, 320*2);
|
write (opts->audio_out_fd, stereo_samp1, 320*2);
|
||||||
|
|
||||||
@@ -678,6 +704,12 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
|
|||||||
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp3, 320*2, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp3, 320*2, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
{
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp1);
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp2);
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp3);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts->audio_out_type == 1 || opts->audio_out_type == 2) //STDOUT or OSS 8k/2channel
|
if (opts->audio_out_type == 1 || opts->audio_out_type == 2) //STDOUT or OSS 8k/2channel
|
||||||
{
|
{
|
||||||
@@ -828,6 +860,17 @@ void playSynthesizedVoiceSS4 (dsd_opts * opts, dsd_state * state)
|
|||||||
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp4, 320*2, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, stereo_samp4, 320*2, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
{
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp1);
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp2);
|
||||||
|
//only play these two if not a single 2v or double 2v (minor skip can still occur on a 4v and 2v combo, but will probably only be perceivable if one is a tone)
|
||||||
|
if (memcmp(empty, stereo_samp3, sizeof(empty)) != 0)
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp3);
|
||||||
|
if (memcmp(empty, stereo_samp4, sizeof(empty)) != 0)
|
||||||
|
udp_socket_blaster (opts, state, 320*2, stereo_samp4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (opts->audio_out_type == 1 || opts->audio_out_type == 2) //STDOUT or OSS 8k/2channel
|
if (opts->audio_out_type == 1 || opts->audio_out_type == 2) //STDOUT or OSS 8k/2channel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -295,6 +295,9 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
|||||||
if (opts->audio_out_type == 0)
|
if (opts->audio_out_type == 0)
|
||||||
pa_simple_write(opts->pulse_raw_dev_out, state->analog_out, 960*2, NULL);
|
pa_simple_write(opts->pulse_raw_dev_out, state->analog_out, 960*2, NULL);
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8)
|
||||||
|
udp_socket_blaster (opts, state, 960*2, state->analog_out);
|
||||||
|
|
||||||
//NOTE: Worked okay earlier in Cygwin, so should be fine -- can only operate at 48k1, else slow mode lag
|
//NOTE: Worked okay earlier in Cygwin, so should be fine -- can only operate at 48k1, else slow mode lag
|
||||||
|
|
||||||
//This one will only operate when OSS 48k1 (when both input and output are OSS audio)
|
//This one will only operate when OSS 48k1 (when both input and output are OSS audio)
|
||||||
|
|||||||
@@ -196,6 +196,13 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn
|
|||||||
pa_simple_write(opts->pulse_raw_dev_out, analog3, 960*2, NULL);
|
pa_simple_write(opts->pulse_raw_dev_out, analog3, 960*2, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 8) //UDP Audio
|
||||||
|
{
|
||||||
|
udp_socket_blaster (opts, state, 960*2, analog1);
|
||||||
|
udp_socket_blaster (opts, state, 960*2, analog2);
|
||||||
|
udp_socket_blaster (opts, state, 960*2, analog3);
|
||||||
|
}
|
||||||
|
|
||||||
//added a condition check so that if OSS output and 8K, switches to 48K when opening OSS
|
//added a condition check so that if OSS output and 8K, switches to 48K when opening OSS
|
||||||
if (opts->audio_out_type == 5 && opts->floating_point == 0 && opts->slot1_on == 1)
|
if (opts->audio_out_type == 5 && opts->floating_point == 0 && opts->slot1_on == 1)
|
||||||
{
|
{
|
||||||
|
|||||||
11
src/m17.c
11
src/m17.c
@@ -342,6 +342,11 @@ void M17processCodec2_1600(dsd_opts * opts, dsd_state * state, uint8_t * payload
|
|||||||
pa_simple_write(opts->pulse_digi_dev_out, samp1, nsam*2, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, samp1, nsam*2, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 0 && state->m17_enc == 0) //UDP Audio
|
||||||
|
{
|
||||||
|
udp_socket_blaster (opts, state, nsam*2, samp1);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts->audio_out_type == 5 && state->m17_enc == 0) //OSS 48k/1
|
if (opts->audio_out_type == 5 && state->m17_enc == 0) //OSS 48k/1
|
||||||
{
|
{
|
||||||
//upsample to 48k and then play
|
//upsample to 48k and then play
|
||||||
@@ -438,6 +443,12 @@ void M17processCodec2_3200(dsd_opts * opts, dsd_state * state, uint8_t * payload
|
|||||||
pa_simple_write(opts->pulse_digi_dev_out, samp2, nsam*2, NULL);
|
pa_simple_write(opts->pulse_digi_dev_out, samp2, nsam*2, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->audio_out_type == 0 && state->m17_enc == 0) //UDP Audio
|
||||||
|
{
|
||||||
|
udp_socket_blaster (opts, state, nsam*2, samp1);
|
||||||
|
udp_socket_blaster (opts, state, nsam*2, samp2);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts->audio_out_type == 5 && state->m17_enc == 0) //OSS 48k/1
|
if (opts->audio_out_type == 5 && state->m17_enc == 0) //OSS 48k/1
|
||||||
{
|
{
|
||||||
//upsample to 48k and then play
|
//upsample to 48k and then play
|
||||||
|
|||||||
Reference in New Issue
Block a user