Exemple #1
0
void VGMColl::UnpackSampColl(DLSFile& dls, VGMSampColl* sampColl, vector<VGMSamp*>& finalSamps)
{
	assert(sampColl != NULL);

	size_t nSamples = sampColl->samples.size();
	for (size_t i=0; i<nSamples; i++)
	{
		VGMSamp* samp = sampColl->samples[i];

		uint32_t bufSize;
		if (samp->ulUncompressedSize)
			bufSize = samp->ulUncompressedSize;
		else
			bufSize = (uint32_t)ceil((double)samp->dataLength * samp->GetCompressionRatio());
		//bool bOddBufSize = bufSize % 2;
		//if (bOddBufSize)				//if the buffer size is odd, we must align it to be even for the RIFF format
		//	bufSize++;
		uint8_t* uncompSampBuf = new uint8_t[bufSize];	//create a new memory space for the uncompressed wave
		samp->ConvertToStdWave(uncompSampBuf);			//and uncompress into that space
		//if (bOddBufSize)
		//	uncompSampBuf[bufSize] = 0;		//set the last (should be unused) byte to 0;

		uint16_t blockAlign = samp->bps / 8*samp->channels;
		dls.AddWave(1, samp->channels, samp->rate, samp->rate*blockAlign, blockAlign,
			samp->bps, bufSize, uncompSampBuf, wstring2string(samp->name));
		finalSamps.push_back(samp);
	}
}
Exemple #2
0
void VGMColl::UnpackSampColl(SynthFile& synthfile, VGMSampColl* sampColl, vector<VGMSamp*>& finalSamps)
{
	assert(sampColl != NULL);

	size_t nSamples = sampColl->samples.size();
	for (size_t i=0; i<nSamples; i++)
	{
		VGMSamp* samp = sampColl->samples[i];

		uint32_t bufSize;
		if (samp->ulUncompressedSize)
			bufSize = samp->ulUncompressedSize;
		else
			bufSize = (uint32_t)ceil((double)samp->dataLength * samp->GetCompressionRatio());
		//bool bOddBufSize = bufSize % 2;
		//if (bOddBufSize)				//if the buffer size is odd, we must align it to be even for the RIFF format
		//	bufSize++;
		uint8_t* uncompSampBuf = new uint8_t[bufSize];	//create a new memory space for the uncompressed wave
		samp->ConvertToStdWave(uncompSampBuf);			//and uncompress into that space
		//if (bOddBufSize)
		//	uncompSampBuf[bufSize] = 0;		//set the last (should be unused) byte to 0;

		uint16_t blockAlign = samp->bps / 8*samp->channels;
		SynthWave* wave = synthfile.AddWave(1, samp->channels, samp->rate, samp->rate*blockAlign, blockAlign,
			samp->bps, bufSize, uncompSampBuf, wstring2string(samp->name));
		finalSamps.push_back(samp);

		// If we don't have any loop information, then don't create a sampInfo structure for the Wave
		if (samp->loop.loopStatus == -1)
			return;

		SynthSampInfo* sampInfo = wave->AddSampInfo();
		if (samp->bPSXLoopInfoPrioritizing)
		{
			if (samp->loop.loopStart != 0 || samp->loop.loopLength != 0)
				sampInfo->SetLoopInfo(samp->loop, samp);
		}
		else
			sampInfo->SetLoopInfo(samp->loop, samp);

		double attenuation = (samp->volume != -1) ? ConvertLogScaleValToAtten(samp->volume) : 0;
		uint8_t unityKey = (samp->unityKey != -1) ? samp->unityKey : 0x3C;
		short fineTune = samp->fineTune;
		sampInfo->SetPitchInfo(unityKey, fineTune, attenuation);
	}
}
Exemple #3
0
void VGMColl::UnpackSampColl(DLSFile &dls, VGMSampColl *sampColl, vector<VGMSamp *> &finalSamps) {
  assert(sampColl != NULL);

  size_t nSamples = sampColl->samples.size();
  for (size_t i = 0; i < nSamples; i++) {
    VGMSamp *samp = sampColl->samples[i];

    uint32_t bufSize;
    if (samp->ulUncompressedSize)
      bufSize = samp->ulUncompressedSize;
    else
      bufSize = (uint32_t) ceil((double) samp->dataLength * samp->GetCompressionRatio());
    uint8_t *uncompSampBuf = new uint8_t[bufSize];    //create a new memory space for the uncompressed wave
    samp->ConvertToStdWave(uncompSampBuf);            //and uncompress into that space

    uint16_t blockAlign = samp->bps / 8 * samp->channels;
    dls.AddWave(1, samp->channels, samp->rate, samp->rate * blockAlign, blockAlign,
                samp->bps, bufSize, uncompSampBuf, wstring2string(samp->name));
    finalSamps.push_back(samp);
  }
}
Exemple #4
0
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;
}