prime/src/musyx/snd_init.c

58 lines
1.2 KiB
C
Raw Normal View History

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) {
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;
s32 ret;
sndActive = 0;
2022-08-11 01:12:35 -07:00
if (voices <= 64) {
synthInfo.voiceNum = voices;
} else {
synthInfo.voiceNum = 64;
}
2022-08-11 01:12:35 -07:00
if (studios <= 8) {
synthInfo.studioNum = studios;
} else {
synthInfo.studioNum = 8;
}
rate = 32000;
synthInfo.maxMusic = music;
synthInfo.maxSFX = sfx;
ret = hwInit(&rate, synthInfo.voiceNum, synthInfo.studioNum, flags);
if (ret == 0) {
ret = DoInit(32000, aramSize, synthInfo.voiceNum, flags);
}
return ret;
2022-04-08 01:30:31 -07:00
}
void sndQuit() {
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) {
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
}