[futurebasic] Re: [FB] Re: Playing continuous sounds

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

From: Alain Pastor <apastor@...>
Date: Mon, 18 Feb 2002 00:51:21 +0100
Craig Hoyt wrote:

> I think the proper way to loop a sound is to use a callback routine as
> shown in the Sound Tutor example by Robert Hommel. This example is FBI but
> works fine in FBII. This allows any standard sound file to loop. I have
> tried several times to get it to work in FB^3 but it freezes when calling
> the callback routine. I think it has to do with the addressing of the
> callback but I can't figure it out. I am desperate for a working FB^3
> example of this. Can any of you brainiacs out there come up with a
> conversion.
> (Alain, no rev6 examples, please!)


I am unable to determine what's wrong with your conversion without
seeing the actual code.
The only thing I can say, is that mine works OK from 68K to Carbon
(Mac OS 9.2 and OS X)

My first conversion of Rommel's code was crashing my computer. I
vaguely remember it was a stupid bug in the original file perhaps
something like an uninitialized variable or maybe the use of a
pointer without allocating space. While I'm not totally sure, I
think I had to add the following statements:
tmpChan = FN NewPtrClear( SIZEOF( SndChannel ) )
err   = ( tmpChan == _nil )
at the beginning of FN SndStartLoop in the SoundUtils.Incl file.

If you have problems using the callback proc, make sure you are
using the PROC statement instead of the LINE statement used in FBII.
Make sure also that you have not messed up the proc itself, mine,
located after the END statement in the main file, looks like this:

ENTERPROC SndFinishedCallBack( chan AS ^SndChannel, myCmdPtr AS
^SndCommand )
  DIM err AS OSErr

  SELECT myCmdPtr.param1
    CASE _loopSndFLag
      err = FN SndContinueLoop( gMusicChan, gSndData )
      FN FatalError( err )
    CASE _playSndOnceFlag
      gSndFinished = _zTrue


If you are not using true records, neither typed variables check
that you are using the correct suffix for each variable.

I've just tried to run with the official Release 5 the file I send
to you. It still works. Are you trying to run the prog with a
release prior to 5?
The release 4 complains about an undefined variable type (easy to
fix declaring a sndCommand record) and about the presence of the
CarbonLib test (easily fixed by removing the few statements related
to Carbon). I bet it would continue to work on R4 with those minor changes.



FB^3 in Europe:  http://euro.futurebasic.com/
FB II Pouch:     http://www.pixmix.com/FB/outils.html