mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Bgm: Implement BgmMusicalInfo and copyAudioInfoList (#1000)
This commit is contained in:
parent
76c3490dec
commit
a3ed1588c4
|
|
@ -227047,82 +227047,82 @@ Library/Bgm/BgmMusicalInfo.o:
|
|||
- offset: 0x82e87c
|
||||
size: 292
|
||||
label: _ZN2al14BgmMusicalInfo10createInfoERKNS_9ByamlIterEPKc
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x82e9a0
|
||||
size: 332
|
||||
label: _ZN2al19createAudioInfoListINS_13BgmRhythmInfoEEEPNS_22AudioInfoListWithPartsIT_EERKNS_9ByamlIterEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82eaec
|
||||
size: 332
|
||||
label: _ZN2al19createAudioInfoListINS_12BgmChordInfoEEEPNS_22AudioInfoListWithPartsIT_EERKNS_9ByamlIterEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82ec38
|
||||
size: 332
|
||||
label: _ZN2al19createAudioInfoListINS_10BgmBpmInfoEEEPNS_22AudioInfoListWithPartsIT_EERKNS_9ByamlIterEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82ed84
|
||||
size: 332
|
||||
label: _ZN2al19createAudioInfoListINS_20BgmTimeSignatureInfoEEEPNS_22AudioInfoListWithPartsIT_EERKNS_9ByamlIterEi
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82eed0
|
||||
size: 12
|
||||
label: _ZN2al14BgmMusicalInfo11compareInfoEPKS0_S2_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x82eedc
|
||||
size: 20
|
||||
label:
|
||||
- _ZN2al14BgmMusicalInfoC1Ev
|
||||
- _ZN2al14BgmMusicalInfoC2Ev
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x82eef0
|
||||
size: 120
|
||||
label:
|
||||
- _ZN2al14BgmMusicalInfoC1ERKS0_
|
||||
- _ZN2al14BgmMusicalInfoC2ERKS0_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x82ef68
|
||||
size: 488
|
||||
label: _ZN2al17copyAudioInfoListINS_13BgmRhythmInfoEEEPNS_22AudioInfoListWithPartsIT_EEPKS4_i
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82f150
|
||||
size: 488
|
||||
label: _ZN2al17copyAudioInfoListINS_12BgmChordInfoEEEPNS_22AudioInfoListWithPartsIT_EEPKS4_i
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82f338
|
||||
size: 488
|
||||
label: _ZN2al17copyAudioInfoListINS_10BgmBpmInfoEEEPNS_22AudioInfoListWithPartsIT_EEPKS4_i
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82f520
|
||||
size: 488
|
||||
label: _ZN2al17copyAudioInfoListINS_20BgmTimeSignatureInfoEEEPNS_22AudioInfoListWithPartsIT_EEPKS4_i
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82f708
|
||||
size: 104
|
||||
label: _ZN2al26AudioInfoListCreateFunctorINS_13BgmRhythmInfoEE30tryCreateAudioInfoAndSetToListERKNS_9ByamlIterE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82f770
|
||||
size: 104
|
||||
label: _ZN2al26AudioInfoListCreateFunctorINS_12BgmChordInfoEE30tryCreateAudioInfoAndSetToListERKNS_9ByamlIterE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82f7d8
|
||||
size: 104
|
||||
label: _ZN2al26AudioInfoListCreateFunctorINS_10BgmBpmInfoEE30tryCreateAudioInfoAndSetToListERKNS_9ByamlIterE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
- offset: 0x82f840
|
||||
size: 104
|
||||
label: _ZN2al26AudioInfoListCreateFunctorINS_20BgmTimeSignatureInfoEE30tryCreateAudioInfoAndSetToListERKNS_9ByamlIterE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
lazy: true
|
||||
Library/Bgm/Bgm3DParamsController.o:
|
||||
'.text':
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class AudioInfoList {
|
|||
public:
|
||||
static s32 compareInfoAndKey(const T* info, const char* key) { return strcmp(info->name, key); }
|
||||
|
||||
static s32 compareInfoAndId(const T* info, const u32* id);
|
||||
|
||||
AudioInfoList() = default;
|
||||
|
||||
void init(s32 listSize) {
|
||||
|
|
@ -54,7 +56,21 @@ public:
|
|||
mList->allocBuffer((listSize == 0) ? 1 : listSize, nullptr);
|
||||
}
|
||||
|
||||
bool setInfo(const T* audioInfo) const { return mList->pushBack(audioInfo); }
|
||||
bool setInfo(const T* info) const { return mList->pushBack(info); }
|
||||
|
||||
const T* getInfoAt(s32 index) const {
|
||||
if (index < 0)
|
||||
return nullptr;
|
||||
return mList->unsafeAt(index);
|
||||
}
|
||||
|
||||
bool copyAndSetInfo(const T* info) const {
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
T* newInfo = new T(*info);
|
||||
return setInfo(newInfo);
|
||||
}
|
||||
|
||||
void sort() const {
|
||||
if (mList->size() >= 10)
|
||||
|
|
@ -63,9 +79,13 @@ public:
|
|||
mList->sort(T::compareInfo);
|
||||
}
|
||||
|
||||
s32 getSize() const { return mList->size(); }
|
||||
|
||||
bool isValidIndex(s32 index) const { return index < getSize(); }
|
||||
|
||||
private:
|
||||
sead::PtrArray<const T>* mList;
|
||||
bool mIsLinearSearch;
|
||||
bool mIsLinearSearch = false;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -93,12 +113,39 @@ public:
|
|||
mParts->at(i)->sort();
|
||||
}
|
||||
|
||||
const T* getInfoAt(s32 index) const {
|
||||
if (AudioInfoList<T>::isValidIndex(index))
|
||||
return AudioInfoList<T>::getInfoAt(index);
|
||||
index -= AudioInfoList<T>::getSize();
|
||||
|
||||
for (s32 i = 0; i < getPartsSize(); i++) {
|
||||
const AudioInfoList<T>* part = mParts->at(i);
|
||||
if (part->isValidIndex(index))
|
||||
return part->getInfoAt(index);
|
||||
index -= part->getSize();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s32 getPartsSize() const {
|
||||
if (!mParts)
|
||||
return 0;
|
||||
return mParts->size();
|
||||
}
|
||||
|
||||
s32 getSize() const {
|
||||
if (!mParts)
|
||||
return AudioInfoList<T>::getSize();
|
||||
|
||||
s32 size = AudioInfoList<T>::getSize();
|
||||
s32 partsSize = 0;
|
||||
for (s32 i = 0; i < getPartsSize(); i++)
|
||||
partsSize += mParts->at(i)->getSize();
|
||||
|
||||
return size + partsSize;
|
||||
}
|
||||
|
||||
private:
|
||||
sead::PtrArray<AudioInfoList<T>>* mParts;
|
||||
};
|
||||
|
|
@ -140,4 +187,23 @@ const T* tryFindAudioInfo(const AudioInfoListWithParts<T>* audioInfoList, const
|
|||
return audioInfoList->tryFindInfo(name);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
AudioInfoListWithParts<T>* copyAudioInfoList(const AudioInfoListWithParts<T>* audioInfoList,
|
||||
s32 additionalSize) {
|
||||
if (!audioInfoList)
|
||||
return nullptr;
|
||||
|
||||
s32 originalSize = audioInfoList->getSize();
|
||||
s32 newSize = originalSize + additionalSize;
|
||||
|
||||
AudioInfoListWithParts<T>* newAudioInfoList = new AudioInfoListWithParts<T>;
|
||||
newAudioInfoList->init(newSize, 0);
|
||||
|
||||
for (s32 i = 0; i < originalSize; i++) {
|
||||
const T* info = audioInfoList->getInfoAt(i);
|
||||
newAudioInfoList->copyAndSetInfo(info);
|
||||
}
|
||||
|
||||
return newAudioInfoList;
|
||||
}
|
||||
} // namespace al
|
||||
|
|
|
|||
49
lib/al/Library/Bgm/BgmMusicalInfo.cpp
Normal file
49
lib/al/Library/Bgm/BgmMusicalInfo.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include "Library/Bgm/BgmMusicalInfo.h"
|
||||
|
||||
#include "Library/Audio/AudioInfo.h"
|
||||
#include "Library/Bgm/BgmResourceCategoryInfo.h"
|
||||
#include "Library/Yaml/ByamlIter.h"
|
||||
#include "Project/Bgm/BgmInfo.h"
|
||||
|
||||
namespace al {
|
||||
|
||||
BgmMusicalInfo* BgmMusicalInfo::createInfo(const ByamlIter& iter, const char* name) {
|
||||
BgmMusicalInfo* info = new BgmMusicalInfo();
|
||||
info->name = name;
|
||||
|
||||
ByamlIter animListIter;
|
||||
if (iter.tryGetIterByKey(&animListIter, "AnimList"))
|
||||
info->rhythmInfoList = createAudioInfoList<BgmRhythmInfo>(animListIter, 0);
|
||||
|
||||
ByamlIter chordListIter;
|
||||
if (iter.tryGetIterByKey(&chordListIter, "ChordList"))
|
||||
info->chordInfoList = createAudioInfoList<BgmChordInfo>(chordListIter, 0);
|
||||
|
||||
ByamlIter bpmListIter;
|
||||
if (iter.tryGetIterByKey(&bpmListIter, "BpmInfoList"))
|
||||
info->bpmInfoList = createAudioInfoList<BgmBpmInfo>(bpmListIter, 0);
|
||||
|
||||
ByamlIter timeSignatureListIter;
|
||||
if (iter.tryGetIterByKey(&timeSignatureListIter, "TimeSignatureInfoList"))
|
||||
info->timeSignatureInfoList =
|
||||
createAudioInfoList<BgmTimeSignatureInfo>(timeSignatureListIter, 0);
|
||||
|
||||
iter.tryGetFloatByKey(&info->beatStartOffsetTime, "BeatStartOffsetTime");
|
||||
return info;
|
||||
}
|
||||
|
||||
s32 BgmMusicalInfo::compareInfo(const BgmMusicalInfo* lhs, const BgmMusicalInfo* rhs) {
|
||||
return strcmp(lhs->name, rhs->name);
|
||||
}
|
||||
|
||||
BgmMusicalInfo::BgmMusicalInfo() = default;
|
||||
|
||||
BgmMusicalInfo::BgmMusicalInfo(const BgmMusicalInfo& info)
|
||||
: name(info.name), beatStartOffsetTime(info.beatStartOffsetTime) {
|
||||
rhythmInfoList = copyAudioInfoList(info.rhythmInfoList, 0);
|
||||
chordInfoList = copyAudioInfoList(info.chordInfoList, 0);
|
||||
bpmInfoList = copyAudioInfoList(info.bpmInfoList, 0);
|
||||
timeSignatureInfoList = copyAudioInfoList(info.timeSignatureInfoList, 0);
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
31
lib/al/Library/Bgm/BgmMusicalInfo.h
Normal file
31
lib/al/Library/Bgm/BgmMusicalInfo.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
|
||||
namespace al {
|
||||
template <typename T>
|
||||
class AudioInfoListWithParts;
|
||||
class ByamlIter;
|
||||
struct BgmRhythmInfo;
|
||||
struct BgmChordInfo;
|
||||
struct BgmBpmInfo;
|
||||
struct BgmTimeSignatureInfo;
|
||||
|
||||
struct BgmMusicalInfo {
|
||||
static BgmMusicalInfo* createInfo(const ByamlIter& iter, const char* name);
|
||||
static s32 compareInfo(const BgmMusicalInfo* lhs, const BgmMusicalInfo* rhs);
|
||||
|
||||
BgmMusicalInfo();
|
||||
BgmMusicalInfo(const BgmMusicalInfo&);
|
||||
|
||||
const char* name = nullptr;
|
||||
AudioInfoListWithParts<BgmRhythmInfo>* rhythmInfoList = nullptr;
|
||||
AudioInfoListWithParts<BgmChordInfo>* chordInfoList = nullptr;
|
||||
AudioInfoListWithParts<BgmBpmInfo>* bpmInfoList = nullptr;
|
||||
AudioInfoListWithParts<BgmTimeSignatureInfo>* timeSignatureInfoList = nullptr;
|
||||
f32 beatStartOffsetTime = 0.0f;
|
||||
};
|
||||
|
||||
static_assert(sizeof(BgmMusicalInfo) == 0x30);
|
||||
|
||||
} // namespace al
|
||||
38
lib/al/Library/Bgm/BgmResourceCategoryInfo.h
Normal file
38
lib/al/Library/Bgm/BgmResourceCategoryInfo.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
|
||||
namespace al {
|
||||
class ByamlIter;
|
||||
|
||||
struct BgmBpmInfo {
|
||||
static BgmBpmInfo* createInfo(const ByamlIter& iter);
|
||||
static s32 compareInfo(const BgmBpmInfo* lhs, const BgmBpmInfo* rhs);
|
||||
|
||||
BgmBpmInfo();
|
||||
BgmBpmInfo(const BgmBpmInfo&);
|
||||
|
||||
f32 time = 0.0f;
|
||||
f32 measureTime = 0.0f;
|
||||
f32 bpm = 0.0f;
|
||||
f32 measureStartBeat = 0.0f;
|
||||
};
|
||||
|
||||
static_assert(sizeof(BgmBpmInfo) == 0x10);
|
||||
|
||||
struct BgmTimeSignatureInfo {
|
||||
static BgmTimeSignatureInfo* createInfo(const ByamlIter& iter);
|
||||
static s32 compareInfo(const BgmTimeSignatureInfo* lhs, const BgmTimeSignatureInfo* rhs);
|
||||
|
||||
BgmTimeSignatureInfo();
|
||||
BgmTimeSignatureInfo(const BgmTimeSignatureInfo&);
|
||||
|
||||
f32 time = 0.0f;
|
||||
f32 beat = 0.0f;
|
||||
s32 nn = 4;
|
||||
s32 dd = 4;
|
||||
};
|
||||
|
||||
static_assert(sizeof(BgmTimeSignatureInfo) == 0x10);
|
||||
|
||||
} // namespace al
|
||||
|
|
@ -63,4 +63,36 @@ struct BgmUserInfo {
|
|||
AudioInfoListWithParts<BgmActionInfo>* bgmActionInfoList = nullptr;
|
||||
AudioInfoListWithParts<BgmSourceInfo>* bgmSourceInfoList = nullptr;
|
||||
};
|
||||
|
||||
struct BgmRhythmInfo {
|
||||
static BgmRhythmInfo* createInfo(const ByamlIter& iter);
|
||||
static s32 compareInfo(const BgmRhythmInfo* lhs, const BgmRhythmInfo* rhs);
|
||||
|
||||
BgmRhythmInfo();
|
||||
BgmRhythmInfo(const BgmRhythmInfo&);
|
||||
|
||||
f32 beat = 0.0f;
|
||||
s32 animId = 0;
|
||||
};
|
||||
|
||||
static_assert(sizeof(BgmRhythmInfo) == 0x8);
|
||||
|
||||
struct BgmChordInfo {
|
||||
static BgmChordInfo* createInfo(const ByamlIter& iter);
|
||||
static BgmChordInfo* createInfoDefault();
|
||||
static s32 compareInfo(const BgmChordInfo* lhs, const BgmChordInfo* rhs);
|
||||
|
||||
BgmChordInfo();
|
||||
BgmChordInfo(const BgmChordInfo&);
|
||||
|
||||
f32 beat = 0.0f;
|
||||
s32 root = 0;
|
||||
s32 chordSize = 0;
|
||||
s32 scaleSize = 0;
|
||||
s32* chordList = nullptr;
|
||||
s32* scaleList = nullptr;
|
||||
};
|
||||
|
||||
static_assert(sizeof(BgmChordInfo) == 0x20);
|
||||
|
||||
} // namespace al
|
||||
|
|
|
|||
Loading…
Reference in a new issue