From d10a0ac7f1ea64099ab6ca6d49a1cdc3fe4b45f6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Sep 2019 16:52:55 -0400 Subject: [PATCH] General: Be explicit about athena's SeekOrigin type Allows the code to still compile if the enum is turned into an enum class. --- include/amuse/AudioGroupPool.hpp | 8 +- include/amuse/AudioGroupProject.hpp | 8 +- include/amuse/AudioGroupSampleDirectory.hpp | 10 +- lib/AudioGroupPool.cpp | 36 +-- lib/AudioGroupProject.cpp | 233 +++++++++++--------- lib/AudioGroupSampleDirectory.cpp | 22 +- 6 files changed, 170 insertions(+), 147 deletions(-) diff --git a/include/amuse/AudioGroupPool.hpp b/include/amuse/AudioGroupPool.hpp index aae27a9..20bd954 100644 --- a/include/amuse/AudioGroupPool.hpp +++ b/include/amuse/AudioGroupPool.hpp @@ -36,7 +36,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) ObjectHe AT_DECL_DNA Value size; ObjectIdDNA objectId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; }; struct SoundMacro { @@ -908,7 +908,7 @@ struct SoundMacro { static const CmdIntrospection Introspective; Value varCtrlA; Value a; - Seek<1, athena::Current> pad; + Seek<1, athena::SeekOrigin::Current> pad; Value imm; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::SetVar; } @@ -1100,7 +1100,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) KeymapDN Value transpose; Value pan; /* -128 for surround-channel only */ Value prioOffset; - Seek<3, athena::Current> pad; + Seek<3, athena::SeekOrigin::Current> pad; }; struct Keymap : BigDNA { AT_DECL_DNA_YAML @@ -1142,7 +1142,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) LayerMap Value prioOffset; Value span; Value pan; - Seek<3, athena::Current> pad; + Seek<3, athena::SeekOrigin::Current> pad; }; struct LayerMapping : BigDNA { AT_DECL_DNA_YAML diff --git a/include/amuse/AudioGroupProject.hpp b/include/amuse/AudioGroupProject.hpp index 4594c26..b3c92e1 100644 --- a/include/amuse/AudioGroupProject.hpp +++ b/include/amuse/AudioGroupProject.hpp @@ -46,7 +46,7 @@ struct SongGroupIndex : AudioGroupIndex { Value priority; Value maxVoices; Value programNo; - Seek<1, athena::Current> pad; + Seek<1, athena::SeekOrigin::Current> pad; }; template struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1PageEntryDNA : BigDNA { @@ -56,7 +56,7 @@ struct SongGroupIndex : AudioGroupIndex { Value maxVoices; Value unk; Value programNo; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; }; struct PageEntry : BigDNA { AT_DECL_DNA_YAML @@ -94,7 +94,7 @@ struct SongGroupIndex : AudioGroupIndex { Value panning; Value reverb; Value chorus; - Seek<3, athena::Current> pad; + Seek<3, athena::SeekOrigin::Current> pad; }; struct MIDISetup : BigDNA { AT_DECL_DNA_YAML @@ -130,7 +130,7 @@ struct SFXGroupIndex : AudioGroupIndex { Value defVel; Value panning; Value defKey; - Seek<1, athena::Current> pad; + Seek<1, athena::SeekOrigin::Current> pad; }; struct SFXEntry : BigDNA { AT_DECL_DNA_YAML diff --git a/include/amuse/AudioGroupSampleDirectory.hpp b/include/amuse/AudioGroupSampleDirectory.hpp index a849e55..7900e2d 100644 --- a/include/amuse/AudioGroupSampleDirectory.hpp +++ b/include/amuse/AudioGroupSampleDirectory.hpp @@ -31,7 +31,7 @@ struct DSPADPCMHeader : BigDNA { Value x46_loop_hist1 = 0; Value x48_loop_hist2 = 0; Value m_pitch = 0; // Stash this in the padding - Seek<21, athena::Current> pad; + Seek<21, athena::SeekOrigin::Current> pad; }; struct VADPCMHeader : BigDNA { @@ -156,11 +156,11 @@ public: struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) EntryDNA : BigDNA { AT_DECL_DNA SampleIdDNA m_sfxId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; Value m_sampleOff; Value m_unk; Value m_pitch; - Seek<1, athena::Current> pad2; + Seek<1, athena::SeekOrigin::Current> pad2; Value m_sampleRate; Value m_numSamples; // Top 8 bits is SampleFormat Value m_loopStartSample; @@ -177,7 +177,7 @@ public: struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1SdirEntry : BigDNA { AT_DECL_DNA SampleIdDNA m_sfxId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; Value m_sampleOff; Value m_pitchSampleRate; Value m_numSamples; @@ -188,7 +188,7 @@ public: struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1AbsSdirEntry : BigDNA { AT_DECL_DNA SampleIdDNA m_sfxId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; Value m_sampleOff; Value m_unk; Value m_pitchSampleRate; diff --git a/lib/AudioGroupPool.cpp b/lib/AudioGroupPool.cpp index 7e5f4dc..574a523 100644 --- a/lib/AudioGroupPool.cpp +++ b/lib/AudioGroupPool.cpp @@ -88,7 +88,7 @@ struct IntrospectCmdOp { static bool AtEnd(athena::io::IStreamReader& r) { uint32_t v = r.readUint32Big(); - r.seek(-4, athena::Current); + r.seek(-4, athena::SeekOrigin::Current); return v == 0xffffffff; } @@ -100,7 +100,7 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { head.read(r); if (head.soundMacrosOffset) { - r.seek(head.soundMacrosOffset, athena::Begin); + r.seek(head.soundMacrosOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -111,12 +111,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { auto& macro = ret.m_soundMacros[objHead.objectId.id]; macro = MakeObj(); macro->template readCmds(r, objHead.size - 8); - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } if (head.tablesOffset) { - r.seek(head.tablesOffset, athena::Begin); + r.seek(head.tablesOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -139,12 +139,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { r.readUBytesToBuf(&static_cast(**ptr).data[0], objHead.size - 8); break; } - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } if (head.keymapsOffset) { - r.seek(head.keymapsOffset, athena::Begin); + r.seek(head.keymapsOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -159,12 +159,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { kmData.read(r); (*km)[i] = kmData; } - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } if (head.layersOffset) { - r.seek(head.layersOffset, athena::Begin); + r.seek(head.layersOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -182,7 +182,7 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { lmData.read(r); lm->push_back(lmData); } - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } @@ -1019,9 +1019,9 @@ std::vector AudioGroupPool::toData() const { p.second->template writeCmds(fo); objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } @@ -1049,9 +1049,9 @@ std::vector AudioGroupPool::toData() const { } objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } @@ -1068,9 +1068,9 @@ std::vector AudioGroupPool::toData() const { } objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } @@ -1089,14 +1089,14 @@ std::vector AudioGroupPool::toData() const { } objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } - fo.seek(0, athena::Begin); + fo.seek(0, athena::SeekOrigin::Begin); head.write(fo); return fo.data(); diff --git a/lib/AudioGroupProject.cpp b/lib/AudioGroupProject.cpp index e7a28a2..21fd65f 100644 --- a/lib/AudioGroupProject.cpp +++ b/lib/AudioGroupProject.cpp @@ -13,19 +13,19 @@ namespace amuse { static bool AtEnd64(athena::io::IStreamReader& r) { uint64_t v = r.readUint64Big(); - r.seek(-8, athena::Current); + r.seek(-8, athena::SeekOrigin::Current); return v == 0xffffffffffffffff; } static bool AtEnd32(athena::io::IStreamReader& r) { uint32_t v = r.readUint32Big(); - r.seek(-4, athena::Current); + r.seek(-4, athena::SeekOrigin::Current); return v == 0xffffffff; } static bool AtEnd16(athena::io::IStreamReader& r) { uint16_t v = r.readUint16Big(); - r.seek(-2, athena::Current); + r.seek(-2, athena::SeekOrigin::Current); return v == 0xffff; } @@ -89,30 +89,35 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); #if 0 - /* Sound Macros */ - r.seek(header.soundMacroIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + /* Sound Macros */ + r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + } - /* Samples */ - r.seek(header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + /* Samples */ + r.seek(header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } - /* Tables */ - r.seek(header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + /* Tables */ + r.seek(header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } - /* Keymaps */ - r.seek(header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + /* Keymaps */ + r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } - /* Layers */ - r.seek(header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + /* Layers */ + r.seek(header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } #endif if (header.type == GroupType::Song) { @@ -120,7 +125,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { idx = MakeObj(); /* Normal pages */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); while (!AtEnd64(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -128,7 +133,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { } /* Drum pages */ - r.seek(header.drumTableOff, athena::Begin); + r.seek(header.drumTableOff, athena::SeekOrigin::Begin); while (!AtEnd64(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -136,24 +141,26 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { } /* MIDI setups */ - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t songId = r.readUint16Big(); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); std::array& setup = idx->m_midiSetups[songId]; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 16; ++i) { setup[i].read(r); - if (SongId::CurNameDB) + } + if (SongId::CurNameDB) { SongId::CurNameDB->registerPair(NameDB::generateName(songId, NameDB::Type::Song), songId); + } } } else if (header.type == GroupType::SFX) { auto& idx = m_sfxGroups[header.groupId]; idx = MakeObj(); /* SFX entries */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count = r.readUint16Big(); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); idx->m_sfxEntries.reserve(count); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; @@ -164,7 +171,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { } } - r.seek(header.groupEndOff, athena::Begin); + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); } } @@ -181,30 +188,35 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); #if 0 - /* Sound Macros */ - r.seek(subDataOff + header.soundMacroIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + /* Sound Macros */ + r.seek(subDataOff + header.soundMacroIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + } - /* Samples */ - r.seek(subDataOff + header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + /* Samples */ + r.seek(subDataOff + header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } - /* Tables */ - r.seek(subDataOff + header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + /* Tables */ + r.seek(subDataOff + header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } - /* Keymaps */ - r.seek(subDataOff + header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + /* Keymaps */ + r.seek(subDataOff + header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } - /* Layers */ - r.seek(subDataOff + header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + /* Layers */ + r.seek(subDataOff + header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } #endif if (header.type == GroupType::Song) { @@ -213,7 +225,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade if (absOffs) { /* Normal pages */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -221,7 +233,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* Drum pages */ - r.seek(header.drumTableOff, athena::Begin); + r.seek(header.drumTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -229,19 +241,20 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* MIDI setups */ - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t songId; athena::io::Read::Do({}, songId, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); std::array& setup = idx->m_midiSetups[songId]; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 16; ++i) { setup[i].read(r); + } SongId::CurNameDB->registerPair(NameDB::generateName(songId, NameDB::Type::Song), songId); } } else { /* Normal pages */ - r.seek(subDataOff + header.pageTableOff, athena::Begin); + r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::MusyX1PageEntryDNA entry; entry.read(r); @@ -249,7 +262,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* Drum pages */ - r.seek(subDataOff + header.drumTableOff, athena::Begin); + r.seek(subDataOff + header.drumTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::MusyX1PageEntryDNA entry; entry.read(r); @@ -257,11 +270,11 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* MIDI setups */ - r.seek(subDataOff + header.midiSetupsOff, athena::Begin); + r.seek(subDataOff + header.midiSetupsOff, athena::SeekOrigin::Begin); while (atInt64(r.position() + 4) < groupBegin + header.groupEndOff) { uint16_t songId; athena::io::Read::Do({}, songId, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); std::array& setup = idx->m_midiSetups[songId]; for (int i = 0; i < 16; ++i) { SongGroupIndex::MusyX1MIDISetup ent; @@ -276,24 +289,24 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade idx = MakeObj(); /* SFX entries */ - r.seek(subDataOff + header.pageTableOff, athena::Begin); + r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count; athena::io::Read::Do({}, count, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); idx->m_sfxEntries.reserve(count); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; entry.read(r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); idx->m_sfxEntries[entry.sfxId.id] = entry; SFXId::CurNameDB->registerPair(NameDB::generateName(entry.sfxId.id, NameDB::Type::SFX), entry.sfxId.id); } } if (absOffs) - r.seek(header.groupEndOff, athena::Begin); + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); else - r.seek(groupBegin + header.groupEndOff, athena::Begin); + r.seek(groupBegin + header.groupEndOff, athena::SeekOrigin::Begin); } return ret; @@ -452,43 +465,47 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); /* Sound Macros */ - r.seek(header.soundMacroIdsOff, athena::Begin); + r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); /* Samples */ - r.seek(header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } /* Tables */ - r.seek(header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } /* Keymaps */ - r.seek(header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } /* Layers */ - r.seek(header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } if (header.type == GroupType::Song) { /* MIDI setups */ - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t id = r.readUint16Big(); SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id); - r.seek(2 + 5 * 16, athena::Current); + r.seek(2 + 5 * 16, athena::SeekOrigin::Current); } } else if (header.type == GroupType::SFX) { /* SFX entries */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count = r.readUint16Big(); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; entry.read(r); @@ -496,7 +513,7 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData } } - r.seek(header.groupEndOff, athena::Begin); + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); } } @@ -511,67 +528,73 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, bool ab GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); /* Sound Macros */ - r.seek(subDataOff + header.soundMacroIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.soundMacroIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + } /* Samples */ - r.seek(subDataOff + header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } /* Tables */ - r.seek(subDataOff + header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } /* Keymaps */ - r.seek(subDataOff + header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } /* Layers */ - r.seek(subDataOff + header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } if (header.type == GroupType::Song) { /* MIDI setups */ if (absOffs) { - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t id; athena::io::Read::Do({}, id, r); SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id); - r.seek(2 + 5 * 16, athena::Current); + r.seek(2 + 5 * 16, athena::SeekOrigin::Current); } } else { - r.seek(subDataOff + header.midiSetupsOff, athena::Begin); + r.seek(subDataOff + header.midiSetupsOff, athena::SeekOrigin::Begin); while (atInt64(r.position()) < groupBegin + header.groupEndOff) { uint16_t id; athena::io::Read::Do({}, id, r); SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id); - r.seek(2 + 8 * 16, athena::Current); + r.seek(2 + 8 * 16, athena::SeekOrigin::Current); } } } else if (header.type == GroupType::SFX) { /* SFX entries */ - r.seek(subDataOff + header.pageTableOff, athena::Begin); + r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count; athena::io::Read::Do({}, count, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; entry.read(r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); SFXId::CurNameDB->registerPair(NameDB::generateName(entry.sfxId.id, NameDB::Type::SFX), entry.sfxId.id); } } - if (absOffs) - r.seek(header.groupEndOff, athena::Begin); - else - r.seek(groupBegin + header.groupEndOff, athena::Begin); + if (absOffs) { + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); + } else { + r.seek(groupBegin + header.groupEndOff, athena::SeekOrigin::Begin); + } } } @@ -861,9 +884,9 @@ std::vector AudioGroupProject::toGCNData(const AudioGroupPool& pool, } header.groupEndOff = fo.position(); - fo.seek(groupStart, athena::Begin); + fo.seek(groupStart, athena::SeekOrigin::Begin); header.write(fo); - fo.seek(header.groupEndOff, athena::Begin); + fo.seek(header.groupEndOff, athena::SeekOrigin::Begin); } else { auto search2 = m_sfxGroups.find(id); if (search2 != m_sfxGroups.end()) { @@ -897,9 +920,9 @@ std::vector AudioGroupProject::toGCNData(const AudioGroupPool& pool, } header.groupEndOff = fo.position(); - fo.seek(groupStart, athena::Begin); + fo.seek(groupStart, athena::SeekOrigin::Begin); header.write(fo); - fo.seek(header.groupEndOff, athena::Begin); + fo.seek(header.groupEndOff, athena::SeekOrigin::Begin); } } } diff --git a/lib/AudioGroupSampleDirectory.cpp b/lib/AudioGroupSampleDirectory.cpp index 099833d..6f904a3 100644 --- a/lib/AudioGroupSampleDirectory.cpp +++ b/lib/AudioGroupSampleDirectory.cpp @@ -24,7 +24,7 @@ namespace amuse { static bool AtEnd32(athena::io::IStreamReader& r) { uint32_t v = r.readUint32Big(); - r.seek(-4, athena::Current); + r.seek(-4, athena::SeekOrigin::Current); return v == 0xffffffff; } @@ -55,7 +55,7 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader& for (auto& p : m_entries) { if (p.second->m_data->m_adpcmParmOffset) { - r.seek(p.second->m_data->m_adpcmParmOffset, athena::Begin); + r.seek(p.second->m_data->m_adpcmParmOffset, athena::SeekOrigin::Begin); r.readUBytesToBuf(&p.second->m_data->m_ADPCMParms, sizeof(ADPCMParms::DSPParms)); p.second->m_data->m_ADPCMParms.swapBigDSP(); } @@ -237,7 +237,7 @@ void AudioGroupSampleDirectory::EntryData::loadLooseWAV(SystemStringView wavPath m_looseData.reset(new uint8_t[chunkSize]); r.readUBytesToBuf(m_looseData.get(), chunkSize); } - r.seek(startPos + chunkSize, athena::Begin); + r.seek(startPos + chunkSize, athena::SeekOrigin::Begin); } } } @@ -388,7 +388,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataDSP(SystemStringView dsp athena::io::FileWriter w(dspPath, false); if (!w.hasError()) { - w.seek(0, athena::Begin); + w.seek(0, athena::SeekOrigin::Begin); head.write(w); } } @@ -397,7 +397,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataDSP(SystemStringView dsp void AudioGroupSampleDirectory::EntryData::patchMetadataVADPCM(SystemStringView vadpcmPath) { athena::io::FileWriter w(vadpcmPath, false); if (!w.hasError()) { - w.seek(0, athena::Begin); + w.seek(0, athena::SeekOrigin::Begin); VADPCMHeader header; header.m_pitchSampleRate = m_pitch << 24; header.m_pitchSampleRate |= m_sampleRate & 0xffff; @@ -434,12 +434,12 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav loopOffset = startPos + 36; ++readSec; } - r.seek(startPos + chunkSize, athena::Begin); + r.seek(startPos + chunkSize, athena::SeekOrigin::Begin); } if (smplOffset == -1 || loopOffset == -1) { /* Complete rewrite of RIFF layout - new smpl chunk */ - r.seek(12, athena::Begin); + r.seek(12, athena::SeekOrigin::Begin); athena::io::FileWriter w(wavPath); if (!w.hasError()) { w.writeUint32Little(SBIG('RIFF')); @@ -470,7 +470,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav loop.end = getLoopEndSample(); loop.write(w); if (chunkMagic == SBIG('smpl')) { - r.seek(chunkSize, athena::Current); + r.seek(chunkSize, athena::SeekOrigin::Current); continue; } } @@ -480,7 +480,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav } atUint64 wavLen = w.position(); - w.seek(4, athena::Begin); + w.seek(4, athena::SeekOrigin::Begin); w.writeUint32Little(wavLen - 8); } r.close(); @@ -489,7 +489,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav r.close(); athena::io::FileWriter w(wavPath, false); if (!w.hasError()) { - w.seek(smplOffset, athena::Begin); + w.seek(smplOffset, athena::SeekOrigin::Begin); WAVSampleChunk smpl; smpl.smplPeriod = 1000000000 / fmt.sampleRate; smpl.midiNote = m_pitch; @@ -810,7 +810,7 @@ void AudioGroupSampleDirectory::_extractCompressed(SampleId id, const EntryData& samps += sampleCount; } - w.seek(0, athena::Begin); + w.seek(0, athena::SeekOrigin::Begin); header.write(w); } else { return;