Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ def MatchingFor(*versions):
Object(Matching, "Inagaki/NpcCarSoundMgr.cpp"),
Object(Matching, "Inagaki/ObjectSoundMgr.cpp"),
Object(Matching, "Inagaki/RockSoundMgr.cpp"),
Object(NonMatching, "Inagaki/GameSoundTable.cpp"),
Object(Matching, "Inagaki/GameSoundTable.cpp"),
Object(NonMatching, "Inagaki/ShoreSoundMgr.cpp"),
Object(NonMatching, "Inagaki/CircleSoundMgr.cpp"),
Object(Matching, "Inagaki/CoasterSoundMgr.cpp"),
Expand Down
20 changes: 12 additions & 8 deletions include/Inagaki/GameSoundTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@

namespace GameAudio
{
class CustomSoundTable : public JAISoundInfo, public JAUSoundInfo, public JAIStreamDataMgr, public JASGlobalInstance<CustomSoundTable>
class CustomSoundTable : public JAISoundInfo, public JAUSoundInfo, public JAIStreamDataMgr
{
public:
virtual u32 getSoundType(JAISoundID soundID) const;
virtual int getCategory(JAISoundID soundID) const;

virtual u32 getPriority(JAISoundID soundID) const;
virtual void getSeInfo(JAISoundID soundID, JAISe *se) const;
virtual void getSeqInfo(JAISoundID soundID, JAISeq *seq) const ;
virtual void getSeqInfo(JAISoundID soundID, JAISeq *seq) const;
virtual void getStreamInfo(JAISoundID soundID, JAIStream *stream) const;

virtual ~CustomSoundTable();
virtual void getAudibleSw(JAISoundID soundID) const;
virtual ~CustomSoundTable(){};
virtual u16 getAudibleSw(JAISoundID soundID) const;
virtual u16 getBgmSeqResourceID(JAISoundID soundID) const;

virtual u8 getPTrack(JAISoundID soundID) const;
virtual u32 getSwBit(JAISoundID soundID) const;
virtual u8 getLevelFlag(JAISoundID soundID) const;
virtual s32 getStreamFileEntry(JAISoundID soundID);
virtual s32 getStreamFileEntry(JAISoundID soundID); // 58

void initAudibleSw();
private:
JAISoundInfo *getSoundInfo_(JAISoundID soundID, JAISound *sound) const;

// UNUSED
void getStreamFilePath(JAISoundID soundID);
private:
void getSoundInfo_(JAISoundID soundID, JAISound *sound) const;
};
}

Expand Down
22 changes: 11 additions & 11 deletions include/JSystem/JAudio/Interface/JAISound.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,17 @@ class JAISound
JAISoundParamsMove &getAuxiliary() { return params_.mMove; }

// private:
JAISoundHandle *handle_;
JAIAudible *audible_;
JAIAudience *audience_;
u32 lifeTime_;
s32 prepareCount_;
JAISoundID soundID_;
JAISoundStatus_ status_;
JAISoundFader fader_;
u32 priority_;
s32 count_;
JAISoundParams params_;
JAISoundHandle *handle_; // 04
JAIAudible *audible_; // 08
JAIAudience *audience_; // 0c
u32 lifeTime_; // 10
s32 prepareCount_; // 14
JAISoundID soundID_; // 18
JAISoundStatus_ status_; // 1c
JAISoundFader fader_; // 24
u32 priority_; // 34
s32 count_; // 38
JAISoundParams params_; // 3a
}; // Size: 0x98

#endif
2 changes: 1 addition & 1 deletion include/JSystem/JAudio/JAUSoundInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class JAUSoundInfo : public JASGlobalInstance<JAUSoundInfo>
{
public:
JAUSoundInfo(bool param_1) : JASGlobalInstance<JAUSoundInfo>(param_1) {}
virtual void getAudibleSw(JAISoundID) const = 0;
virtual u16 getAudibleSw(JAISoundID) const = 0;
virtual u16 getBgmSeqResourceID(JAISoundID) const = 0;
};

Expand Down
14 changes: 9 additions & 5 deletions include/JSystem/JAudio/JAUSoundTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

struct JAUSoundTableItem
{
u8 mPriority;
u8 _1;
u16 mResourceId;
u32 _4;
f32 _8;
u8 mPriority; // 00
u8 _1; // (Other type of priority?) 01
u16 mResourceId; // 02
u32 mSwBit; // 04
u8 _8; // 08
u8 mPTrack; // 09
u16 mSeqResourceID; // 0a
u32 _c; // 0c
u16 mAudibleSw; // 10
};

template <typename Root, typename Section, typename Group, typename Typename_0>
Expand Down
262 changes: 248 additions & 14 deletions src/Inagaki/GameSoundTable.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,270 @@
#include "Inagaki/GameSoundTable.h"
#include "JSystem/JAudio/Interface/JAISound.h"
#include "JSystem/JAudio/JAUSoundTable.h"

#include "JSystem/JAudio/JASFakeMatch11.h"
#include "JSystem/JAudio/Interface/JAISe.h"
#include "JSystem/JAudio/Interface/JAISeq.h"
#include "JSystem/JAudio/Interface/JAIStream.h"
#include "JSystem/JAudio/System/JASDriver.h"
#include "JSystem/JAudio/System/JASGadget.h"
#include "JSystem/JUtility/JUTAssert.h"

namespace GameAudio {

u16 CustomSoundTable::getBgmSeqResourceID(JAISoundID soundID) const {}
static inline bool isValid() {
bool resourceNotNull = false;
if(JASGlobalInstance<JAUSoundTable>::sInstance != NULL
&& JASGlobalInstance<JAUSoundTable>::sInstance->getResource() != NULL)
{
resourceNotNull = true;
}
return resourceNotNull;
}

u16 CustomSoundTable::getBgmSeqResourceID(JAISoundID soundID) const {
#line 27
JUT_ASSERT(isValid());

JAUSoundTableItem* tableItem = JASGlobalInstance<JAUSoundTable>::sInstance->getData(soundID);
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

if(tableItem != NULL) {
switch(typeID) case 0x20:
return tableItem->mSeqResourceID;
}
return -1;
}

u32 CustomSoundTable::getSoundType(JAISoundID soundID) const {
switch(soundID.mId.mBytes.mSectionId)
{
case 0: return 0;
case 1: return 1;
case 2: return 2;
default: return -1;
}
}

int CustomSoundTable::getCategory(JAISoundID soundID) const {
if(soundID.mId.mBytes.mSectionId == 1) {
return getPTrack(soundID.mId.mFullId) - 1;
}

return soundID.mId.mBytes.mGroupId;
}

u16 CustomSoundTable::getAudibleSw(JAISoundID soundID) const {
#line 76
JUT_ASSERT(isValid());

JAUSoundTableItem* tableItem = JASGlobalInstance<JAUSoundTable>::sInstance->getData(soundID);
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

if(tableItem != NULL) {
switch(typeID) case 0x10:
return tableItem->mAudibleSw;
}
return -1;
}

u8 CustomSoundTable::getPTrack(JAISoundID soundID) const {
#line 109
JUT_ASSERT(isValid());

JAUSoundTableItem* tableItem = JASGlobalInstance<JAUSoundTable>::sInstance->getData(soundID);
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

if(tableItem != NULL) {
switch(typeID) case 0x20:
return tableItem->mPTrack;
}
return -1;
}

u32 CustomSoundTable::getSwBit(JAISoundID soundID) const {
#line 128
JUT_ASSERT(isValid());

JAUSoundTableItem* tableItem = JASGlobalInstance<JAUSoundTable>::sInstance->getData(soundID);
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

if(tableItem != NULL) {
switch(typeID){
case 0x20:
return tableItem->mSwBit;
case 0x10:
return tableItem->mSwBit;
}
}
return -1;
}

u8 CustomSoundTable::getLevelFlag(JAISoundID soundID) const {
#line 152
JUT_ASSERT(isValid());

JAUSoundTableItem* tableItem = JASGlobalInstance<JAUSoundTable>::sInstance->getData(soundID);
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

if(tableItem != NULL) {
switch(typeID){
case 0x10:
return tableItem->mPriority != 0;
}
}
return 0;
}

u32 CustomSoundTable::getSoundType(JAISoundID soundID) const {}
u32 CustomSoundTable::getPriority(JAISoundID soundID) const {
#line 171
JUT_ASSERT(isValid());

int CustomSoundTable::getCategory(JAISoundID soundID) const {}
JAUSoundTableItem* tableItem = JASGlobalInstance<JAUSoundTable>::sInstance->getData(soundID);
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

void CustomSoundTable::getAudibleSw(JAISoundID soundID) const {}
if(tableItem != NULL) {
switch(typeID){
case 0x10:
return 0xFF - tableItem->_1;
case 0x20:
return 0xFF - tableItem->mPriority;
case 0x30:
return 0xFF - tableItem->mPriority;
}
}
return 0;
}

u8 CustomSoundTable::getPTrack(JAISoundID soundID) const {}
void CustomSoundTable::getSeInfo(JAISoundID soundID, JAISe *se) const {
getSoundInfo_(soundID, se);
}

u32 CustomSoundTable::getSwBit(JAISoundID soundID) const {}
void CustomSoundTable::getSeqInfo(JAISoundID soundID, JAISeq *seg) const {
getSoundInfo_(soundID, seg);
}

u8 CustomSoundTable::getLevelFlag(JAISoundID soundID) const {}
void CustomSoundTable::getStreamInfo(JAISoundID soundID, JAIStream *stream) const {
getSoundInfo_(soundID, stream);

u32 CustomSoundTable::getPriority(JAISoundID soundID) const {}
#line 209
JUT_ASSERT(isValid());

void CustomSoundTable::getSeInfo(JAISoundID soundID, JAISe *se) const {}
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

void CustomSoundTable::getSeqInfo(JAISoundID soundID, JAISeq *seg) const {}
switch(typeID) {
case 0x30:
JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::sInstance->getData(soundID);

void CustomSoundTable::getStreamInfo(JAISoundID soundID, JAIStream *stream) const {}
#line 216
JUT_ASSERT(data);

JAISoundInfo *CustomSoundTable::getSoundInfo_(JAISoundID soundID, JAISound *sound) const {}
s32 numChild = stream->getNumChild();

s32 CustomSoundTable::getStreamFileEntry(JAISoundID soundID) {}
const f32 leftPan = 0.f;
const f32 rightPan = 1.f;

for(s32 childIndex = 0; childIndex < numChild; childIndex++)
{
JAISoundChild* child = stream->getChild(childIndex);
if(child == NULL)
{
continue;
}

if(childIndex == 0)
{
child->mMove.mPan = leftPan;
}
else if(childIndex == 1)
{
child->mMove.mPan = rightPan;
}
}
}
}

void CustomSoundTable::getSoundInfo_(JAISoundID soundID, JAISound *sound) const {
#line 257
JUT_ASSERT(isValid());

JAUSoundTable* soundTable = JASGlobalInstance<JAUSoundTable>::sInstance;
JAUSoundTableItem* tableItem = soundTable->getData(soundID);
const u8 typeID = JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(soundID);

if(tableItem != NULL) {
switch(typeID){
case 0x10:
sound->params_.mProperty._0 = tableItem->_8 / 255.f;
break;

case 0x20:
sound->params_.mProperty._0 = tableItem->_8 / 255.f;
break;

case 0x30:
sound->params_.mProperty._0 = tableItem->_8 / 255.f;
if(JASDriver::getOutputMode() == 0)
{
sound->params_.mProperty._0 *= 0.75f;
}
break;
}
}
}

void CustomSoundTable::initAudibleSw() {}
// UNUSED
void CustomSoundTable::getStreamFilePath(JAISoundID soundID){}

s32 CustomSoundTable::getStreamFileEntry(JAISoundID soundID) {
const u32 ID = soundID.mId.mFullId;
#line 297
JUT_ASSERT(isValid());

JASGlobalInstance<JAUSoundTable>::sInstance->getTypeID(ID);

return -1;
}

void CustomSoundTable::initAudibleSw() {
JAISoundID id;
id.mId.mFullId = 0;

for (u8 group_id = 0;
(s32)group_id < (s32)JASGlobalInstance<JAUSoundTable>::sInstance->getNumGroups_inSection(0);
group_id++)
{
for (u16 item = 0;
(s32)item < (s32)JASGlobalInstance<JAUSoundTable>::sInstance->getNumItems_inGroup(0, group_id);
item++)
{
JAUSoundTableItem* data = JASGlobalInstance<JAUSoundTable>::sInstance->getData(id);

u16 acc = data->mAudibleSw & 0xC1;
u32 swBit = getSwBit(id);

acc += (u16)(((swBit >> 8) & 0x3) << 14);

if ((swBit & 0x1) == 0)
{
acc += 0x800;
}
if ((swBit & 0x2) == 0)
{
acc += 0x400;
}
if ( swBit & 0x20)
{
acc += 0x100;
}

data->mAudibleSw = acc;

id.mId.mAdvancedId.mShortId++;
}
id.mId.mAdvancedId.mShortId = 0;
id.mId.mBytes.mGroupId++;
}
}

}
Loading