[futurebasic] Sound Tutor

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2002 : Group Archive : Group : All Groups

From: Richard Goodman <bhomme@...>
Date: Thu, 28 Mar 2002 09:37:02 -0800
Two questions:

Question #1: The two functions below are from Hommel's Sound Tutor for
FB^2. There has been some discussion on this forum regarding the fact that
they cause the program to crash if used on current Macs. I would like to
incorporate them into Sebastian, if possible. I need my program to know
when a melody has finished playing. Have any of the audio mavens on this
list gotten these functions to work, or derived alternate functions that
accomplish the same thing?


'---------------------------------------------------------------------
'FBSndChannelStatus(chanP&,theLength%,@theStatusP&)
'---------------------------------------------------------------------
'Current version of FB doesn't support this function, so we

'need to add it.  REQUIRES SYSTEM 7.0+!
'Pascal prototype from Inside Macintosh Vol VI:
'   FUNCTION SndChannelStatus(chan:ChannelPtr;theLength:integer;VAR
theStatus:scStatus):OSErr
'
'Calling syntax:
'   DIM theStatus.24
'   osErr=FN FBSndChannelStatus(chan&,theLength%,theStatus)
'
'If you use this routine, or one of the routines that calls it
'(SndChannelBusy or SndChannelPaused), be sure to check that your
'program is running on a Mac with System 7 or higher.
'---------------------------------------------------------------------

REM: The function below doesn't work with FB^2 or FB^3 with System 8.6

'LOCAL FN FBSndChannelStatus(chanP&,theLength%,@theStatusP&)
` subq.l  #2,SP                             ;clear room on stack for osErr%
` move.l  ^chanP&,-(SP)                     ;put chan ptr on stack
` move.w  ^theLength%,-(SP)                 ;put theLength% on stack
` move.l  ^theStatusP&,-(SP)                ;put theStatus ptr on stack
` dc.w    $203C,$0010,$0008,$A800           ;make the call
` move.w  (SP)+,D0                          ;pull osErr off stack and place
in D0
` ext.l   D0                                ;extend D0 to long
END FN

'---------------------------------------------------------------------
'SndChannelBusy(chan&)
'---------------------------------------------------------------------
'Returns TRUE (-1) if channel is playing a snd, FALSE if not
'(or osErr if there's a problem).
'
'EXAMPLE:
'
'DO                                           'loop
'UNTIL NOT(FN SndChannelBusy(chan&))          'until sound has finished playing
'---------------------------------------------------------------------
CLEAR LOCAL MODE
DIM theStatus.scStatusSize
LOCAL FN SndChannelBusy(Chan&)
  osErr=FN FBSndChannelStatus(Chan&,_scStatusSize,theStatus)
  IF osErr THEN tmp=osErr ELSE tmp=-PEEK(@theStatus+_scChannelBusy)
END FN=tmp
'End of Code

 -----------------------------------------------------------

Question #2: The present Sound Manager, working with FB^3, allows sound to
play asynchronously. That is, the program flow continues while the sound is
playing. I would like to know if there is a way to get the sound to play
synchronously, so that the program flow is halted until a melody has
finished playing.

Both of my questions are related; if I can accomplish either of them, then
I will be able to inform the user when a melody has finished playing.

Thanks for any help.

Richard