bool QSoundSampColl::GetSampleInfo() { //QSoundInstrSet* instrset = (QSoundInstrSet*)instrset; uint32_t numSamples = instrset->sampInfoTable->numSamples; for (uint32_t i=0; i<numSamples; i++) { wostringstream name; name << L"Sample " << i; qs_samp_info* sampInfo = &sampInfoTable->infos[i]; uint32_t sampOffset = (sampInfo->bank<<16) + (sampInfo->start_addr_hi<<8) + sampInfo->start_addr_lo; int sampLength; if (sampInfo->end_addr_hi == 0 && sampInfo->end_addr_lo == 0) sampLength = ((sampInfo->bank+1)<<16) - sampOffset; else sampLength = (sampInfo->bank<<16) + (sampInfo->end_addr_hi<<8) + sampInfo->end_addr_lo - sampOffset; if (sampLength < 0) sampLength = -sampLength; //uint32_t loopOffset = (sampOffset+sampLength)-((sampInfo->bank<<16) + (sampInfo->loop_offset_hi<<8) + sampInfo->loop_offset_lo); uint32_t loopOffset = ((sampInfo->bank<<16) + (sampInfo->loop_offset_hi<<8) + sampInfo->loop_offset_lo) - sampOffset; if (loopOffset > (uint32_t)sampLength) loopOffset = sampLength; if (sampLength == 0 || sampOffset > unLength) break; VGMSamp* newSamp = AddSamp(sampOffset, sampLength, sampOffset, sampLength, 1, 8, 24000, name.str()); newSamp->SetWaveType(WT_PCM8); if ( sampLength - loopOffset < 40) newSamp->SetLoopStatus(false); else { newSamp->SetLoopStatus(true); newSamp->SetLoopOffset(loopOffset); newSamp->SetLoopLength(sampLength-loopOffset); newSamp->unityKey = sampInfo->unity_key; } } return true; }