Merge pull request #16 from lwvmobile/lwvmobile-patch-pulse-stdin-etc
Fix STDIN, file playback, and WAV file creation
This commit is contained in:
commit
003b956d2c
|
|
@ -117,6 +117,7 @@ void playRawAudio(dsd_opts * opts, dsd_state * state) {
|
|||
if (opts->audio_out_type == 0){
|
||||
//write (opts->audio_out_fd, (void*)&obuf, outl);
|
||||
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL);
|
||||
//printf("writing samples");
|
||||
}
|
||||
|
||||
#ifdef USE_PORTAUDIO //no idea if this method will work, since I can't test it
|
||||
|
|
@ -308,6 +309,7 @@ writeSynthesizedVoice (dsd_opts * opts, dsd_state * state)
|
|||
}
|
||||
|
||||
sf_write_short(opts->wav_out_f, aout_buf, 160);
|
||||
|
||||
/*
|
||||
|
||||
int n;
|
||||
|
|
@ -396,16 +398,13 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
|
|||
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
if (opts->monitor_input_audio == 1){
|
||||
pa_simple_flush(opts->pulse_raw_dev_in, NULL);
|
||||
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
|
||||
}
|
||||
|
||||
else
|
||||
//if (opts->monitor_input_audio == 1){
|
||||
//pa_simple_flush(opts->pulse_raw_dev_in, NULL);
|
||||
//pa_simple_flush(opts->pulse_raw_dev_out, NULL);
|
||||
//}
|
||||
pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL); //Yay! It works.
|
||||
state->audio_out_idx = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (state->audio_out_idx2 >= 800000)
|
||||
|
|
@ -610,6 +609,7 @@ openAudioInDevice (dsd_opts * opts)
|
|||
opts->audio_in_type = 1;
|
||||
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
|
||||
opts->audio_in_file_info->samplerate=48000;
|
||||
opts->pulse_digi_rate_out = 8000; //set out rate to 8000 for stdin input
|
||||
opts->audio_in_file_info->channels=1;
|
||||
opts->audio_in_file_info->seekable=0;
|
||||
opts->audio_in_file_info->format=SF_FORMAT_RAW|SF_FORMAT_PCM_16|SF_ENDIAN_LITTLE;
|
||||
|
|
@ -617,7 +617,7 @@ openAudioInDevice (dsd_opts * opts)
|
|||
|
||||
if(opts->audio_in_file == NULL) {
|
||||
printf ("Error, couldn't open stdin with libsndfile: %s\n", sf_strerror(NULL));
|
||||
//exit(1);
|
||||
exit(1); //had this one disabled, re-enabling it now
|
||||
}
|
||||
}
|
||||
else if(strncmp(opts->audio_in_dev, "pa:", 2) == 0)
|
||||
|
|
@ -659,6 +659,7 @@ openAudioInDevice (dsd_opts * opts)
|
|||
if (S_ISREG(stat_buf.st_mode))
|
||||
{
|
||||
// is this a regular file? then process with libsndfile.
|
||||
//opts->pulse_digi_rate_out = 8000; //this for wav files input?
|
||||
opts->audio_in_type = 1;
|
||||
opts->audio_in_file_info = calloc(1, sizeof(SF_INFO));
|
||||
opts->audio_in_file_info->channels = 1;
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ openWavOutFile (dsd_opts * opts, dsd_state * state)
|
|||
// opts->wav_out_f = fopen (opts->wav_out_file, "w");
|
||||
|
||||
SF_INFO info;
|
||||
info.samplerate = 8000;
|
||||
info.samplerate = 8000; //8000
|
||||
info.channels = 1;
|
||||
info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE;
|
||||
opts->wav_out_f = sf_open (opts->wav_out_file, SFM_WRITE, &info);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
|||
//printf("now=%d\n", now); //okay, so this is incrementing as expected
|
||||
if ( opts->monitor_input_audio == 1 && (time(NULL) - now) > 1 ) //okay, still something going on, still doing the read part for some reason
|
||||
{
|
||||
playRawAudio(opts, state); //this is on line 21 in dsd_audio.c
|
||||
//playRawAudio(opts, state); //this is on line 21 in dsd_audio.c
|
||||
}
|
||||
|
||||
t++;
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@ main (int argc, char **argv)
|
|||
opts.frame_nxdn48 = 0;
|
||||
opts.frame_nxdn96 = 0;
|
||||
opts.frame_dmr = 1;
|
||||
opts.frame_provoice = 0;
|
||||
opts.frame_provoice = 0; //turn it on, doesn't work due to symbol rate difference
|
||||
}
|
||||
else if (optarg[0] == 'd')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
|||
// TODO: need to read demodulated stream here
|
||||
get_rtlsdr_sample(&sample);
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,18 +15,18 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
//strftime (datestr, 31, "%Y-%m-%d-%H%M%S", &timep);
|
||||
//printf ("%s VOICE e:", datestr);
|
||||
//printf ("VOICE e:");
|
||||
printf ("VOICE e:");
|
||||
}
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf (" ");
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
// lid
|
||||
|
|
@ -34,22 +34,22 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf (" ");
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf (" ");
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
// imbe frames 1,2 first half
|
||||
|
|
@ -77,14 +77,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -92,14 +92,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr1[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
w -= 6;
|
||||
x -= 6;
|
||||
|
|
@ -107,25 +107,25 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf (" ");
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
// spacer bits
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
//printf (" ");
|
||||
printf ("%i", dibit);
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
// imbe frames 1,2 second half
|
||||
|
|
@ -134,14 +134,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
|
|
@ -150,14 +150,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr1[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
w -= 6;
|
||||
x -= 6;
|
||||
|
|
@ -165,14 +165,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -180,14 +180,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr1[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
w -= 5;
|
||||
x -= 5;
|
||||
|
|
@ -195,14 +195,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
|
|
@ -218,7 +218,7 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
w -= 6;
|
||||
x -= 6;
|
||||
|
|
@ -226,14 +226,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -241,14 +241,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr1[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
w -= 5;
|
||||
x -= 5;
|
||||
|
|
@ -256,14 +256,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf (" ");
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
processMbeFrame (opts, state, NULL, NULL, imbe7100_fr1);
|
||||
|
|
@ -272,23 +272,23 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
// spacer bits
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
//printf (" ");
|
||||
printf ("%i", dibit);
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf (" ");
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
// imbe frames 3,4 first half
|
||||
|
|
@ -300,14 +300,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr1[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
w -= 6;
|
||||
x -= 6;
|
||||
|
|
@ -315,28 +315,28 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
}
|
||||
for (j = 0; j < 6; j++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr1[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("_");
|
||||
printf ("_");
|
||||
#endif
|
||||
w -= 6;
|
||||
x -= 6;
|
||||
|
|
@ -344,14 +344,14 @@ processProVoice (dsd_opts * opts, dsd_state * state)
|
|||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf ("%i", dibit);
|
||||
printf ("%i", dibit);
|
||||
#endif
|
||||
imbe7100_fr2[*w][*x] = dibit;
|
||||
w++;
|
||||
x++;
|
||||
}
|
||||
#ifdef PROVOICE_DUMP
|
||||
//printf (" ");
|
||||
printf (" ");
|
||||
#endif
|
||||
|
||||
// spacer bits
|
||||
|
|
|
|||
|
|
@ -1054,7 +1054,7 @@ void open_rtlsdr_stream(dsd_opts *opts)
|
|||
int r;
|
||||
rtl_bandwidth = opts->rtl_bandwidth * 1000; //multiple by 1000 to get rate
|
||||
//rtl_bandwidth = 48000;
|
||||
bandwidth_multiplier = (bandwidth_divisor / rtl_bandwidth); //find multiple with no remainder if oddball number entered
|
||||
bandwidth_multiplier = (bandwidth_divisor / rtl_bandwidth);
|
||||
//bandwidth_multiplier = 1;
|
||||
dongle_init(&dongle);
|
||||
demod_init(&demod);
|
||||
|
|
|
|||
Loading…
Reference in New Issue