mirror of
https://github.com/AxioDL/amuse.git
synced 2025-12-09 05:27:57 +00:00
Add N64-VADPCM decoder; DSP-ADPCM seamless loop fix
This commit is contained in:
@@ -19,8 +19,8 @@ void AudioGroupSampleDirectory::Entry::swapBig()
|
||||
void AudioGroupSampleDirectory::ADPCMParms::swapBig()
|
||||
{
|
||||
m_bytesPerFrame = SBig(m_bytesPerFrame);
|
||||
m_hist1 = SBig(m_hist1);
|
||||
m_hist2 = SBig(m_hist2);
|
||||
m_hist1 = SBig(m_hist1);
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
{
|
||||
m_coefs[i][0] = SBig(m_coefs[i][0]);
|
||||
@@ -28,7 +28,7 @@ void AudioGroupSampleDirectory::ADPCMParms::swapBig()
|
||||
}
|
||||
}
|
||||
|
||||
AudioGroupSampleDirectory::AudioGroupSampleDirectory(const unsigned char* data)
|
||||
AudioGroupSampleDirectory::AudioGroupSampleDirectory(const unsigned char* data, GCNDataTag)
|
||||
{
|
||||
const unsigned char* cur = data;
|
||||
while (*reinterpret_cast<const uint32_t*>(cur) != 0xffffffff)
|
||||
@@ -53,4 +53,66 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(const unsigned char* data)
|
||||
}
|
||||
}
|
||||
|
||||
struct MusyX1SdirEntry
|
||||
{
|
||||
uint16_t m_sfxId;
|
||||
uint32_t m_sampleOff;
|
||||
uint32_t m_pitchSampleRate;
|
||||
uint32_t m_numSamples;
|
||||
uint32_t m_loopStartSample;
|
||||
uint32_t m_loopLengthSamples;
|
||||
|
||||
void swapBig()
|
||||
{
|
||||
m_sfxId = SBig(m_sfxId);
|
||||
m_sampleOff = SBig(m_sampleOff);
|
||||
m_pitchSampleRate = SBig(m_pitchSampleRate);
|
||||
m_numSamples = SBig(m_numSamples);
|
||||
m_loopStartSample = SBig(m_loopStartSample);
|
||||
m_loopLengthSamples = SBig(m_loopLengthSamples);
|
||||
}
|
||||
|
||||
void setIntoMusyX2(AudioGroupSampleDirectory::Entry& ent) const
|
||||
{
|
||||
ent.m_sfxId = m_sfxId;
|
||||
ent.m_sampleOff = m_sampleOff;
|
||||
ent.m_unk = 0;
|
||||
ent.m_pitch = m_pitchSampleRate >> 24;
|
||||
ent.m_sampleRate = m_pitchSampleRate & 0xffff;
|
||||
ent.m_numSamples = m_numSamples;
|
||||
ent.m_loopStartSample = m_loopStartSample;
|
||||
ent.m_loopLengthSamples = m_loopLengthSamples;
|
||||
ent.m_adpcmParmOffset = 0;
|
||||
}
|
||||
};
|
||||
|
||||
AudioGroupSampleDirectory::AudioGroupSampleDirectory(const unsigned char* data, N64DataTag)
|
||||
{
|
||||
const unsigned char* cur = data;
|
||||
while (*reinterpret_cast<const uint32_t*>(cur) != 0xffffffff)
|
||||
{
|
||||
MusyX1SdirEntry ent = *reinterpret_cast<const MusyX1SdirEntry*>(cur);
|
||||
ent.swapBig();
|
||||
|
||||
std::pair<Entry, ADPCMParms>& store = m_entries[ent.m_sfxId];
|
||||
ent.setIntoMusyX2(store.first);
|
||||
|
||||
cur += 24;
|
||||
}
|
||||
}
|
||||
|
||||
AudioGroupSampleDirectory::AudioGroupSampleDirectory(const unsigned char* data, PCDataTag)
|
||||
{
|
||||
const unsigned char* cur = data;
|
||||
while (*reinterpret_cast<const uint32_t*>(cur) != 0xffffffff)
|
||||
{
|
||||
const MusyX1SdirEntry* ent = reinterpret_cast<const MusyX1SdirEntry*>(cur);
|
||||
|
||||
std::pair<Entry, ADPCMParms>& store = m_entries[ent->m_sfxId];
|
||||
ent->setIntoMusyX2(store.first);
|
||||
|
||||
cur += 24;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user