int sfx;
int c = 1;
main()
{
while (1) {
if (c==1) sfx = snd_sfx_load("/rd/1.wav")
else if (c==2) sfx = snd_sfx_load("/rd/2.wav")
else if (c==3) sfx = snd_sfx_load("/rd/3.wav")
c=playgame();
snd_sfx_unload(sfx);
}
}
int playgame() {
// do a bunch of stuff here
snd_sfx_play(sfx);
// do a bunch of more stuff here
return random; //random is between 1 and 3
}
snd_sfx_load and unload, garbled sfx
-
- DCEmu Freak
- Posts: 71
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu Feb 20, 2003 11:46 am
- Has thanked: 1 time
- Been thanked: 0
- Contact:
snd_sfx_load and unload, garbled sfx
My code looks like this (simplified):
The first snd_sfx_play works just fine, but after that the sfx comes out garbled. Is there any problem in keeping unloading and loading the way I'm doing?
- BB Hood
- DC Developer
- Posts: 189
- Joined: Fri Mar 30, 2007 12:09 am
- Has thanked: 41 times
- Been thanked: 10 times
Re: snd_sfx_load and unload, garbled sfx
In my personal opinion it is not a good idea to unload sfx continuously. Just load all the files upfront and depending on the value of 'c', play the correct sfx.
-
- DCEmu Freak
- Posts: 71
- Joined: Thu Feb 20, 2003 11:46 am
- Has thanked: 1 time
- Been thanked: 0
- Contact:
Re: snd_sfx_load and unload, garbled sfx
Yep that's how I fixed it, my concern is that we have less than 2Mb of memory to work with and I'd like to streamline the memory usage. Thank you for your response.