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-2017 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. * |
142 |
} |
} |
143 |
|
|
144 |
void PrintFileInformations(gig::File* gig) { |
void PrintFileInformations(gig::File* gig) { |
145 |
cout << "Global File Informations:" << endl; |
cout << "Global File Information:" << endl; |
146 |
cout << " Total instruments: " << gig->Instruments << endl; |
cout << " Total instruments: " << gig->Instruments << endl; |
147 |
if (gig->pVersion) { |
if (gig->pVersion) { |
148 |
cout << " Version: " << gig->pVersion->major << "." |
cout << " Version: " << gig->pVersion->major << "." |
228 |
cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd; |
cout << ", LoopFraction=" << pSample->LoopFraction << ", Start=" << pSample->LoopStart << ", End=" << pSample->LoopEnd; |
229 |
cout << ", LoopPlayCount=" << pSample->LoopPlayCount; |
cout << ", LoopPlayCount=" << pSample->LoopPlayCount; |
230 |
} |
} |
231 |
|
cout << flush; |
232 |
|
printf(", crc=%x", pSample->GetWaveDataCRC32Checksum()); |
233 |
|
fflush(stdout); |
234 |
cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") |
cout << ", Length=" << pSample->SamplesTotal << " Compressed=" << ((pSample->Compressed) ? "true" : "false") |
235 |
<< " foffset=" << pSample->pCkData->GetFilePos() |
<< " foffset=" << pSample->pCkData->GetFilePos() |
236 |
<< " fsz=" << pSample->pCkData->GetSize() |
<< " fsz=" << pSample->pCkData->GetSize() |
508 |
cout << endl; |
cout << endl; |
509 |
} |
} |
510 |
#endif |
#endif |
511 |
cout << " Pan=" << (int) pDimensionRegion->Pan << endl; |
gig::eg_opt_t& egopt = pDimensionRegion->EGOptions; |
512 |
|
cout << " Pan=" << (int) pDimensionRegion->Pan << ", EGAttackCancel=" << egopt.AttackCancel << ", EGAttackHoldCancel=" << egopt.AttackHoldCancel << ", EGDecay1Cancel=" << egopt.Decay1Cancel << ", EGDecay2Cancel=" << egopt.Decay2Cancel << ", EGReleaseCancel=" << egopt.ReleaseCancel << endl; |
513 |
|
|
514 |
dimensionRegions++; |
dimensionRegions++; |
515 |
} |
} |
516 |
} |
} |
517 |
|
|
518 |
|
struct _FailedSample { |
519 |
|
gig::Sample* sample; |
520 |
|
uint32_t calculatedCRC; |
521 |
|
}; |
522 |
|
|
523 |
bool VerifyFile(gig::File* _gig) { |
bool VerifyFile(gig::File* _gig) { |
524 |
PubFile* gig = (PubFile*) _gig; |
PubFile* gig = (PubFile*) _gig; |
525 |
|
|
532 |
cout << "OK\n" << flush; |
cout << "OK\n" << flush; |
533 |
|
|
534 |
cout << "Verifying samples ... " << flush; |
cout << "Verifying samples ... " << flush; |
535 |
std::map<int,gig::Sample*> failedSamples; |
std::map<int,_FailedSample> failedSamples; |
536 |
int iTotal = 0; |
int iTotal = 0; |
537 |
for (gig::Sample* pSample = gig->GetFirstSample(); pSample; pSample = gig->GetNextSample(), ++iTotal) { |
for (gig::Sample* pSample = gig->GetFirstSample(); pSample; pSample = gig->GetNextSample(), ++iTotal) { |
538 |
if (!pSample->VerifyWaveData()) |
uint32_t crc; // will be set to the actually now calculated checksum |
539 |
failedSamples[iTotal] = pSample; |
if (!pSample->VerifyWaveData(&crc)) { |
540 |
|
_FailedSample failed; |
541 |
|
failed.sample = pSample; |
542 |
|
failed.calculatedCRC = crc; |
543 |
|
failedSamples[iTotal] = failed; |
544 |
|
} |
545 |
} |
} |
546 |
if (failedSamples.empty()) { |
if (failedSamples.empty()) { |
547 |
cout << "ALL OK\n"; |
cout << "ALL OK\n"; |
548 |
return true; |
return true; |
549 |
} else { |
} else { |
550 |
cout << failedSamples.size() << " of " << iTotal << " Samples DAMAGED:\n"; |
cout << failedSamples.size() << " of " << iTotal << " Samples DAMAGED:\n"; |
551 |
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) { |
552 |
const int i = it->first; |
const int i = it->first; |
553 |
gig::Sample* pSample = it->second; |
gig::Sample* pSample = it->second.sample; |
554 |
|
|
555 |
string name = pSample->pInfo->Name; |
string name = pSample->pInfo->Name; |
556 |
if (name == "") name = "<NO NAME>"; |
if (name == "") name = "<NO NAME>"; |
557 |
else name = '\"' + name + '\"'; |
else name = '\"' + name + '\"'; |
558 |
|
|
559 |
cout << "Damaged Sample " << (i+1) << ") " << name << endl; |
cout << "Damaged Sample " << (i+1) << ") " << name << flush; |
560 |
|
printf(" expectedCRC=%x calculatedCRC=%x\n", pSample->GetWaveDataCRC32Checksum(), it->second.calculatedCRC); |
561 |
} |
} |
562 |
return false; |
return false; |
563 |
} |
} |