X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwavesplit.cpp;h=f3dd3fd8bc7119c414a9077a05301e7a8ee4b502;hb=5584493c50cfa0541398527741253a0db8cdbf18;hp=f7030ca1d8ca3e4c9a18ad190d39a992a4ab2798;hpb=4ca942b397d1e6ff69b28aa01a5e5a250103463f;p=asdcplib.git diff --git a/src/wavesplit.cpp b/src/wavesplit.cpp index f7030ca..f3dd3fd 100755 --- a/src/wavesplit.cpp +++ b/src/wavesplit.cpp @@ -44,13 +44,13 @@ static const char* PROGRAM_NAME = "wavesplit"; // program name for messages // Macros used to test command option data state. // True if a major mode has already been selected. -#define TEST_MAJOR_MODE() ( create_flag ) +#define TEST_MAJOR_MODE() ( create_flag || info_flag ) // Causes the caller to return if a major mode has already been selected, // otherwise sets the given flag. #define TEST_SET_MAJOR_MODE(f) if ( TEST_MAJOR_MODE() ) \ { \ - fputs("Conflicting major mode, choose one of -(ic)).\n", stderr); \ + fputs("Conflicting major mode, choose one of -(ic).\n", stderr); \ return; \ } \ (f) = true; @@ -82,21 +82,23 @@ void usage(FILE* stream = stderr) { fprintf(stream, "\ -USAGE: %s [-i|-c [-v]] \n\ +USAGE: %s [-v] -V\n\ + %s [-v] -c [-d ] [-f ] \n\ + %s [-v] -i \n\ \n\ Major modes:\n\ - -c - Create a WAV file for each channel in the input file (default is two channel files)\n\ - -V - Show version\n\ - -h - Show help\n\ -\n\ -Read/Write Options:\n\ - -f - Starting frame number, default 0\n\ + -c - Create a WAV file for each channel in the input file\n\ + (default is two-channel files)\n\ -d - Number of frames to process, default all\n\ + -f - Starting frame number, default 0\n\ + -h - Show help\n\ + -i - Show input file metadata (no output created)\n\ + -V - Show version\n\ -v - Print extra info while processing\n\ \n\ NOTES: o There is no option grouping, all options must be distinct arguments.\n\ o All option arguments must be separated from the option by whitespace.\n\ -\n", PROGRAM_NAME); +\n", PROGRAM_NAME, PROGRAM_NAME, PROGRAM_NAME); } // @@ -108,6 +110,7 @@ class CommandOptions public: bool error_flag; // true if the given options are in error or not complete bool create_flag; // true if the file create mode was selected + bool info_flag; // true if the file info mode was selected bool version_flag; // true if the version display option was selected bool help_flag; // true if the help display option was selected bool verbose_flag; // true for extra info during procesing @@ -117,7 +120,7 @@ public: const char* filename; // filename to be processed CommandOptions(int argc, const char** argv) : - error_flag(true), create_flag(false), + error_flag(true), create_flag(false), info_flag(false), version_flag(false), help_flag(false), start_frame(0), duration(0xffffffff), file_root(0), filename(0) { @@ -127,23 +130,25 @@ public: { switch ( argv[i][1] ) { - case 'V': version_flag = true; break; - case 'h': help_flag = true; break; case 'c': TEST_SET_MAJOR_MODE(create_flag); TEST_EXTRA_ARG(i, 'c'); file_root = argv[i]; break; + case 'd': + TEST_EXTRA_ARG(i, 'd'); + duration = atoi(argv[i]); // TODO: test for negative value, should use strtol() + break; + case 'f': TEST_EXTRA_ARG(i, 'f'); start_frame = atoi(argv[i]); // TODO: test for negative value, should use strtol() break; - case 'd': - TEST_EXTRA_ARG(i, 'd'); - duration = atoi(argv[i]); // TODO: test for negative value, should use strtol() - break; + case 'h': help_flag = true; break; + case 'i': TEST_SET_MAJOR_MODE(info_flag); break; + case 'V': version_flag = true; break; default: fprintf(stderr, "Unrecognized option: %c\n", argv[i][1]); @@ -181,8 +186,30 @@ public: } }; - // +Result_t +wav_file_info(CommandOptions& Options) +{ + PCM::AudioDescriptor ADesc; + Rational PictureRate = EditRate_24; + PCM::WAVParser Parser; + + // set up essence parser + Result_t result = Parser.OpenRead(Options.filename, PictureRate); + + if ( ASDCP_SUCCESS(result) ) + { + Parser.FillAudioDescriptor(ADesc); + ADesc.EditRate = PictureRate; + fprintf(stderr, "48Khz PCM Audio, %s fps (%u spf)\n", "24", + PCM::CalcSamplesPerFrame(ADesc)); + fputs("AudioDescriptor:\n", stderr); + PCM::AudioDescriptorDump(ADesc); + } + + return result; +} + // void split_buffer(ui32_t sample_size, PCM::FrameBuffer& FrameBuffer, @@ -208,8 +235,6 @@ split_buffer(ui32_t sample_size, PCM::FrameBuffer& FrameBuffer, R_FrameBuffer.Size(R_FrameBuffer.Capacity()); } - -// // Result_t split_wav_file(CommandOptions& Options) @@ -228,7 +253,7 @@ split_wav_file(CommandOptions& Options) { Parser.FillAudioDescriptor(ADesc); - ADesc.SampleRate = PictureRate; + ADesc.EditRate = PictureRate; ui32_t fb_size = PCM::CalcFrameBufferSize(ADesc); assert((fb_size % 2) == 0); FrameBuffer.Capacity(fb_size); @@ -346,7 +371,10 @@ main(int argc, const char** argv) if ( Options.version_flag ) banner(); - if ( Options.create_flag ) + if ( Options.info_flag ) + result = wav_file_info(Options); + + else if ( Options.create_flag ) result = split_wav_file(Options); if ( result != RESULT_OK )