/[svn]/libgig/trunk/src/tools/wav2gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/tools/wav2gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3993 by schoenebeck, Thu Sep 2 15:34:11 2021 UTC revision 3994 by schoenebeck, Thu Sep 2 16:22:36 2021 UTC
# Line 416  static gig::Sample* createSample(gig::Fi Line 416  static gig::Sample* createSample(gig::Fi
416      s->FrameSize = s->Channels * s->BitDepth / 8;      s->FrameSize = s->Channels * s->BitDepth / 8;
417    
418      if (bVerbose) {      if (bVerbose) {
419          cout << "\t" << s->BitDepth << " Bits "          cout << "\t" << s->BitDepth << " Bits, "
420               << s->SamplesPerSecond << " Hz "               << s->SamplesPerSecond << " Hz, "
421               << s->Channels << " Channels"               << s->Channels << " Channels"
422               << endl;               << " [Source: .WAV File Content]" << endl;
423      }      }
424    
425      if (wav->hasSfInst) {      if (wav->hasSfInst) {
# Line 427  static gig::Sample* createSample(gig::Fi Line 427  static gig::Sample* createSample(gig::Fi
427          s->FineTune      = wav->sfinst.detune;          s->FineTune      = wav->sfinst.detune;
428          if (bVerbose) {          if (bVerbose) {
429              cout << "\tRoot Note " << s->MIDIUnityNote              cout << "\tRoot Note " << s->MIDIUnityNote
430                  << " [Source: .WAV Internal Content]" << endl;                   << " [Source: .WAV File Content]" << endl;
431              cout << "\tFine Tune " << s->FineTune << endl;              cout << "\tFine Tune " << s->FineTune
432                     << " [Source: .WAV File Content]" << endl;
433          }          }
434          if (wav->sfinst.loop_count && wav->sfinst.loops[0].mode != SF_LOOP_NONE) {          if (wav->sfinst.loop_count && wav->sfinst.loops[0].mode != SF_LOOP_NONE) {
435              s->Loops = 1;              s->Loops = 1;
# Line 461  static gig::Sample* createSample(gig::Fi Line 462  static gig::Sample* createSample(gig::Fi
462          s->MIDIUnityNote = wav->note;          s->MIDIUnityNote = wav->note;
463          cout << "\tRoot Note " << s->MIDIUnityNote << " [Source: .WAV Filename Schema]" << endl;          cout << "\tRoot Note " << s->MIDIUnityNote << " [Source: .WAV Filename Schema]" << endl;
464      }      }
465        cout << "\tVelocity " << wav->velocity
466             << " [Source: .WAV Filename Schema]" << endl;
467        cout << "\tRegion " << wav->note
468             << " [Source: .WAV Filename Schema]" << endl;
469    
470      // schedule for resize (will be performed when gig->Save() is called)      // schedule for resize (will be performed when gig->Save() is called)
471      s->Resize(wav->sfinfo.frames);      s->Resize(wav->sfinfo.frames);
# Line 473  int main(int argc, char *argv[]) { Line 478  int main(int argc, char *argv[]) {
478      bool bRecursive = false;      bool bRecursive = false;
479      bool bDryRun = false;      bool bDryRun = false;
480      bool bVerbose = false;      bool bVerbose = false;
481        // using C++11 raw string literals for the RegEx patterns here to avoid
482        // having to double escape special characters inside the RegEx patterns
483      FilenameRegExPatterns patterns = {      FilenameRegExPatterns patterns = {
484          // name 1 (e.g. "BSTEIN18")          // name 1 (e.g. "BSTEIN18")
485          .name1 = "^([^-]+) - [^-]+ - [^-]+ - [^-]+ - [^.]+",          .name1 = R"RegEx(([^-\/\\]+) - [^-]+ - [^-]+ - [^-]+ - [^.]+)RegEx",
486          // name 2 (e.g. "noname")          // name 2 (e.g. "noname")
487          .name2 = "^[^-]+ - ([^-]+) - [^-]+ - [^-]+ - [^.]+",          .name2 = R"RegEx([^-\/\\]+ - ([^-]+) - [^-]+ - [^-]+ - [^.]+)RegEx",
488          // velocity value (e.g. "18")          // velocity value (e.g. "18")
489          .velocityNr = "^[^-]+ - [^-]+ - ([^-]+) - [^-]+ - [^.]+",          .velocityNr = R"RegEx([^-\/\\]+ - [^-]+ - ([^-]+) - [^-]+ - [^.]+)RegEx",
490          // note number (e.g. "021")          // note number (e.g. "021")
491          .noteNr = "^[^-]+ - [^-]+ - [^-]+ - ([^-]+) - [^.]+",          .noteNr = R"RegEx([^-\/\\]+ - [^-]+ - [^-]+ - ([^-]+) - [^.]+)RegEx",
492          // note name (e.g. "a-1")          // note name (e.g. "a-1")
493          .noteName = "^[^-]+ - [^-]+ - [^-]+ - [^-]+ - ([^.]+)",          .noteName = R"RegEx([^-\/\\]+ - [^-]+ - [^-]+ - [^-]+ - ([^.]+))RegEx",
494      };      };
495    
496      // validate & parse arguments provided to this program      // validate & parse arguments provided to this program
# Line 514  int main(int argc, char *argv[]) { Line 521  int main(int argc, char *argv[]) {
521                  return EXIT_FAILURE;                  return EXIT_FAILURE;
522              }              }
523              patterns.name1 = nextOpt;              patterns.name1 = nextOpt;
524                ++iArg;
525          } else if (opt == "--regex-name2") {          } else if (opt == "--regex-name2") {
526              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {
527                  cerr << "Missing argument for option '" << opt << "'" << endl;                  cerr << "Missing argument for option '" << opt << "'" << endl;
528                  return EXIT_FAILURE;                  return EXIT_FAILURE;
529              }              }
530              patterns.name2 = nextOpt;              patterns.name2 = nextOpt;
531                ++iArg;
532          } else if (opt == "--regex-velocity-nr") {          } else if (opt == "--regex-velocity-nr") {
533              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {
534                  cerr << "Missing argument for option '" << opt << "'" << endl;                  cerr << "Missing argument for option '" << opt << "'" << endl;
535                  return EXIT_FAILURE;                  return EXIT_FAILURE;
536              }              }
537              patterns.velocityNr = nextOpt;              patterns.velocityNr = nextOpt;
538                ++iArg;
539          } else if (opt == "--regex-note-nr") {          } else if (opt == "--regex-note-nr") {
540              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {
541                  cerr << "Missing argument for option '" << opt << "'" << endl;                  cerr << "Missing argument for option '" << opt << "'" << endl;
542                  return EXIT_FAILURE;                  return EXIT_FAILURE;
543              }              }
544              patterns.noteNr = nextOpt;              patterns.noteNr = nextOpt;
545                ++iArg;
546          } else if (opt == "--regex-note-name") {          } else if (opt == "--regex-note-name") {
547              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {              if (nextOpt.empty() || beginsWith(nextOpt, "-")) {
548                  cerr << "Missing argument for option '" << opt << "'" << endl;                  cerr << "Missing argument for option '" << opt << "'" << endl;
549                  return EXIT_FAILURE;                  return EXIT_FAILURE;
550              }              }
551              patterns.noteName = nextOpt;              patterns.noteName = nextOpt;
552                ++iArg;
553          } else {          } else {
554              cerr << "Unknown option '" << opt << "'" << endl;              cerr << "Unknown option '" << opt << "'" << endl;
555              cerr << endl;              cerr << endl;

Legend:
Removed from v.3993  
changed lines
  Added in v.3994

  ViewVC Help
Powered by ViewVC