programs/sndfile-info.c : Add ability to dump the cart chunk.

This commit is contained in:
Erik de Castro Lopo 2013-02-11 19:23:20 +11:00
parent e866561923
commit dcc3c85c84

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** All rights reserved.
**
@ -54,6 +54,7 @@ static void info_dump (const char *filename) ;
static int instrument_dump (const char *filename) ;
static int broadcast_dump (const char *filename) ;
static int chanmap_dump (const char *filename) ;
static int cart_dump (const char *filename) ;
static void total_dump (void) ;
static double total_seconds = 0.0 ;
@ -69,7 +70,7 @@ main (int argc, char *argv [])
return 1 ;
} ;
if (strcmp (argv [1], "-i") == 0)
if (strcmp (argv [1], "--instrument") == 0)
{ int error = 0 ;
for (k = 2 ; k < argc ; k++)
@ -77,7 +78,7 @@ main (int argc, char *argv [])
return error ;
} ;
if (strcmp (argv [1], "-b") == 0)
if (strcmp (argv [1], "--broadcast") == 0)
{ int error = 0 ;
for (k = 2 ; k < argc ; k++)
@ -85,7 +86,7 @@ main (int argc, char *argv [])
return error ;
} ;
if (strcmp (argv [1], "-c") == 0)
if (strcmp (argv [1], "--channel-map") == 0)
{ int error = 0 ;
for (k = 2 ; k < argc ; k++)
@ -93,6 +94,14 @@ main (int argc, char *argv [])
return error ;
} ;
if (strcmp (argv [1], "--cart") == 0)
{ int error = 0 ;
for (k = 2 ; k < argc ; k++)
error += cart_dump (argv [k]) ;
return error ;
} ;
for (k = 1 ; k < argc ; k++)
info_dump (argv [k]) ;
@ -121,10 +130,14 @@ static void
usage_exit (const char *progname)
{ printf ("Usage :\n %s <file> ...\n", progname) ;
printf (" Prints out information about one or more sound files.\n\n") ;
printf (" %s -i <file>\n", progname) ;
printf (" %s --instrument <file>\n", progname) ;
printf (" Prints out the instrument data for the given file.\n\n") ;
printf (" %s -b <file>\n", progname) ;
printf (" %s --broadcast <file>\n", progname) ;
printf (" Prints out the broadcast WAV info for the given file.\n\n") ;
printf (" %s --channel-map <file>\n", progname) ;
printf (" Prints out the channel map for the given file.\n\n") ;
printf (" %s --cart <file>\n", progname) ;
printf (" Prints out the cart chunk WAV info for the given file.\n\n") ;
#if (defined (_WIN32) || defined (WIN32))
printf ("This is a Unix style command line application which\n"
"should be run in a MSDOS box or Command Shell window.\n\n") ;
@ -138,7 +151,6 @@ usage_exit (const char *progname)
*/
Sleep (5 * 1000) ;
#endif
printf ("Using %s.\n\n", sf_version_string ()) ;
exit (0) ;
} /* usage_exit */
@ -456,6 +468,60 @@ chanmap_dump (const char *filename)
return 0 ;
} /* chanmap_dump */
static int
cart_dump (const char *filename)
{ SNDFILE *file ;
SF_INFO sfinfo ;
SF_CART_INFO_VAR (1024) cart ;
int got_cart, k ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
memset (&cart, 0, sizeof (cart)) ;
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
{ printf ("Error : Not able to open input file %s.\n", filename) ;
fflush (stdout) ;
memset (data, 0, sizeof (data)) ;
puts (sf_strerror (NULL)) ;
return 1 ;
} ;
got_cart = sf_command (file, SFC_GET_CART_INFO, &cart, sizeof (cart)) ;
sf_close (file) ;
if (got_cart == SF_FALSE)
{ printf ("Error : File '%s' does not contain cart information.\n\n", filename) ;
return 1 ;
} ;
printf ("Version : %.*s\n", (int) sizeof (cart.version), cart.version) ;
printf ("Title : %.*s\n", (int) sizeof (cart.title), cart.title) ;
printf ("Artist : %.*s\n", (int) sizeof (cart.artist), cart.artist) ;
printf ("Cut id : %.*s\n", (int) sizeof (cart.cut_id), cart.cut_id) ;
printf ("Category : %.*s\n", (int) sizeof (cart.category), cart.category) ;
printf ("Classification : %.*s\n", (int) sizeof (cart.classification), cart.classification) ;
printf ("Out cue : %.*s\n", (int) sizeof (cart.out_cue), cart.out_cue) ;
printf ("Start date : %.*s\n", (int) sizeof (cart.start_date), cart.start_date) ;
printf ("Start time : %.*s\n", (int) sizeof (cart.start_time), cart.start_time) ;
printf ("End date : %.*s\n", (int) sizeof (cart.end_date), cart.end_date) ;
printf ("End time : %.*s\n", (int) sizeof (cart.end_time), cart.end_time) ;
printf ("App id : %.*s\n", (int) sizeof (cart.producer_app_id), cart.producer_app_id) ;
printf ("App version : %.*s\n", (int) sizeof (cart.producer_app_version), cart.producer_app_version) ;
printf ("User defined : %.*s\n", (int) sizeof (cart.user_def), cart.user_def) ;
printf ("Level ref. : %d\n", cart.level_reference) ;
printf ("Post timers :\n") ;
for (k = 0 ; k < ARRAY_LEN (cart.post_timers) ; k++)
if (cart.post_timers [k].usage [0])
printf (" %d %.*s %d\n", k, (int) sizeof (cart.post_timers [k].usage), cart.post_timers [k].usage, cart.post_timers [k].value) ;
printf ("Reserved : %.*s\n", (int) sizeof (cart.reserved), cart.reserved) ;
printf ("Url : %.*s\n", (int) sizeof (cart.url), cart.url) ;
printf ("Tag text : %.*s\n", cart.tag_text_size, cart.tag_text) ;
return 0 ;
} /* cart_dump */
static void
total_dump (void)
{ printf ("========================================\n") ;