mirror of
https://github.com/CTurt/dsgmLib.git
synced 2025-06-18 22:55:33 -04:00
Improvements to the sound handling
Still not great though
This commit is contained in:
parent
4f10b3023e
commit
afcb086c93
Binary file not shown.
@ -408,6 +408,7 @@ void player_create(playerObjectInstance *me) {
|
||||
else {
|
||||
DSGM_DrawText(DSGM_TOP, 1, 5, "Room_2");
|
||||
}
|
||||
|
||||
DSGM_PlaySound(FlatOutLies);
|
||||
}
|
||||
|
||||
@ -477,14 +478,5 @@ void player_loop(playerObjectInstance *me) {
|
||||
}
|
||||
|
||||
void player_touch(playerObjectInstance *me) {
|
||||
//mmStop();
|
||||
//DSGM_Sounds[FlatOutLies].loaded = false;
|
||||
//DSGM_PlaySound(FlatOutLies);
|
||||
//mmLoad(DSGM_Sounds[FlatOutLies].ID);
|
||||
//swiWaitForVBlank();
|
||||
//mmStart(DSGM_Sounds[FlatOutLies].ID, MM_PLAY_LOOP);
|
||||
|
||||
DSGM_GotoNextRoom(false);
|
||||
/*if(DSGM_currentRoom == Room_1) DSGM_SwitchRoom(Room_2, false);
|
||||
else if(DSGM_currentRoom == Room_2) DSGM_SwitchRoom(Room_1, false);*/
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define DSGM_MAX_SOUNDS 32
|
||||
#define DSGM_MAX_SOUND_EFFECT_INSTANCES 32
|
||||
#define DSGM_RESERVED_STREAMS 1
|
||||
|
||||
#define DSGM_SOUND_STREAM 0
|
||||
@ -28,8 +28,10 @@ typedef struct {
|
||||
|
||||
extern int DSGM_soundStreamCount;
|
||||
|
||||
extern DSGM_SoundInstance DSGM_soundInstances[DSGM_MAX_SOUNDS];
|
||||
extern int DSGM_soundInstanceCount;
|
||||
extern DSGM_SoundInstance DSGM_soundStreamInstance;
|
||||
|
||||
extern DSGM_SoundInstance DSGM_soundEffectInstances[DSGM_MAX_SOUND_EFFECT_INSTANCES];
|
||||
extern int DSGM_soundEffectInstanceCount;
|
||||
|
||||
void DSGM_InitSoundFull(int soundStreamCount);
|
||||
void DSGM_ResetSound(void);
|
||||
|
BIN
lib/libdsgm.a
BIN
lib/libdsgm.a
Binary file not shown.
@ -85,9 +85,9 @@ void DSGM_LoopRoom(DSGM_Room *room) {
|
||||
DSGM_ValidateRoom();
|
||||
|
||||
//+1?
|
||||
for(sound = 0; sound < DSGM_soundInstanceCount; sound++) {
|
||||
DSGM_SetSoundInstanceVolumeFull(&DSGM_soundInstances[sound], DSGM_soundInstances[sound].volume);
|
||||
DSGM_SetSoundInstancePanningFull(&DSGM_soundInstances[sound], DSGM_soundInstances[sound].panning);
|
||||
for(sound = 0; sound < DSGM_soundEffectInstanceCount; sound++) {
|
||||
DSGM_SetSoundInstanceVolumeFull(&DSGM_soundEffectInstances[sound], DSGM_soundEffectInstances[sound].volume);
|
||||
DSGM_SetSoundInstancePanningFull(&DSGM_soundEffectInstances[sound], DSGM_soundEffectInstances[sound].panning);
|
||||
}
|
||||
|
||||
for(screen = 0; screen < 2; screen++) {
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
int DSGM_soundStreamCount = 0;
|
||||
|
||||
DSGM_SoundInstance DSGM_soundInstances[DSGM_MAX_SOUNDS];
|
||||
int DSGM_soundInstanceCount = 0;
|
||||
DSGM_SoundInstance DSGM_soundStreamInstance;
|
||||
|
||||
DSGM_SoundInstance DSGM_soundEffectInstances[DSGM_MAX_SOUND_EFFECT_INSTANCES];
|
||||
int DSGM_soundEffectInstanceCount = 0;
|
||||
|
||||
void DSGM_InitSoundFull(int soundStreamCount) {
|
||||
mmInitDefault("nitro:/soundbank.bin");
|
||||
@ -11,29 +13,33 @@ void DSGM_InitSoundFull(int soundStreamCount) {
|
||||
}
|
||||
|
||||
void DSGM_ResetSound(void) {
|
||||
/*mmStop();
|
||||
mmStop();
|
||||
mmEffectCancelAll();
|
||||
|
||||
int i;
|
||||
for(i = 0; i < DSGM_soundInstanceCount; i++) {
|
||||
if(DSGM_soundInstances[i].sound->type == DSGM_SOUND_STREAM) {
|
||||
// MaxMod is broken :(
|
||||
//mmUnload(DSGM_soundInstances[i].sound->ID);
|
||||
//DSGM_soundInstances[i].sound->loaded = false;
|
||||
}
|
||||
else {
|
||||
//mmUnloadEffect(DSGM_soundInstances[i].sound->ID - DSGM_soundStreamCount);
|
||||
//DSGM_soundInstances[i].sound->loaded = false;
|
||||
}
|
||||
if(DSGM_soundStreamInstance.sound) {
|
||||
mmUnload(DSGM_soundStreamInstance.sound->ID);
|
||||
DSGM_soundStreamInstance.sound->loaded = false;
|
||||
}
|
||||
|
||||
DSGM_soundInstanceCount = 0;*/
|
||||
int i;
|
||||
for(i = 0; i < DSGM_soundEffectInstanceCount; i++) {
|
||||
mmUnloadEffect(DSGM_soundEffectInstances[i].sound->ID - DSGM_soundStreamCount);
|
||||
DSGM_soundEffectInstances[i].sound->loaded = false;
|
||||
}
|
||||
|
||||
DSGM_soundEffectInstanceCount = 0;
|
||||
}
|
||||
|
||||
DSGM_SoundInstance *DSGM_AddSoundInstance(DSGM_Sound *sound) {
|
||||
// still playing?
|
||||
if(DSGM_soundInstanceCount == DSGM_MAX_SOUNDS) DSGM_soundInstanceCount = sound->type == DSGM_SOUND_STREAM ? 0 : DSGM_RESERVED_STREAMS;
|
||||
return &DSGM_soundInstances[DSGM_soundInstanceCount++];
|
||||
if(sound->type == DSGM_SOUND_STREAM) {
|
||||
DSGM_soundStreamInstance.sound = sound;
|
||||
return &DSGM_soundStreamInstance;
|
||||
}
|
||||
else {
|
||||
if(DSGM_soundEffectInstanceCount < DSGM_MAX_SOUND_EFFECT_INSTANCES) DSGM_soundEffectInstanceCount++;
|
||||
DSGM_soundEffectInstances[DSGM_soundEffectInstanceCount - 1].sound = sound;
|
||||
return &DSGM_soundEffectInstances[DSGM_soundEffectInstanceCount - 1];
|
||||
}
|
||||
}
|
||||
|
||||
DSGM_SoundInstance *DSGM_PlaySoundFull(DSGM_Sound *sound) {
|
||||
|
Loading…
Reference in New Issue
Block a user