2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2016 by Christian Schoenebeck * |
* Copyright (C) 2003-2018 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This program is part of libgig. * |
* This program is part of libgig. * |
37 |
|
|
38 |
string Revision(); |
string Revision(); |
39 |
void PrintVersion(); |
void PrintVersion(); |
40 |
void PrintFileInformations(gig::File* gig); |
void PrintFileInformation(gig::File* gig); |
41 |
void PrintGroups(gig::File* gig); |
void PrintGroups(gig::File* gig); |
42 |
void PrintSamples(gig::File* gig); |
void PrintSamples(gig::File* gig); |
43 |
void PrintScripts(gig::File* gig); |
void PrintScripts(gig::File* gig); |
44 |
void PrintInstruments(gig::File* gig); |
void PrintInstruments(gig::File* gig); |
45 |
|
void PrintInstrumentNamesOnly(gig::File* gig); |
46 |
void PrintRegions(gig::Instrument* instr); |
void PrintRegions(gig::Instrument* instr); |
47 |
void PrintUsage(); |
void PrintUsage(); |
48 |
void PrintDimensionRegions(gig::Region* rgn); |
void PrintDimensionRegions(gig::Region* rgn); |
65 |
{ |
{ |
66 |
bool bVerify = false; |
bool bVerify = false; |
67 |
bool bRebuildChecksums = false; |
bool bRebuildChecksums = false; |
68 |
|
bool bInstrumentNamesOnly = false; |
69 |
|
|
70 |
if (argc <= 1) { |
if (argc <= 1) { |
71 |
PrintUsage(); |
PrintUsage(); |
88 |
bVerify = true; |
bVerify = true; |
89 |
} else if (opt == "--rebuild-checksums") { |
} else if (opt == "--rebuild-checksums") { |
90 |
bRebuildChecksums = true; |
bRebuildChecksums = true; |
91 |
|
} else if (opt == "--instrument-names") { |
92 |
|
bInstrumentNamesOnly = true; |
93 |
} else { |
} else { |
94 |
cerr << "Unknown option '" << opt << "'" << endl; |
cerr << "Unknown option '" << opt << "'" << endl; |
95 |
cerr << endl; |
cerr << endl; |
120 |
if (OK) cout << "All checks passed successfully! :-)\n"; |
if (OK) cout << "All checks passed successfully! :-)\n"; |
121 |
return (OK) ? EXIT_SUCCESS : EXIT_FAILURE; |
return (OK) ? EXIT_SUCCESS : EXIT_FAILURE; |
122 |
} else { |
} else { |
123 |
PrintFileInformations(gig); |
if (bInstrumentNamesOnly) { |
124 |
cout << endl; |
PrintInstrumentNamesOnly(gig); |
125 |
PrintGroups(gig); |
} else { |
126 |
cout << endl; |
PrintFileInformation(gig); |
127 |
PrintSamples(gig); |
cout << endl; |
128 |
cout << endl; |
PrintGroups(gig); |
129 |
PrintScripts(gig); |
cout << endl; |
130 |
cout << endl; |
PrintSamples(gig); |
131 |
PrintInstruments(gig); |
cout << endl; |
132 |
|
PrintScripts(gig); |
133 |
|
cout << endl; |
134 |
|
PrintInstruments(gig); |
135 |
|
} |
136 |
} |
} |
137 |
delete gig; |
delete gig; |
138 |
delete riff; |
delete riff; |
149 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
150 |
} |
} |
151 |
|
|
152 |
void PrintFileInformations(gig::File* gig) { |
void PrintFileInformation(gig::File* gig) { |
153 |
cout << "Global File Informations:" << endl; |
cout << "Global File Information:" << endl; |
154 |
cout << " Total instruments: " << gig->Instruments << endl; |
cout << " Total instruments: " << gig->Instruments << endl; |
155 |
if (gig->pVersion) { |
if (gig->pVersion) { |
156 |
cout << " Version: " << gig->pVersion->major << "." |
cout << " Version: " << gig->pVersion->major << "." |
236 |
cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd; |
cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd; |
237 |
cout << ", LoopPlayCount=" << pSample->LoopPlayCount; |
cout << ", LoopPlayCount=" << pSample->LoopPlayCount; |
238 |
} |
} |
239 |
|
cout << flush; |
240 |
|
printf(", crc=%x", pSample->GetWaveDataCRC32Checksum()); |
241 |
|
fflush(stdout); |
242 |
cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") |
cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") |
243 |
<< " foffset=" << pSample->pCkData->GetFilePos() |
<< " foffset=" << pSample->pCkData->GetFilePos() |
244 |
<< " fsz=" << pSample->pCkData->GetSize() |
<< " fsz=" << pSample->pCkData->GetSize() |
302 |
} |
} |
303 |
} |
} |
304 |
|
|
305 |
|
void PrintInstrumentNamesOnly(gig::File* gig) { |
306 |
|
int instruments = 0; |
307 |
|
gig::Instrument* pInstrument = gig->GetFirstInstrument(); |
308 |
|
for (; pInstrument; pInstrument = gig->GetNextInstrument()) { |
309 |
|
instruments++; |
310 |
|
string name = pInstrument->pInfo->Name; |
311 |
|
if (name == "") name = "<NO NAME>"; |
312 |
|
else name = '\"' + name + '\"'; |
313 |
|
cout << "Instrument " << instruments << ") " << name << endl; |
314 |
|
} |
315 |
|
} |
316 |
|
|
317 |
void PrintRegions(gig::Instrument* instr) { |
void PrintRegions(gig::Instrument* instr) { |
318 |
int iRegion = 1; |
int iRegion = 1; |
319 |
gig::Region* pRegion = instr->GetFirstRegion(); |
gig::Region* pRegion = instr->GetFirstRegion(); |
528 |
cout << endl; |
cout << endl; |
529 |
} |
} |
530 |
#endif |
#endif |
531 |
cout << " Pan=" << (int) pDimensionRegion->Pan << endl; |
cout << " Pan=" << (int) pDimensionRegion->Pan; |
532 |
|
cout << ", SustainReleaseTrigger="; |
533 |
|
switch (pDimensionRegion->SustainReleaseTrigger) { |
534 |
|
case gig::sust_rel_trg_none: |
535 |
|
cout << "NONE"; |
536 |
|
break; |
537 |
|
case gig::sust_rel_trg_maxvelocity: |
538 |
|
cout << "MAXVELOCITY"; |
539 |
|
break; |
540 |
|
case gig::sust_rel_trg_keyvelocity: |
541 |
|
cout << "KEYVELOCITY"; |
542 |
|
break; |
543 |
|
} |
544 |
|
cout << ", NoNoteOffReleaseTrigger=" << int(pDimensionRegion->NoNoteOffReleaseTrigger); |
545 |
|
cout << endl; |
546 |
|
{ |
547 |
|
gig::eg_opt_t& egopt = pDimensionRegion->EG1Options; |
548 |
|
cout << " EG1AttackCancel=" << egopt.AttackCancel << ", EG1AttackHoldCancel=" << egopt.AttackHoldCancel << ", EG1Decay1Cancel=" << egopt.Decay1Cancel << ", EG1Decay2Cancel=" << egopt.Decay2Cancel << ", EG1ReleaseCancel=" << egopt.ReleaseCancel << endl; |
549 |
|
} |
550 |
|
{ |
551 |
|
gig::eg_opt_t& egopt = pDimensionRegion->EG2Options; |
552 |
|
cout << " EG2AttackCancel=" << egopt.AttackCancel << ", EG2AttackHoldCancel=" << egopt.AttackHoldCancel << ", EG2Decay1Cancel=" << egopt.Decay1Cancel << ", EG2Decay2Cancel=" << egopt.Decay2Cancel << ", EG2ReleaseCancel=" << egopt.ReleaseCancel << endl; |
553 |
|
} |
554 |
|
|
555 |
dimensionRegions++; |
dimensionRegions++; |
556 |
} |
} |
557 |
} |
} |
558 |
|
|
559 |
|
struct _FailedSample { |
560 |
|
gig::Sample* sample; |
561 |
|
uint32_t calculatedCRC; |
562 |
|
}; |
563 |
|
|
564 |
bool VerifyFile(gig::File* _gig) { |
bool VerifyFile(gig::File* _gig) { |
565 |
PubFile* gig = (PubFile*) _gig; |
PubFile* gig = (PubFile*) _gig; |
566 |
|
|
573 |
cout << "OK\n" << flush; |
cout << "OK\n" << flush; |
574 |
|
|
575 |
cout << "Verifying samples ... " << flush; |
cout << "Verifying samples ... " << flush; |
576 |
std::map<int,gig::Sample*> failedSamples; |
std::map<int,_FailedSample> failedSamples; |
577 |
int iTotal = 0; |
int iTotal = 0; |
578 |
for (gig::Sample* pSample = gig->GetFirstSample(); pSample; pSample = gig->GetNextSample(), ++iTotal) { |
for (gig::Sample* pSample = gig->GetFirstSample(); pSample; pSample = gig->GetNextSample(), ++iTotal) { |
579 |
if (!pSample->VerifyWaveData()) |
uint32_t crc; // will be set to the actually now calculated checksum |
580 |
failedSamples[iTotal] = pSample; |
if (!pSample->VerifyWaveData(&crc)) { |
581 |
|
_FailedSample failed; |
582 |
|
failed.sample = pSample; |
583 |
|
failed.calculatedCRC = crc; |
584 |
|
failedSamples[iTotal] = failed; |
585 |
|
} |
586 |
} |
} |
587 |
if (failedSamples.empty()) { |
if (failedSamples.empty()) { |
588 |
cout << "ALL OK\n"; |
cout << "ALL OK\n"; |
589 |
return true; |
return true; |
590 |
} else { |
} else { |
591 |
cout << failedSamples.size() << " of " << iTotal << " Samples DAMAGED:\n"; |
cout << failedSamples.size() << " of " << iTotal << " Samples DAMAGED:\n"; |
592 |
for (std::map<int,gig::Sample*>::iterator it = failedSamples.begin(); it != failedSamples.end(); ++it) { |
for (std::map<int,_FailedSample>::iterator it = failedSamples.begin(); it != failedSamples.end(); ++it) { |
593 |
const int i = it->first; |
const int i = it->first; |
594 |
gig::Sample* pSample = it->second; |
gig::Sample* pSample = it->second.sample; |
595 |
|
|
596 |
string name = pSample->pInfo->Name; |
string name = pSample->pInfo->Name; |
597 |
if (name == "") name = "<NO NAME>"; |
if (name == "") name = "<NO NAME>"; |
598 |
else name = '\"' + name + '\"'; |
else name = '\"' + name + '\"'; |
599 |
|
|
600 |
cout << "Damaged Sample " << (i+1) << ") " << name << endl; |
cout << "Damaged Sample " << (i+1) << ") " << name << flush; |
601 |
|
printf(" expectedCRC=%x calculatedCRC=%x\n", pSample->GetWaveDataCRC32Checksum(), it->second.calculatedCRC); |
602 |
} |
} |
603 |
return false; |
return false; |
604 |
} |
} |
639 |
cout << endl; |
cout << endl; |
640 |
cout << " --verify Checks raw wave data integrity of all samples." << endl; |
cout << " --verify Checks raw wave data integrity of all samples." << endl; |
641 |
cout << endl; |
cout << endl; |
642 |
|
cout << " --instrument-names Print only instrument names." << endl; |
643 |
|
cout << endl; |
644 |
} |
} |