[futurebasic] Re: [FB] ON TIMER event handling

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

From: Peter Bancroft <peter@...>
Date: Fri, 21 Jun 2002 04:00:29 +1000
>If it were possible to sound
>the music synchronously rather than asynchronously, then I would have no
>problem. However, FB^3 apparently plays all music asynchronously via the
>Sound Manager. Therefore, the entire melody string is read and supplied to
>the sound queue while the first note is just sounding.
>
>Richard

What have you tried synchronously? I was playing around with this some time
ago, and from memory it looked like it could be done. Maybe if you give me
some idea of where the problem is with synchronous sound, I can nut it out.

'___________________________________________________________________________

' FUNCTION SndStartFilePlay (chan: SndChannelPtr; fRefNum: Integer;
' resNum: Integer; bufferSize: LongInt; theBuffer: Ptr;
' theSelection: AudioSelectionPtr; theCompletion: ProcPtr;
' async: Boolean): OSErr
' Ref IM : Sound p1-26, p1-36

' chan: SndChannelPtr;                  NIL - Sound Manager allocates channel
' fRefNum: Integer;                     provide a fRefNum of a file
' resNum: Integer;                      0 - play a sound file, not a resource
' bufferSize: LongInt;                  20480 min buffer size
' theBuffer: Ptr;                       NIL - Sound Manager allocate memory
' theSelection: AudioSelectionPtr;      NIL - Sound Manager plays entire sund
' theCompletion: ProcPtr;               NIL - No completion routine
' async: Boolean                        FALSE - Synchronous playback
' OSErr

'___________________________________________________________________________

CLEAR LOCAL MODE
LOCAL FN fbsndStartFilePlay (fRefNum%)
  sndChanPtr&    = _NIL
  'fRefNum%
  resID%         = 0
  bSize&         = 20480
  bPtr&          = _NIL
  selPtr&        = _NIL
  procPtr&       = _NIL
  aSync          = _FALSE

  sndErr% = FN SNDSTARTFILEPLAY (sndChanPtr&, fRefNum%, resID%, bSize&,
bPtr&, selPtr&, procPtr&, aSync)

  SELECT sndErr%
    CASE 0    : PRINT "sndErr% = 0           noErr"
    CASE -201 : PRINT "sndErr% = -201        notEnoughHardwareErr"
    CASE -203 : PRINT "sndErr% = -203        queueFull"
    CASE -204 : PRINT "sndErr% = -204        resProblem"
    CASE -205 : PRINT "sndErr% = -205        badChannel"
    CASE -206 : PRINT "sndErr% = -206        badFormat"
    CASE -207 : PRINT "sndErr% = -207        notEnoughBufferSpace"
    CASE -208 : PRINT "sndErr% = -208        badFileFormat"
    CASE -209 : PRINT "sndErr% = -209        channelBusy"
    CASE -210 : PRINT "sndErr% = -210        buffersTooSmall"
    CASE -223 : PRINT "sndErr% = -223        siInvalidCompression"
  END SELECT

END FN


Peter