[futurebasic] Sound Bites

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

From: Robert Covington <artlythere@...>
Date: Sun, 10 Feb 2002 04:09:17 -0500
Lil FB 3 demo from Apple sample code, plus some tweaks.

RC


Include "Tlbx Sounds.Incl"
/*
The below record for SndChannel needs to be installed into the above include.
*/

/*
// Already DIMmed perhaps
Begin Record SndCommand
Dim cmd    as unsigned short
Dim param1 as short
Dim param2 as long
End record

// Needs to be added.
BEGIN RECORD SndChannel  'Record for soundChannels
DIM nextChan AS ptr'*** SndChannelPtr
DIM firstMod AS Ptr// reserved for the Sound Manager //
DIM callBack AS PROC'callback procedure
DIM userInfo AS long
DIM wait AS long// The following is for internal Sound Manager use only.//
DIM cmdInProgress AS SndCommand
DIM flags AS short
DIM qLength AS short
DIM qHead AS short
DIM qTail AS short
DIM queue(128) AS SndCommand
end Record

*/

Local FN SquareWaveSynthPlay
DIM @chan  as Ptr to SndChannel
DIM @mycmd as SndCommand
DIM @count as unsigned long
DIM change as short
DIM err    as short
DIM i      as Int

/* Allocate a channel tied to the squareWaveSynth */
chan = 0
err = FN SndNewChannel (@chan,_squareWaveSynth, 0, 0)

if err then  goto "bail"

for i = 1 to 15

mycmd.cmd = _freqCmd
mycmd.param1 = 0
mycmd.param2 = 70+i

err = FN SndDoImmediate (chan, @mycmd)
if err then goto "bail"

mycmd.cmd = _timbreCmd
mycmd.param1 = 0
mycmd.param2 = 86//+(10*i)

err = FN SndDoImmediate (chan, @mycmd)
if err then goto "bail"

Delay 40 // let it ring.

next i

for i = 1 to 10

mycmd.cmd = _freqCmd
mycmd.param1 = 0
mycmd.param2 = 80-i

err = FN SndDoImmediate (chan, @mycmd)
if err then goto "bail"

mycmd.cmd = _timbreCmd
mycmd.param1 = 0
mycmd.param2 = 86//+(10*i)

err = FN SndDoImmediate (chan, @mycmd)
if err then goto "bail"
Delay 20+(i*5)// let it ring.

next i

err = FN SndDisposeChannel (chan,_false)

"bail"

END FN


FN SquareWaveSynthPlay