milo@ndmath.UUCP (Greg Corson) (02/06/90)
Does anyone know if Apple's upcoming system 7.0 sound manager will support playing multiple sampled sounds at once? For example, having music playing in the background then overlaying it with sound effects or voice messages (as in a game). Greg Corson 19141 Summers Drive South Bend, IN 46637 (219) 277-5306 {uunet, rutgers}!iuvax!ndmath!milo milo@ndmath GEnie: GCORSON
d88-jwa@nada.kth.se (Jon Watte) (02/06/90)
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
chaffee@reed.UUCP (Alex Chaffee) (02/06/90)
In article <2850@draken.nada.kth.se> d88-jwa@nada.kth.se (Jon W{tte) writes: |There are two ways of doing twin sampled sound channels. |Both use several short buffers, like 0.1s each. | |Way 1: Quick & dirty ... |Way 2: Scientific & Cycle-stealing | |Sample the sounds at 11kHz, play them zero-padded at 22kHz: ... |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. What a great idea. But what do you mean by "digitally cut-filter?" Would you just divide each sample by 2? And since it should be "real-time," do you think this could be implemented as a modifier? -- Alex Chaffee chaffee@reed.UUCP Reed College, Portland OR 97202 ____________________
d88-jwa@nada.kth.se (Jon Watte) (02/07/90)
In article <14075@reed.UUCP> chaffee@reed.UUCP (Alex Chaffee) writes: >In article <2850@draken.nada.kth.se> d88-jwa@nada.kth.se (Jon W{tte) writes: >|Way 2: Scientific & Cycle-stealing >|Sample the sounds at 11kHz, play them zero-padded at 22kHz: >|2000 3000 4000 5000 A000 B000 C000 8000 Note, you still play byte-by-byte ! 20 00 30 00 40 00 ... As you can see, this introduces a note with frequency equal to half the sampling rate. There is a weird frequency-shift-reversal going on as well that doesn't sound good. This is why you need to filter the sound. 20 00 30 00 40 00 ... _might_ become: 1E 28 32 38 40 46 ... or something else, depending on the filter and surrounding data. >|which you would then digitally cut-filter at 11KHz and regain the >What a great idea. But what do you mean by "digitally cut-filter?" Would >you just divide each sample by 2? And since it should be "real-time," do >you think this could be implemented as a modifier? "Cut-filter" is shorthand for a steep low-pass filter. With this I mean, filter the sound so there's practically nothing left of the tone at half the sampling rate. (Really, you should cut at 120 dB just above one quarter of the sampling rate to be orthodoz, but this is too computationally expensive to even think about doing something else at the same time. Besides, the filter out to the mac speaker isn't good enough anyway, so why waste time ?) A sound modifier works on the sound COMMAND, not the actual data, so that mechanism would be awkward in this case. Best is to filter the buffer just before you pass the bufferCmd. h+ -- --- Stay alert ! - Trust no one ! - Keep your laser handy ! --- h+@nada.kth.se == h+@proxxi.se == Jon Watte longer .sig available on request