Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!yale!mintaka!bloom-beacon!eru!luth!sunic!draken!d88-jwa From: d88-jwa@nada.kth.se (Jon Watte) Newsgroups: comp.sys.mac.programmer Subject: Re: System 7.0 sound Message-ID: <2850@draken.nada.kth.se> Date: 5 Feb 90 22:18:40 GMT References: <1629@ndmath.UUCP> Reply-To: d88-jwa@nada.kth.se (Jon W{tte) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 62 In article <1629@ndmath.UUCP> milo@ndmath.UUCP (Greg Corson) writes: >Does anyone know if Apple's upcoming system 7.0 sound manager will support >playing multiple sampled sounds at once? There are two ways of doing twin sampled sound channels. Both use several short buffers, like 0.1s each. Way 1: Quick & dirty Play the buffers one after another, but when two sounds are required, overlay the second sound over the background, like scaling them to 0.6 times the volume each and adding them. This doesn't sound too good, but is fast (as in a game) Way 2: Scientific & Cycle-stealing Sample the sounds at 11kHz, play them zero-padded at 22kHz: i.e. sampled data: 2030 4050 A0B0 C080 would become 2000 3000 4000 5000 A000 B000 C000 8000 which you would then digitally cut-filter at 11KHz and regain the previous signal (note: real-time filtering !) This is the method used by over-sampling CD players, by the way. When another sound is needed, you insert the second sound in the pad-zeros, so 6677 8899 8855 6677 overlaid with 2030 4050 A0B0 C080 would become 2066 3077 4088 5099 A088 B055 C066 8077 which would then be digitally cut-filtered at 11KHz, played at 22KHz. This is the method used in digital mixers. If you don't believe me, go look it up in nearest DSP book (Digital Signal Processing) Of course, both ways require a callback routine to prepare and play another sniplet. Probably you'd want to be one little piece ahead, to keep from clicking. Note: digital filtering is _not_ computationally cheap... Especial{y since you'll need at least 36dB/octave filtering... Happy hacking, and please mail me any source you actually do using this, since the mere thought of how hairy it all would become has kept me from writing anything arcade-style... h+ -- --- Stay alert ! - Trust no one ! - Keep your laser handy ! --- h+@nada.kth.se == h+@proxxi.se == Jon Watte longer .sig available on request