[futurebasic] Re: Playing Sounds (was To dim or not)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1998 : Group Archive : Group : All Groups

From: Al Staff <AlStaff@...>
Date: Tue, 12 May 1998 20:34:36 EDT
Lucy24 said:
<<<<Oh, let's not even _talk_ about memory dribbles. The original version of
Pavilion started at 300K, crept up to 800 during gameplay... and stayed there.
The current version does a little better; I suspect stray sounds lying around
but haven't pinned it down.>>>>


Do you use the FB SOUND and SOUND END commands? I found a while back that
using them alone doesn't always release the memory after SOUND END (think it
depended on the situation, but I don't remember). What might be happening is
that each time a different sound is played, the memory useage increases by the
amount of the sound handle. However, if you replay a sound that has already
played, memory will not increase again since it's already in memory. This
would cause your memory useage to slowly increase to a certain point and then
stop, just as you said.

I got around this problem by making a global handle for my sounds (I only need
to play one at a time). I use GET1NAMEDRESOURCE to get the sound by name and
then play it with the SOUND command. I don't release it until I need to play
another sound. If you release it before it's finished playing you may get some
screeching and break up. For some reason, this fixed my problem.


LONG FN playSound (soundName$)
  IF gSndH& THEN CALL RELEASERESOURCE (gSndH&) : gSndH& = 0
  SOUND END
  gSndH& = FN GET1NAMEDRESOURCE (_"snd ", soundName$)
  LONG IF sndH&
    soundName$ = "&" + MKI$(gSndH&)
    SOUND soundName$
  END IF
END FN


Al Staffieri Jr.

AlStaff@...
http://members.aol.com/AlStaff/index.html