RE: Playing 2 or more audio data simultaneously
RE: Playing 2 or more audio data simultaneously
- Subject: RE: Playing 2 or more audio data simultaneously
- From: "Robert Goulet" <email@hidden>
- Date: Wed, 18 Sep 2002 14:21:07 -0400
- Thread-topic: Playing 2 or more audio data simultaneously
Ok, I'm almost bored of writting and re-writting audio implementation for our software. So I would need some basic guide lines that will prevent me from re-do all the stuff again.
[I currently have an implementation of CoreAudio. When the application starts, I query the system to get how many AudioDevice are present, and I keep them for future references.] Our application work like this:
You can add an audio file to the scene (this is a multimedia application that works with 3D animations, videos, etc.), and then, you can specify a destination to that audio clip. The destination defines on which sound card the sound will output. Then the user can add more audio clips and set the same destination for all of them.
[My implementation of CoreAudio uses an IOProc that fill an AudioBuffer. When I receive a call to that callback, my job is to get next samples to be played and fill the buffer with them. Here comes the problem, I must mix the audio data by myself, which is not convenient.]
What would be the easiest modification of that program so I could play multiple file simultaneously?
-----Original Message-----
From: Kurt Revis [
mailto:email@hidden]
Sent: Wednesday, September 18, 2002 1:01 PM
To: Robert Goulet
Cc: CoreAudio mailing list (E-mail)
Subject: Re: Playing 2 or more audio data simultaneously
On Wednesday, September 18, 2002, at 08:28 AM, Robert Goulet wrote:
>
It is possible to mix sound with core audio? I'm currently able to
>
play a single audio file because I don't understand how am I suppose
>
to have more than one buffer in my output audio buffer list that I
>
receive in my AudioIOProc.
This is not difficult at all; here's an overview. Use a mixer AudioUnit
to mix multiple audio streams into one stream. You set up an input
callback on the mixer, so it will ask you for data for each stream when
it needs it. On the output side, you can do two things:
1. Use one of the default audio output AudioUnits (see
AudioToolbox/DefaultAudioOutput.h). You can connect the mixer directly
to this, and your application won't need to implement an IO proc
anymore. This is definitely the easiest route.
2. Keep using the same IO proc that you're using now, but in it, ask
the mixer AU for data using AudioUnitRender() (or
AudioUnitRenderSlice() if the mixer AU is still a version-1 AU).
Despite what the other poster said, it's definitely not recommended to
set up more than one IO proc on the same output in the same
application. I think it works, but it will cost you CPU time and
increase the total load on the system, and will be confusing too.
Hope this helps.
--
Kurt Revis
email@hidden
_______________________________________________
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.