handling "Index" column in prn files
This commit is contained in:
parent
36537366f6
commit
5fb34a3741
@ -39,6 +39,7 @@ void spicestream_construct( SpiceStream *ss, char *filename, char *format, WaveT
|
|||||||
spicestream_read_rows, spicestream_destroy );
|
spicestream_read_rows, spicestream_destroy );
|
||||||
ss->filename = filename;
|
ss->filename = filename;
|
||||||
ss->format = format;
|
ss->format = format;
|
||||||
|
ss->idxcol = -1;
|
||||||
|
|
||||||
/* open file */
|
/* open file */
|
||||||
ss->linebuf = fdbuf_new ( filename, "r", 0);
|
ss->linebuf = fdbuf_new ( filename, "r", 0);
|
||||||
|
@ -71,6 +71,7 @@ struct _SpiceStream {
|
|||||||
int currow;
|
int currow;
|
||||||
/* some more variables for .wav */
|
/* some more variables for .wav */
|
||||||
int bps; /* bit per sample */
|
int bps; /* bit per sample */
|
||||||
|
int idxcol; // throw away any index column
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ int sf_rdhdr_ascii( SpiceStream *ss )
|
|||||||
* Process a header line from an ascii or cazm format file.
|
* Process a header line from an ascii or cazm format file.
|
||||||
* Returns a filled-in SpiceStream* with variable information.
|
* Returns a filled-in SpiceStream* with variable information.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ascii_process_header(SpiceStream *ss, char *line, VarType ivtype )
|
ascii_process_header(SpiceStream *ss, char *line, VarType ivtype )
|
||||||
{
|
{
|
||||||
char *signam;
|
char *signam;
|
||||||
@ -150,6 +150,16 @@ ascii_process_header(SpiceStream *ss, char *line, VarType ivtype )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (app_strcasestr(signam, "index") ) {
|
||||||
|
ss->idxcol = 0;
|
||||||
|
// Skip to next token in header
|
||||||
|
signam = strtok(NULL, " \t\n");
|
||||||
|
if ( ! signam) {
|
||||||
|
msg_error(_("line %d: syntax error in header"), fdbuf_get_lineno(ss->linebuf));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( ivtype == UNKNOWN) {
|
if ( ivtype == UNKNOWN) {
|
||||||
if (app_strcasestr(signam, "time") ) {
|
if (app_strcasestr(signam, "time") ) {
|
||||||
ivtype = TIME;
|
ivtype = TIME;
|
||||||
@ -202,6 +212,14 @@ int sf_readrow_ascii(SpiceStream *ss)
|
|||||||
return -2; /* blank line can indicate end of data */
|
return -2; /* blank line can indicate end of data */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip index column
|
||||||
|
if (ss->idxcol >= 0) {
|
||||||
|
tok = strtok(NULL, " \t\n");
|
||||||
|
if ( ! tok) {
|
||||||
|
return -2; /* blank line can indicate end of data */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check to see if it is numeric: ascii format is so loosly defined
|
* check to see if it is numeric: ascii format is so loosly defined
|
||||||
* that we might read a load of garbage otherwise.
|
* that we might read a load of garbage otherwise.
|
||||||
@ -237,10 +255,10 @@ void sf_write_file_ascii( FILE *fd, WaveTable *wt, char *fmt)
|
|||||||
char format[64];
|
char format[64];
|
||||||
WDataSet *wds = wavetable_get_dataset( wt, k);
|
WDataSet *wds = wavetable_get_dataset( wt, k);
|
||||||
WaveVar *var = g_ptr_array_index( wds->vars, 0);
|
WaveVar *var = g_ptr_array_index( wds->vars, 0);
|
||||||
// double min = wavevar_val_get_min(var);
|
// double min = wavevar_val_get_min(var);
|
||||||
// double max = wavevar_val_get_max(var);
|
// double max = wavevar_val_get_max(var);
|
||||||
|
|
||||||
// fprintf( stdout, "min %f, max %f\n", min, max);
|
// fprintf( stdout, "min %f, max %f\n", min, max);
|
||||||
|
|
||||||
for ( i = 0 ; i < wds->ncols ; i++ ){
|
for ( i = 0 ; i < wds->ncols ; i++ ){
|
||||||
var = g_ptr_array_index( wds->vars, i);
|
var = g_ptr_array_index( wds->vars, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user