[comp.sys.mac.programmer] Mixing Sounds

Mark.Fong@f444.n161.z1.FIDONET.ORG (Mark Fong) (01/29/91)

 
How do you mix sounds "on-the-fly" (i.e. if one sound is playing 
asynchronously currently, another free-form sound can be mixed in together 
without cutting off the first sound.)?  I've tried a method using VBL tasks 
and actually succeeded, but it was too slow for my SE.  I've seen some games 
do it quickly, does anyone know how?
 
Thanks,
 
Mark Fong

--  
Mark Fong - via FidoNet node 1:125/777
    UUCP: ...!uunet!hoptoad!fidogate!161!444!Mark.Fong
INTERNET: Mark.Fong@f444.n161.z1.FIDONET.ORG

orpheus@reed.UUCP (P. Hawthorne) (01/30/91)

	It seems that in order to play multiple, asynchronous sounds, you
add the sounds, divide by two, then play the result.
	Sonic algebra?
	Sounds like a good band, or at least a good approach.

	Anyway, it took me a long time to get the Sound Manager working
at all, much less well, and I was wondering if there is any code out there
that does this already. Anything but reading the Sound Manager docs again!

	I understand that System 6.07 does this, but I decided not to run
that release based on some highly trusted advice.


	orpheus@reed

ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (01/31/91)

Just a note that if you're feeding sound samples direct to the standard
Mac sound output hardware, it expects the numbers to be in what I would
call "excess-128" form, rather than twos-complement form. To convert
one to the other is quite simple: just flip the top bit of the byte
(exclusive-or with 128).

So if you want to do your own mixing on sound data, you have to convert
the data to twos-complement form, do the addition and shifting, and
then convert it back.

As for dynamic mixing in 6.0.7, that only works on machines with
the Apple Sound Chip. Based on my initial *tentative* experiments,
I'd say that members of the Mac II family (including the LC) can
manage 4 channels max. The Portable, even though it has the ASC,
can only manage one.

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00