2022-04-08 01:30:31 -07:00
|
|
|
#include "musyx/musyx_priv.h"
|
2022-12-24 14:54:58 -08:00
|
|
|
//#define _DEBUG
|
|
|
|
#include "musyx/assert.h"
|
2022-04-08 01:30:31 -07:00
|
|
|
|
2022-08-11 01:12:35 -07:00
|
|
|
s32 DoInit(u32 rate, u32 aramSize, u8 voices, u32 flags) {
|
2022-04-09 17:17:06 -07:00
|
|
|
dataInitStack();
|
|
|
|
dataInit(0, aramSize);
|
|
|
|
seqInit();
|
|
|
|
synthIdleWaitActive = 0;
|
|
|
|
synthInit(rate, voices);
|
|
|
|
streamInit();
|
|
|
|
vsInit();
|
|
|
|
s3dInit(flags);
|
|
|
|
sndActive = 1;
|
|
|
|
|
2022-08-05 12:43:46 -07:00
|
|
|
return FALSE;
|
2022-04-08 01:30:31 -07:00
|
|
|
}
|
|
|
|
|
2022-08-11 01:12:35 -07:00
|
|
|
s32 sndInit(u8 voices, u8 music, u8 sfx, u8 studios, u32 flags, u32 aramSize) {
|
2022-10-18 18:00:53 -07:00
|
|
|
u32 rate;
|
2022-04-09 17:17:06 -07:00
|
|
|
s32 ret;
|
|
|
|
|
|
|
|
sndActive = 0;
|
2022-08-11 01:12:35 -07:00
|
|
|
if (voices <= 64) {
|
2023-02-18 20:27:24 -08:00
|
|
|
synthInfo.voiceNum = voices;
|
2022-04-09 17:17:06 -07:00
|
|
|
} else {
|
2023-02-18 20:27:24 -08:00
|
|
|
synthInfo.voiceNum = 64;
|
2022-04-09 17:17:06 -07:00
|
|
|
}
|
2022-08-11 01:12:35 -07:00
|
|
|
if (studios <= 8) {
|
2023-02-18 20:27:24 -08:00
|
|
|
synthInfo.studioNum = studios;
|
2022-04-09 17:17:06 -07:00
|
|
|
} else {
|
2023-02-18 20:27:24 -08:00
|
|
|
synthInfo.studioNum = 8;
|
2022-04-09 17:17:06 -07:00
|
|
|
}
|
|
|
|
rate = 32000;
|
2023-02-18 20:27:24 -08:00
|
|
|
synthInfo.maxMusic = music;
|
|
|
|
synthInfo.maxSFX = sfx;
|
|
|
|
ret = hwInit(&rate, synthInfo.voiceNum, synthInfo.studioNum, flags);
|
2022-04-09 17:17:06 -07:00
|
|
|
if (ret == 0) {
|
2023-02-18 20:27:24 -08:00
|
|
|
ret = DoInit(32000, aramSize, synthInfo.voiceNum, flags);
|
2022-04-09 17:17:06 -07:00
|
|
|
}
|
|
|
|
return ret;
|
2022-04-08 01:30:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void sndQuit() {
|
2022-04-09 17:17:06 -07:00
|
|
|
hwExit();
|
|
|
|
dataExit();
|
|
|
|
s3dExit();
|
|
|
|
synthExit();
|
|
|
|
sndActive = 0;
|
2022-04-08 01:30:31 -07:00
|
|
|
}
|
|
|
|
|
2022-12-24 14:54:58 -08:00
|
|
|
void sndSetMaxVoices(u8 music, u8 sfx) {
|
2023-02-18 20:27:24 -08:00
|
|
|
ASSERT_MSG(music > synthInfo.voiceNum, "Music voices are above maximum voice number.");
|
|
|
|
ASSERT_MSG(sfx > synthInfo.voiceNum, "Sfx voices are above maximum voice number.");
|
|
|
|
synthInfo.maxMusic = music;
|
|
|
|
synthInfo.maxSFX = sfx;
|
2022-04-08 01:30:31 -07:00
|
|
|
}
|