[futurebasic] Re: [FB] locking resource handles

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

From: Lucy24@...
Date: Sun, 2 May 1999 14:48:06 EDT
>> Also, note that you must redefine the "s$" string _every_ time just before 
you
call SOUND.  For example:

DEFSTR LONG
    :
gameSound& = FN LoadNamedSound("snork")
s$ = "&" + MKI$(gameSound&)
SOUND s$  'This plays "snork"
    :
gameSound& = FN LoadNamedSound("dwibble")
'(Failed to re-assign s$ here)
SOUND s$  'Might play "dwibble", or "snork", or...?

Any of this look similar to what you're doing? <<

Well, except that my sound names aren't as attractive, and in this app I'm 
not using a direct SOUND soundname$ statement.

I was given to understand that once I say DEFSTR LONG, it stays in effect in 
perpetuity. Did I misunderstand something? I've got one at startup and that's 
it.

The sound-playing routines in this app are essentially cribbed from Mel's 
SoundBuddy, with (apparently) the addition of some new all-original errors. 
The bit that actually _plays_ the sound goes:

CLEAR LOCAL
LOCAL FN playTheSound(hndl&,channel&,sndvol)
  DIM err
  LONG IF hndl&
    FN sndCmdNow(channel&,_ampCmd,sndvol,0) 
           'FN that sets volume
    err = FN SNDPLAY(channel&,hndl&,-1)           'send play cmd and return
    LONG IF channel& = backChannel&
      soundsOn = _true                            'mark as playing a sound
      FN cleanUpCmd(_callBackCmd)
          'I have no idea what this FN does (toolbox call SNDDOCOMMAND)!
    END IF
  END IF
END FN

.... called by various FN's, for example

LOCAL FN foregroundSound(soundname$)
  DIM err
  FN finishSound
           'FN that waits for silence in this channel
           'and gets rid of old gameSound& if there is one
  gameSound& = FN loadNamedSound(soundname$)
  LONG IF gameSound&
    FN playTheSound(gameSound&,foreChannel&,soundVolume)
  END IF
END FN

When a sound goes astray, it's something that started out in the gameSound& 
handle (for playing in foreChannel&), and then it mysteriously emerges in the 
backSound1& handle (coming out of backChannel&).