[futurebasic] Re: [FB] more: SndRecord Toolbox function

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

From: Rick Brown <rbrown@...>
Date: Wed, 30 Jun 1999 22:15:49 -0500

support@... wrote:

> In further working with the code snippets posted, and comparing them
> to the converted pascal routine (which looks identical) I was still
> unable to achieve the results I expected to see from reading the
> docs at the apple site. Correct me if I am mistaken, but I am under the
> impression that calling the SndRecord function should pop up a dialog
> with stop, start, pause, play and resume recording controls.

Yes, it should.  There is a sample program in "(FB)
Examples:Handbook:Sound:SnRecord FN" which works for me.

> I seem to
> get nothing, and my call returns -108 which is not listed in the docs.

-108 means "out of memory".

>
> I call the function like this:
>
>         DIM myPoint.4, lp
>         myPoint.v = 0
>         myPoint.h = 0
>         lp = FN SndRecord(_nil,myPoint.nil, _Sigoodquality ,_nil)
>         print str$(lp)
>

> (snip)

> according to the docs sndHandle& in the function definition is
> declared @sndHandle&, but I changed it in order to be able to pass
> NIL to it. Could this be my problem? The docs say I can pass a handle
> to some storage space or NIL to use default storage space.

Yes, I think this is your problem.  Whenever the Pascal definition declares a
parameter as "VAR", the corresponding FB definition must pass the _address_ of
a variable in that parameter.  This is because the routine is going to want
want to pass something back _into_ that variable.

You can't simply pass the value _nil.  What you need to do is assign _nil to
some long-integer variable like sndH&, then pass the address of sndH& to
SndRecord.  When SndRecord returns, the variable sndH& will no longer be _nil,
but will now contain a handle (to a block which the Sound Manager created and
into which it stored the sound).  Indeed, if you just pass "_nil" (as you're
doing now), the SndRecord function has no way to pass the sound handle back to
your program.  That's why that parameter must reference a variable.

- Rick