Re: Simple Audio Playback
Re: Simple Audio Playback
- Subject: Re: Simple Audio Playback
- From: William Stewart <email@hidden>
- Date: Wed, 30 Jun 2004 10:44:20 -0700
The main thing is to ensure that the format you give to the output unit
is the right one...
In the CA SDK there's the CAStreamBasicDescription class that can help
to format this...
So - set this to say stereo de-interleaved, 44K:
desc.SetCanonical (2, false);
desc.mSampleRate = 44100.;
Then - SetProperty on the output unit (to make sure it has the format
you are giving it):
SetProperty (kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0
/*element*/, &desc, &sizeofDesc)
Then your callback gets an AudioBufferList of one buffer for each
channel (as well as an int to say how many sample frames you need to
provide)
So:
for (unsigned int i = 0; i < ioData->mNumberBuffers; ++i) {
AudioBuffer &buf = ioData->mBuffers[i];
Float32* channel = static_cast<float*>(buf.mData);
for (unsigned int j = 0; j < inNumberOfFrames; ++j) {
// channel[j] through this loop is the individual sample for each
channel in the buffer list
}
}
Bill
On 29/06/2004, at 12:24 PM, email@hidden wrote:
>
Hi all,
>
I am new to this list - have been using the Carbon-Dev list for a
>
while.
>
>
I need help finding my way through the CoreAudio Documentation. I4ve
>
read just
>
about everything there is in the Apple site about Audio (CoreAudio.PDF,
>
samples, Q&As, TechNotes, headers, ..., even searched through dozens
>
of old
>
messages in your archives).
>
>
All I need to do is to send a buffer of audio data to the default
>
output, but I
>
couldn4t find any document that made it clear what APIs I do need. So
>
I would
>
appreciate it if anyone could point me out some info (maybe an old,
>
comprehensive posting) about what each group of APIs should be used
>
for. Like,
>
do I need an AudioUnit or a an AUGraph? Some examples make use of HAL.
>
Do I
>
need it?
>
>
I have simple playback needs, because due to the nature of my
>
application I
>
handle all mixing and processing before hand. All I want to do is to
>
send two
>
buffers (left and right channels) to the Default audio output. Every
>
example I
>
found (such as PlayAudioFileLite) are full of features I don4t really
>
need,
>
which makes it more complicated to understand the basics. (sorry I am
>
probably
>
too slow to get this stuff...).I managed to get "some" playback
>
working using
>
and AudioUnit in a manner similar to that found in PlayAudioFileLite
>
(see
>
below) but the app crashes right after playing with a BAD_ACCESS
>
exception. I
>
want to know if I am going in the right direction or if I am totally
>
off track
>
with this core audio stuff.
>
>
Here is a summary of what I am doing:
>
>
FindNextComponent();// to fin correct component
>
OpenAComponent(); // to acces the audio unit
>
AudioUnitSetProperty(); // to install the input callback
>
AudioUnitInitialize(); // tp prepare the audio unit
>
AudioOutputUnitStart(); // to begin pulling the audio stream from my
>
buffers
>
>
One of the things that confused the most was the way we are supposed
>
to fill the
>
AudioBufferList. Isn't it strange to use something declared as a
>
static array
>
as if it were a pointer? (please I am not criticizing anything, I am
>
jsut
>
confused, probably out of my lack of expertise with the C language). I
>
mean,
>
how exactly am I supposed to pass my buffers to the callback, assuming
>
the data
>
is previously allocated and filled with a valid audio buffer?
>
>
Sorry about the length of this message. Any help would be appreciated
>
>
Carlos.
>
>
>
-------------------------------------------------
>
Mail enviado atravis do WebMail/UnB
>
CPD - Centro de Informatica
>
_______________________________________________
>
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
________________________________________________________________________
__
Culture Ship Names:
Ravished By The Sheer Implausibility Of That Last Statement [GSV]
I said, I've Got A Big Stick [OU]
Inappropiate Response [OU]
Far Over The Borders Of Insanity And Still Accelerating [Eccentric]
________________________________________________________________________
__
_______________________________________________
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.