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() |
514 |
} |
} |
515 |
} |
} |
516 |
|
|
517 |
|
struct _FailedSample { |
518 |
|
gig::Sample* sample; |
519 |
|
uint32_t calculatedCRC; |
520 |
|
}; |
521 |
|
|
522 |
bool VerifyFile(gig::File* _gig) { |
bool VerifyFile(gig::File* _gig) { |
523 |
PubFile* gig = (PubFile*) _gig; |
PubFile* gig = (PubFile*) _gig; |
524 |
|
|
531 |
cout << "OK\n" << flush; |
cout << "OK\n" << flush; |
532 |
|
|
533 |
cout << "Verifying samples ... " << flush; |
cout << "Verifying samples ... " << flush; |
534 |
std::map<int,gig::Sample*> failedSamples; |
std::map<int,_FailedSample> failedSamples; |
535 |
int iTotal = 0; |
int iTotal = 0; |
536 |
for (gig::Sample* pSample = gig->GetFirstSample(); pSample; pSample = gig->GetNextSample(), ++iTotal) { |
for (gig::Sample* pSample = gig->GetFirstSample(); pSample; pSample = gig->GetNextSample(), ++iTotal) { |
537 |
if (!pSample->VerifyWaveData()) |
uint32_t crc; // will be set to the actually now calculated checksum |
538 |
failedSamples[iTotal] = pSample; |
if (!pSample->VerifyWaveData(&crc)) { |
539 |
|
_FailedSample failed; |
540 |
|
failed.sample = pSample; |
541 |
|
failed.calculatedCRC = crc; |
542 |
|
failedSamples[iTotal] = failed; |
543 |
|
} |
544 |
} |
} |
545 |
if (failedSamples.empty()) { |
if (failedSamples.empty()) { |
546 |
cout << "ALL OK\n"; |
cout << "ALL OK\n"; |
547 |
return true; |
return true; |
548 |
} else { |
} else { |
549 |
cout << failedSamples.size() << " of " << iTotal << " Samples DAMAGED:\n"; |
cout << failedSamples.size() << " of " << iTotal << " Samples DAMAGED:\n"; |
550 |
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) { |
551 |
const int i = it->first; |
const int i = it->first; |
552 |
gig::Sample* pSample = it->second; |
gig::Sample* pSample = it->second.sample; |
553 |
|
|
554 |
string name = pSample->pInfo->Name; |
string name = pSample->pInfo->Name; |
555 |
if (name == "") name = "<NO NAME>"; |
if (name == "") name = "<NO NAME>"; |
556 |
else name = '\"' + name + '\"'; |
else name = '\"' + name + '\"'; |
557 |
|
|
558 |
cout << "Damaged Sample " << (i+1) << ") " << name << endl; |
cout << "Damaged Sample " << (i+1) << ") " << name << flush; |
559 |
|
printf(" expectedCRC=%x calculatedCRC=%x\n", pSample->GetWaveDataCRC32Checksum(), it->second.calculatedCRC); |
560 |
} |
} |
561 |
return false; |
return false; |
562 |
} |
} |