Esempio n. 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);
	}
}
Esempio n. 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);
	}
}
Esempio n. 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);
  }
}