|
From: <sv...@op...> - 2024-05-30 20:56:14
|
Author: sagamusix Date: Thu May 30 22:56:07 2024 New Revision: 20869 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20869 Log: [Mod] 8SVX: Add code to load a specific octave sample (currently unused). Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp ============================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp Thu May 30 22:54:12 2024 (r20868) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp Thu May 30 22:56:07 2024 (r20869) @@ -2560,7 +2560,7 @@ MPT_BINARY_STRUCT(IFFSampleHeader, 20) -bool CSoundFile::ReadIFFSample(SAMPLEINDEX nSample, FileReader &file, bool allowLittleEndian) +bool CSoundFile::ReadIFFSample(SAMPLEINDEX nSample, FileReader &file, bool allowLittleEndian, uint8 octave) { file.Rewind(); @@ -2651,6 +2651,18 @@ sampleRate = sampleHeader.samplesPerSec; volume = sampleHeader.volume; numSamples = mpt::saturate_cast<SmpLength>(sampleData.GetLength() / bytesPerFrame); + + if(octave < sampleHeader.octave) + { + numSamples = sampleHeader.oneShotHiSamples + sampleHeader.repeatHiSamples; + for(uint8 o = 0; o < octave; o++) + { + sampleData.Skip(numSamples * bytesPerSample * numChannels); + numSamples *= 2; + loopStart *= 2; + loopLength *= 2; + } + } } DestroySampleThreadsafe(nSample); Modified: trunk/OpenMPT/soundlib/Sndfile.h ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h Thu May 30 22:54:12 2024 (r20868) +++ trunk/OpenMPT/soundlib/Sndfile.h Thu May 30 22:56:07 2024 (r20869) @@ -1246,7 +1246,7 @@ bool ReadXISample(SAMPLEINDEX nSample, FileReader &file); bool ReadITSSample(SAMPLEINDEX nSample, FileReader &file, bool rewind = true); bool ReadITISample(SAMPLEINDEX nSample, FileReader &file); - bool ReadIFFSample(SAMPLEINDEX sample, FileReader &file, bool allowLittleEndian = true); + bool ReadIFFSample(SAMPLEINDEX sample, FileReader &file, bool allowLittleEndian = true, uint8 octave = uint8_max); bool ReadBRRSample(SAMPLEINDEX sample, FileReader &file); bool ReadFLACSample(SAMPLEINDEX sample, FileReader &file); bool ReadOpusSample(SAMPLEINDEX sample, FileReader &file); |