[futurebasic] Re: [FB] Sound Question

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2004 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Tue, 30 Nov 2004 21:29:58 +1300
H. Gluender wrote:

>   Robert Purves has provided the code for simultaneous (actually, it 
> isn't totally simultaneous on my 7600 machine) sound reproduction in 
> the left and right stereo channels

The demo that I posted yesterday did not explicitly synchronise the 
start of the sounds in left and right channels, partly because on my 
Mac under 10.3.6 they were already fully synchronised, and partly 
because I did not know that the Sound Manager has the ability to 
synchronise.  After reading Herbie's report, I tried the demo under 
Classic (9.2) and indeed there is a distressing time delay between 
channels :-(

The fix requires one function in the demo to be changed.  
PlaySimultaneousSounds now issues _syncCmd so as to prevent the channel 
sounds from starting independently. The final _syncCmd starts both 
channels at the same instant. This works properly in both Classic and 
OS X.


// improved version with channel synchronisation  30 Nov 2004
local fn PlaySimultaneousSounds( leftH as Handle, rightH as Handle )
'~'1
dim as SndCommand  cmd
dim as OSErr       ignore

// prepare synchronisation
cmd.cmd    = _syncCmd
cmd.param1 = 3
cmd.param2 = 12345678 // arbitrary identifier
ignore = fn SndDoImmediate( gLeftChannel, cmd )
cmd.param1 = 2
ignore = fn SndDoImmediate( gRightChannel, cmd )
// set up sounds
ignore = fn SndPlay( gLeftChannel,  leftH,  _true )
ignore = fn SndPlay( gRightChannel, rightH, _true )
// start both channels synchronised
cmd.param1 = 1 // 1 means start now
ignore = fn SndDoImmediate( gRightChannel, cmd )
end fn


Robert P.