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

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

From: Alain Pastor <pixmix@...>
Date: Fri, 21 Jun 2002 08:00:57 +0200
Ian Mann wrote:
> 
> Peter Bancroft wrote:
> 
> > >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
> >
> 
> I believe that SndStartFilePlay and SndStopFilePlay have been canned in carbon.
> To keep going you will need to develop QuickTime work rounds.
> 

I was about to post on that topic since I had to do tech support a few
days ago about SndStartFilePlay not working in Carbon, but I think
that Richard's problem is to play the sound synchronously. As far as I
can see in the definition of the function there's an async parameter
for that purpose I guess.
As to Carbon, I came up with the following example for a workaround
(not tested under OS X):

Include "Tlbx QuickTime.Incl"

Clear Local Mode
Local Fn SndFilePlay ( fSpec As .FSSpec )
'~'9
Dim As OSErr   err
Dim As Movie @ theSound
Dim As short @ fileRefNum

Long If Fn OpenMovieFile( #fSpec, fileRefNum, _fsRdPerm ) = _noErr

Long If Fn NewMovieFromFile( theSound, ¬
                        fileRefNum, ¬
                             #_nil, ¬
                              _nil, ¬
                   _newMovieActive, ¬
                              #_nil ) = _noErr
err = Fn CloseMovieFile( fileRefNum )
GoToBeginningOfMovie( theSound )
StartMovie(theSound)
Do
MoviesTask( theSound, 0 )
Until Fn IsMovieDone( theSound )

End If
End If

End Fn


// test
Window 1

Dim theSpec As FSSpec

Long If Fn EnterMovies = _noErr
Long If Len( Files$( _FSSpecOpen, "","Choisir un fichier son", theSpec
) )
Fn SndFilePlay( theSpec )
End if
ExitMovies
End If


Do
Handleevents
Until Fn Button


-- 
Cheers,

Alain