mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-13 09:17:20 -05:00
Add Float Symbol Input File Support (.raw or .sym);
This commit is contained in:
@@ -901,7 +901,7 @@ openAudioInDevice (dsd_opts * opts)
|
||||
}
|
||||
|
||||
//test .rrc files with hardset wav file settings
|
||||
else if (strncmp(extension, ".rrc", 3) == 0)
|
||||
else if (strncmp(extension, ".rrc", 4) == 0)
|
||||
{
|
||||
//debug
|
||||
fprintf (stderr, "Opening M17 .rrc headless wav file\n");
|
||||
@@ -921,19 +921,19 @@ openAudioInDevice (dsd_opts * opts)
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: test .sym files as symbol capture .bin files
|
||||
else if (strncmp(extension, ".sym", 3) == 0)
|
||||
//Open .raw files as a float input type
|
||||
else if (strncmp(extension, ".raw", 4) == 0)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
if (stat(opts->audio_in_dev, &stat_buf) != 0)
|
||||
{
|
||||
fprintf (stderr,"Error, couldn't open bin file %s\n", opts->audio_in_dev);
|
||||
fprintf (stderr,"Error, couldn't open raw (float) file %s\n", opts->audio_in_dev);
|
||||
exit(1);
|
||||
}
|
||||
if (S_ISREG(stat_buf.st_mode))
|
||||
{
|
||||
opts->symbolfile = fopen(opts->audio_in_dev, "r");
|
||||
opts->audio_in_type = 4; //symbol capture bin files
|
||||
opts->audio_in_type = 44; //float symbol input
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -941,7 +941,27 @@ openAudioInDevice (dsd_opts * opts)
|
||||
}
|
||||
}
|
||||
|
||||
else if (strncmp(extension, ".bin", 3) == 0)
|
||||
//Open .raw files as a float input type
|
||||
else if (strncmp(extension, ".sym", 4) == 0)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
if (stat(opts->audio_in_dev, &stat_buf) != 0)
|
||||
{
|
||||
fprintf (stderr,"Error, couldn't open sym (float) file %s\n", opts->audio_in_dev);
|
||||
exit(1);
|
||||
}
|
||||
if (S_ISREG(stat_buf.st_mode))
|
||||
{
|
||||
opts->symbolfile = fopen(opts->audio_in_dev, "r");
|
||||
opts->audio_in_type = 44; //float symbol input
|
||||
}
|
||||
else
|
||||
{
|
||||
opts->audio_in_type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (strncmp(extension, ".bin", 4) == 0)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
if (stat(opts->audio_in_dev, &stat_buf) != 0)
|
||||
|
||||
@@ -2474,7 +2474,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
if (opts->audio_in_type == 4)
|
||||
{
|
||||
printw ("| Symbol Bin Input: %s \n", opts->audio_in_dev);
|
||||
printw ("| Dibit Bin Input: %s \n", opts->audio_in_dev);
|
||||
}
|
||||
|
||||
if (opts->audio_in_type == 44)
|
||||
{
|
||||
printw ("| Symbol Float Input: %s \n", opts->audio_in_dev);
|
||||
}
|
||||
|
||||
if (opts->m17decoderip == 1 && opts->udp_sockfd)
|
||||
|
||||
@@ -627,13 +627,7 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
||||
}
|
||||
#endif
|
||||
|
||||
//test throttle on wav input files
|
||||
if (opts->audio_in_type == 2)
|
||||
{
|
||||
if (state->use_throttle == 1) usleep(.003); //very environment specific, tuning to cygwin
|
||||
}
|
||||
|
||||
//read op25/fme symbol bin files
|
||||
//read dibit capture bin files
|
||||
if (opts->audio_in_type == 4)
|
||||
{
|
||||
//use fopen and read in a symbol, check op25 for clues
|
||||
@@ -713,6 +707,16 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
||||
|
||||
}
|
||||
|
||||
//.raw or .sym float symbol files
|
||||
if (opts->audio_in_type == 44)
|
||||
{
|
||||
float float_symbol = 0.0f;
|
||||
fread (&float_symbol, sizeof(float), 1, opts->symbolfile); //sizeof(float) is 4 (usually)
|
||||
if ( feof(opts->symbolfile) ) exitflag = 1; //end of file, exit
|
||||
// float_symbol = -float_symbol; //inversion
|
||||
symbol = (int)float_symbol * (int)10000;
|
||||
}
|
||||
|
||||
state->symbolcnt++;
|
||||
return (symbol);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user