Skip to content

Commit

Permalink
JAIStreamMgr work, copy pikmin2 JAI enums
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Sep 9, 2024
1 parent 5b502c9 commit 3e09392
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 76 deletions.
60 changes: 56 additions & 4 deletions include/JSystem/JAudio/JAISound.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,58 @@

#include "dolphin/types.h"

enum JAISoundType {
SOUNDPARAM_Unk0 = 0,
SOUNDPARAM_Dopplar = 1,
SOUNDPARAM_Demo = 2,
SOUNDPARAM_Unk3 = 3,
SOUNDPARAM_Distance = 4,
SOUNDPARAM_Unk5 = 5,
SOUNDPARAM_Direct = 6,
SOUNDPARAM_Fadeout = 7,
SOUNDPARAM_Unk8 = 8,
SOUNDPARAM_Unk9 = 9,
SOUNDPARAM_Unk10 = 10,
SOUNDPARAM_Pause = 11,
};

enum JAISoundState {
SOUNDSTATE_Inactive = 0,
SOUNDSTATE_Stored = 1,
SOUNDSTATE_Loaded = 2,
SOUNDSTATE_Ready = 3,
SOUNDSTATE_Playing = 4,
SOUNDSTATE_Fadeout = 5,
};

enum JAISoundTrackActiveFlags {
SOUNDACTIVE_Unk0 = 0,
SOUNDACTIVE_Unk1 = 1 << 0, // 0x1
SOUNDACTIVE_DoFadeout = 1 << 1, // 0x2
SOUNDACTIVE_TempoProportion = 1 << 2, // 0x4
SOUNDACTIVE_Unk4 = 1 << 3, // 0x8
SOUNDACTIVE_Unk5 = 1 << 4, // 0x10
SOUNDACTIVE_Unk6 = 1 << 5, // 0x20
SOUNDACTIVE_TrackVolume = 1 << 6, // 0x40
SOUNDACTIVE_TrackPan = 1 << 7, // 0x80
SOUNDACTIVE_TrackDolby = 1 << 8, // 0x100
SOUNDACTIVE_TrackPitch = 1 << 9, // 0x200
SOUNDACTIVE_Unk11 = 1 << 10, // 0x400
SOUNDACTIVE_TrackFxmix = 1 << 11, // 0x800
SOUNDACTIVE_TrackPortData = 1 << 12, // 0x1000
SOUNDACTIVE_Unk14 = 1 << 13, // 0x2000
SOUNDACTIVE_Unk15 = 1 << 14, // 0x4000
SOUNDACTIVE_Unk16 = 1 << 15, // 0x8000
SOUNDACTIVE_Unk17 = 1 << 16, // 0x10000
SOUNDACTIVE_Unk18 = 1 << 17, // 0x20000
SOUNDACTIVE_Volume = 1 << 18, // 0x40000
SOUNDACTIVE_Pan = 1 << 19, // 0x80000
SOUNDACTIVE_Pitch = 1 << 20, // 0x100000
SOUNDACTIVE_Fxmix = 1 << 21, // 0x200000
SOUNDACTIVE_Dolby = 1 << 22, // 0x400000
SOUNDACTIVE_TrackInterruptSwitch = 1 << 23, // 0x800000
};

namespace JAInter {
class Actor;
class SeParameter;
Expand Down Expand Up @@ -103,7 +155,7 @@ class JAISound {
void setDemoFxmix(f32 f1, u32 r4) { setFxmix(f1, r4, 3); }
void setDemoPan(f32 f1, u32 r4) { setPan(f1, r4, 3); }
void setDemoPitch(f32 f1, u32 r4) { setPitch(f1, r4, 3); }
void setDemoVolume(f32 f1, u32 r4) { setVolume(f1, r4, 3); }
void setDemoVolume(f32 f1, u32 r4) { setVolume(f1, r4, SOUNDPARAM_Unk3); }
void setFadetime(u32) {}
void setID(u32) {}
void setMainSoundPPointer(JAISound**) {}
Expand All @@ -121,15 +173,15 @@ class JAISound {
void setWait(u8) {}

/* 0x04 */ u8 field_0x4;
/* 0x05 */ u8 field_0x5;
/* 0x05 */ u8 mState;
/* 0x06 */ u8 field_0x6;
/* 0x07 */ u8 field_0x7;
/* 0x08 */ u8 field_0x8;
/* 0x09 */ u8 field_0x9;
/* 0x0a */ s16 field_0xa;
/* 0x0c */ u32 mSoundID;
/* 0x10 */ int field_0x10;
/* 0x14 */ u32 field_0x14;
/* 0x14 */ u32 mFadeCounter;
/* 0x18 */ u32 field_0x18;
/* 0x1c */ int field_0x1c;
/* 0x20 */ PositionInfo_t* mPositionInfo;
Expand All @@ -148,7 +200,7 @@ namespace JAInter {
public:
MoveParaSet(f32 param_1=1.0f) { init(param_1); }
int set(f32 param_1, u32 param_2);
bool move();
BOOL move();

void init(f32 value) {
mCurrentValue = value;
Expand Down
16 changes: 9 additions & 7 deletions include/JSystem/JAudio/JAIStreamMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace JAInter {
/* 0x04 */ f32 field_0x4;
/* 0x08 */ f32 field_0x8;
/* 0x0C */ f32 field_0xc;
/* 0x10 */ int field_0x10;
/* 0x10 */ u32 mActiveTrackFlag;
/* 0x14 */ JAISound* mpSound;
};

Expand All @@ -38,15 +38,17 @@ namespace JAInter {

class StreamParameter {
public:
/* 0x000 */ u8 field_0x0;
void init() {} // TODO

/* 0x000 */ u8 mPauseMode;
/* 0x004 */ int field_0x4;
/* 0x008 */ int field_0x8;
/* 0x00C */ int field_0xc;
/* 0x010 */ int field_0x10;
/* 0x014 */ JAInter::MoveParaSet field_0x14[20];
/* 0x008 */ u32 mVolumeFlags;
/* 0x00C */ u32 mPitchFlags;
/* 0x010 */ u32 mPanFlags;
/* 0x014 */ JAInter::MoveParaSet mVolumes[20];
/* 0x154 */ JAInter::MoveParaSet* pitch;
/* 0x158 */ JAInter::MoveParaSet* pan;
/* 0x15C */ streamUpdate_t* field_0x15c;
/* 0x15C */ streamUpdate_t* mUpdateData;
};

namespace StreamMgr {
Expand Down
40 changes: 20 additions & 20 deletions src/JAZelAudio/JAIZelBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void JAIZelBasic::gframeProcess() {
if (!JAInter::SeMgr::seHandle) {
return;
}
if (JAInter::SeMgr::seHandle->field_0x5 >= 4) {
if (JAInter::SeMgr::seHandle->mState >= SOUNDSTATE_Playing) {
zeldaGFrameWork();
}
processFrameWork();
Expand All @@ -197,14 +197,14 @@ void JAIZelBasic::resetProcess() {
for (int i = 0; i < JAIGlobalParameter::getParamSeqPlayTrackMax(); i++) {
JAInter::SeqUpdateData* data = JAInter::SequenceMgr::getPlayTrackInfo(i);
if (data && data->field_0x48) {
data->field_0x48->setSeqInterVolume(6, 0.0f, 1);
data->field_0x48->setSeqInterVolume(SOUNDPARAM_Direct, 0.0f, 1);
}
}
if (JAInter::StreamMgr::getUpdateInfo()->mpSound) {
JAInter::StreamMgr::getUpdateInfo()->mpSound->stop(1);
}
if (JAInter::SeMgr::seHandle) {
JAInter::SeMgr::seHandle->setSeqInterVolume(6, 0.0f, 1);
JAInter::SeMgr::seHandle->setSeqInterVolume(SOUNDPARAM_Direct, 0.0f, 1);
}
mNextSceneBgmId = 0;
field_0x022e = 0;
Expand All @@ -214,7 +214,7 @@ void JAIZelBasic::resetProcess() {
/* 802A31C0-802A334C .text resetRecover__11JAIZelBasicFv */
void JAIZelBasic::resetRecover() {
if (JAInter::SeMgr::seHandle) {
JAInter::SeMgr::seHandle->setSeqInterVolume(6, 1.0f, 0);
JAInter::SeMgr::seHandle->setSeqInterVolume(SOUNDPARAM_Direct, 1.0f, 0);
}
for (int i = 0; i < JAIGlobalParameter::getParamSeqPlayTrackMax(); i++) {
JAInter::SeqUpdateData* data = JAInter::SequenceMgr::getPlayTrackInfo(i);
Expand Down Expand Up @@ -540,7 +540,7 @@ void JAIZelBasic::enemyNearByGFrame() {
void JAIZelBasic::bgmAllMute(u32 param_1) {
field_0x0080 = 0.0;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), param_1, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), param_1, SOUNDPARAM_Unk0);
}
}

Expand All @@ -549,32 +549,32 @@ void JAIZelBasic::taktModeMute() {
field_0x0098 = 0.0f;
if (mpMainBgmSound) {
if (mMainBgmNum != JA_BGM_TAKT_MAKORE && mMainBgmNum != JA_BGM_TAKT_MEDRI) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 10, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 10, SOUNDPARAM_Unk0);
} else {
field_0x0098 = 1.0f;
}
}
field_0x00a4 = 0.0;
if (mpSubBgmSound) {
mpSubBgmSound->setVolume(calcSubBgmVol(), 10, 0);
mpSubBgmSound->setVolume(calcSubBgmVol(), 10, SOUNDPARAM_Unk0);
}
}

/* 802A5DF0-802A5F24 .text taktModeMuteOff__11JAIZelBasicFv */
void JAIZelBasic::taktModeMuteOff() {
field_0x0098 = 1.0;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 10, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 10, SOUNDPARAM_Unk0);
}
if (mSubBgmNum == JA_BGM_TAKT_KAZE) {
field_0x008c = 1.0;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 45, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 45, SOUNDPARAM_Unk0);
}
}
field_0x00a4 = 1.0;
if (mpSubBgmSound) {
mpSubBgmSound->setVolume(calcSubBgmVol(), 10, 0);
mpSubBgmSound->setVolume(calcSubBgmVol(), 10, SOUNDPARAM_Unk0);
}
}

Expand All @@ -598,7 +598,7 @@ void JAIZelBasic::cbPracticeStop() {
field_0x00a8 = 1.0;
field_0x009c = 1.0;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 90, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 90, SOUNDPARAM_Unk0);
}
field_0x00d0 = 0;
}
Expand Down Expand Up @@ -886,11 +886,11 @@ void JAIZelBasic::talkIn() {
if (field_0x0064 != 1 && isDemo() != 1 && field_0x0098 != 0.0f) {
field_0x0084 = JAIZelParam::VOL_BGM_TALKING;
if (mpMainBgmSound && mMainBgmNum != JA_BGM_BIRDMAN_GOAL && mMainBgmNum != JA_BGM_BIRDMAN_FAIL) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 2, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 2, SOUNDPARAM_Unk0);
}
field_0x00a0 = JAIZelParam::VOL_BGM_TALKING;
if (mpSubBgmSound) {
mpSubBgmSound->setSeqInterVolume(0, calcSubBgmVol(), 2);
mpSubBgmSound->setSeqInterVolume(SOUNDPARAM_Unk0, calcSubBgmVol(), 2);
}
setSeCategoryVolume(0, JAIZelParam::VOL_SE_SYSTEM_TALKING);
setSeCategoryVolume(1, JAIZelParam::VOL_SE_LINK_VOICE_TALKING);
Expand All @@ -910,11 +910,11 @@ void JAIZelBasic::talkOut() {
}
field_0x0084 = JAIZelParam::VOL_BGM_DEFAULT;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 2, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 2, SOUNDPARAM_Unk0);
}
field_0x00a0 = JAIZelParam::VOL_BGM_DEFAULT;
if (mpSubBgmSound) {
mpSubBgmSound->setSeqInterVolume(0, calcSubBgmVol(), 2);
mpSubBgmSound->setSeqInterVolume(SOUNDPARAM_Unk0, calcSubBgmVol(), 2);
}
setSeCategoryVolume(0, JAIZelParam::VOL_SE_SYSTEM_DEFAULT);
setSeCategoryVolume(1, JAIZelParam::VOL_SE_LINK_VOICE_DEFAULT);
Expand All @@ -930,11 +930,11 @@ void JAIZelBasic::talkOut() {
void JAIZelBasic::menuIn() {
field_0x0088 = JAIZelParam::VOL_BGM_PAUSING;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 2, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 2, SOUNDPARAM_Unk0);
}
field_0x00a0 = JAIZelParam::VOL_BGM_PAUSING;
if (mpSubBgmSound) {
mpSubBgmSound->setSeqInterVolume(0, calcSubBgmVol(), 2);
mpSubBgmSound->setSeqInterVolume(SOUNDPARAM_Unk0, calcSubBgmVol(), 2);
}
setSeCategoryVolume(0, JAIZelParam::VOL_SE_SYSTEM_PAUSING);
setSeCategoryVolume(1, JAIZelParam::VOL_SE_LINK_VOICE_PAUSING);
Expand Down Expand Up @@ -1064,7 +1064,7 @@ void JAIZelBasic::changeSeaBgm() {
case 2:
field_0x0094 = (sp08 - (sp0C.field_0xC + 2000.0f)) / 1000.0f;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 1, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 1, SOUNDPARAM_Unk0);
}
return;
default:
Expand All @@ -1080,14 +1080,14 @@ void JAIZelBasic::changeSeaBgm() {
case 1:
field_0x0094 = ((sp0C.field_0xC + 2000.0f) - sp08) / 2000.0f;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 1, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 1, SOUNDPARAM_Unk0);
}
break;
case 2:
case 3:
field_0x0094 = 0.0f;
if (mpMainBgmSound) {
mpMainBgmSound->setVolume(calcMainBgmVol(), 0, 0);
mpMainBgmSound->setVolume(calcMainBgmVol(), 0, SOUNDPARAM_Unk0);
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/JAZelAudio/JAIZelSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ void JAIZelSound::setSeDistanceVolume(u8 r30) {
} else {
f31 = 1.0f;
}
setSeInterVolume(4, f31, r30, 0);
setSeInterVolume(SOUNDPARAM_Distance, f31, r30, 0);
}

/* 802AF2A0-802AF314 .text setSeDistancePan__11JAIZelSoundFUc */
void JAIZelSound::setSeDistancePan(u8 r31) {
if ((getSwBit() & 0x00800000) && field_0x18 > 1) {
return;
}
setSeInterPan(4, setDistancePanCommon(), r31, 0);
setSeInterPan(SOUNDPARAM_Distance, setDistancePanCommon(), r31, 0);
}

/* 802AF314-802AF458 .text setSeDistanceDolby__11JAIZelSoundFUc */
Expand Down Expand Up @@ -110,5 +110,5 @@ void JAIZelSound::setSeDistanceDolby(u8 r30) {
}

u8 r0 = f0;
setSeInterDolby(4, r0 / 127.0f, r30, 0);
setSeInterDolby(SOUNDPARAM_Distance, r0 / 127.0f, r30, 0);
}
2 changes: 1 addition & 1 deletion src/JSystem/JAudio/JAIBankWave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void JAInter::BankWave::setWaveScene() {

/* 802914D4-80291578 .text loadSecondStayWave__Q27JAInter8BankWaveFv */
void JAInter::BankWave::loadSecondStayWave() {
if (SeMgr::seHandle->field_0x5 == 3 && flags.flag2 == 0 && initOnCodeWs) {
if (SeMgr::seHandle->mState == SOUNDSTATE_Ready && flags.flag2 == 0 && initOnCodeWs) {
for (int i = 0; initOnCodeWs[i].field_0x0; i++) {
if (initOnCodeWs[i].field_0x8 == 1) {
loadGroupWave(i, 0);
Expand Down
Loading

0 comments on commit 3e09392

Please sign in to comment.