[comp.sys.mac.programmer] Mixing two or more sampled sounds

milo@ndmath.UUCP (Greg Corson) (05/04/89)

I have a game which currently plays sampled sounds out of "snd" resources.

Sometimes I would like to have two or more sounds playing at the same time,
mixed together.  For example, background music with gun shounds dropped in
on top of it when the player shoots.

Anyone got any good ideas on how to do this?

Greg Corson
19141 Summers Drive
South Bend, IN 46637
(219) 277-5306 
{pur-ee,rutgers,uunet}!iuvax!ndmath!milo
 

jmunkki@kampi.hut.fi (Juri Munkki) (05/05/89)

In article <1378@ndmath.UUCP> milo@ndmath.UUCP (Greg Corson) writes:
>I have a game which currently plays sampled sounds out of "snd" resources.
>
>Sometimes I would like to have two or more sounds playing at the same time,
>mixed together.  For example, background music with gun shounds dropped in
>on top of it when the player shoots.
>
Ok. Dig up the technote about playing sounds without the click. Then
write a cdev that mixes two (or more) sound sources and feeds that to
the sampled sound synthesizer. It is a bit tricky, but it works on all
current Macintosh models.

How do I know that it works?

Well, I wrote a VBL task and a sound file converted that converts sound
to a format suitable for mixing. It uses a maximum of two channels, but
the same idea could be used to create more channels.

There are some other restrictions too. You can only play the sounds at
11 Khz (easy to change by rewriting some of the code). You can't play
different notes with a single sound. These limitations aren't too bad
if you are writing "dark castle"-style sound F/X.

The VBL task is documented, but the sound converter is ugly and I would
like to write some documentation. My idea was to send this to the usenet
programmers guide as an example of VBL tasks and the sampled sound driver.

It's written in LSC, but it is very easy to convert it into a resource
that can be run at the beginning of the program. Some related routines
can be written in almost any language that supports the toolbox.

Can I get a free "Milo", if I mail it to you? ;-)

_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
|     Juri Munkki jmunkki@hut.fi  jmunkki@fingate.bitnet        I Want   Ne   |
|     Helsinki University of Technology Computing Centre        My Own   XT   |
^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^