Re: Playing lots of tiny sounds with different formats?
Re: Playing lots of tiny sounds with different formats?
- Subject: Re: Playing lots of tiny sounds with different formats?
- From: Bill Stewart <email@hidden>
- Date: Thu, 01 Aug 2002 12:41:29 -0700
on 8/1/02 2:38 AM, William Shipley wrote:
>
Ok, we've done a couple of game ports now using the low-level CoreAudio
>
stuff, and we're trying to move up to AudioUnits.
>
>
We're currently using a single AudioUnit much the way we did the raw
>
HAL -- we mix all of our sound effects and music ourselves and just hand
>
out buffers to the default output device at 44.1.
>
>
Tonight I started playing with using the higher-level features of
>
AudioToolbox and AudioUnits, and although I managed to get an reverb
>
unit attached to the default output (and MAN did that sound cool) I
>
still am fundamentally missing something.
>
>
So, given the following:
>
>
- I have 20-30 sound files that are stored at different sample rates (22
>
or 44), some stereo and some mono.
>
- During a game I need to queue these sounds in response to game
>
actions, and play them out real-time, often overlapping each other.
>
- I want to add in the ability to do stereo panning for mono samples.
>
- I'd like to add in 3D positioning under Jaguar.
>
- I don't want to do the mixing myself.
>
>
Then, how should I set up my AudioUnits to use the least CPU?
Output <- 3D Mixer <- n inputs
The 3D Mixer can take mono or stereo sources - but these will all have to be
at the same sample rate.
So, for those sources that aren't at the sample rate you need - you use the
AUConverter unit (or the AudioConverter directly)
(In fact in the SDK to be released when Jaguar is available we have some
audio file playing code that will be ideal for what you need - it uses a
converter to convert to the desired format)
>
Should I create an instance of the default output device for each format
>
of sound file I might possibly play? (Does this even work?) This would
>
create (potentially) a lot of devices that need to be serviced every
>
cycle, and still leaves me doing the mixing myself for, say, all 22K
>
mono sounds, then all 44K mono, then 22K stereo, etc.
No - it doesn't do mixing
>
Note: One thing I don't have a good grasp on is "input elements". I just
>
haven't seen any docs on them. Reading through this list for the last
>
couple of months, it looks like some (all?) audioUnits can accept
>
multiple input streams at once, through the use of input elements.
An element is like a bus on a mixing board.
So you have input and output scopes, then you have the busses that are used
on each of these scopes (So a mixer takes n inputs, where n is the elementID
- bus) and a single output (elementID == 0)
An element (or bus) should not be equated with channels as an element can
contain n-channels of audio data.
>
Which units can do this? (The stereo mixer? The default output unit?)
>
Can each input stream be configured to have a different sample rate?
>
(Can the stereo mixer accept any sample rate I throw at it? Should I be
>
pre-converting all my sound files when I launch the app?)
You'll need to get your data at the same sample rate before you mix
>
Maybe I should create and remove input elements on-the-fly on the
>
default output unit, as I start and stop each sound? Or should I have a
>
stable of input elements that are pre-configured on my mixer unit?
It doesn't do mixing, so this won't work.
>
Am I totally off-base?
No - and its partly our fault because our docs and sample code are woefully
inadequate - but we are working hard on these areas as I speak
Bill
>
RELP!
>
>
Thanks,
>
-Wil Shipley
>
President, The Omni Group
>
_______________________________________________
>
coreaudio-api mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
>
Do not post admin requests to the list. They will be ignored.
--
mailto:email@hidden
tel: +1 408 974 4056
__________________________________________________________________________
"...Been havin' some trouble lately in the sausage business," C.M.O.T.
Dibbler replied.
"What, having trouble making both ends meat?"
__________________________________________________________________________
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.