Re: RE : Core Audio beginner questions
Re: RE : Core Audio beginner questions
- Subject: Re: RE : Core Audio beginner questions
- From: Chris Reed <email@hidden>
- Date: Sun, 22 Jun 2003 21:29:12 -0500
On Sunday, Jun 22, 2003, at 13:36 US/Central, David Scrhve wrote:
* First of all, I would like to be able to play
severals buffered
files at the same time. My code is responsible of filling
the buffer
and
reading from the files but all files have differents sounds format
(number
of channel, bytes per sample, sample rate). Should I have
to create one
AudioUnit per file and could I have severals AudioUnit with same or
different sound format ? And, am I forced to send floating point
values to
CoreAudio ?
You can create AudioConverters to convert the sound file
formats to the
canonical 32-bit float format used in CoreAudio.
Yes, but can I force the input format for one output AudioUnit
instead
of connection AudioConverters (I don't know how to connect
AudioConverter to
AudioUnit) ?
Yes you can set the input format for the output AU and it will do the
conversion for you. But if you are going to be mixing several input
streams, you will have to convert to a common format anyway.
I'd use a single output AU and manually mix the converted audio file
data.
But is it legal to create several AudioUnits ?
I'm not sure. It works, I believe, just like you can install multple
IOProcs within a process. But it's not recommended.
On the other hand, if you are using MTCoreAudio for instance, using
AudioDevices is just as easier (or easier) than AUs.
MTCoreAudio ? What's that ?
A CoreAudio wrapper framework written in Objective-C by Michael
Thornburgh. Very nice...a lot of people use it.
* Can I change the size of the buffer I sent to
CoreAudio and know
the current playback position in each buffer (I need to know, in
addition, when a buffer begin to be played ) ?
Not sure exactly what you mean here..
I would like to be able to choose the size of the buffers from the
file I send to
CoreAudio, and being able to know what's the current sound position in
the
sound buffer. For example,
if your buffer contains 4 seconds of sounds, I would like to know if
the
current position is at 1 second (but with more
accuracy than 1 second) ?
The buffers you work with are going to be more like 10 ms (512
frames=11.6 ms @ 44.1kHz) instead of 4 sec. It's up to you to manage
the larger buffers you read the file into, preferably in a separate
feeder thread.
More specifically, you provide a callback. It's either an IOProc, using
AudioDevices directly, or an input callback, for an output AU. This
callback is handed a list of buffers, a timestamp, and a number of
frames. The number of frames can be set by you, with limits. 512 or
1024 is fine for most cases. The timestamp indicates when that buffer
will be played in host time.
But for your case, you will be copying the 512 or whatever frames into
the output buffer yourself, so you will definitely know the playback
position.
Take a look at the PlayBufferedSoundFile example by Kurt Revis:
http://www.snoize.com/Code/PlayBufferedSoundFile.tar.gz (although it
uses QuickTIme for file reading and conversion).
cheers
-chris
_______________________________________________
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.