Re: Beginner question
Re: Beginner question
- Subject: Re: Beginner question
- From: Chris Liscio <email@hidden>
- Date: Tue, 14 Sep 2004 13:32:31 -0400
Hi Alexander,
On Mon, 13 Sep 2004 23:02:52 -0400, Alexander Dvorak
<email@hidden> wrote:
> What I have been able to figure out...
> I need to
> 1. Include the line "#import <CoreAudio/CoreAudio.h>" in my file to
> access the core audio functions.
> 2. Get the default input audio device (internal microphone) using
> AudioHardwareGetProperty().
> 3. Add a ioproc to the input audio device using AudioDeviceAddIOProc()
> 4. Use AudioDeviceStart() to start the recording and AudioDeviceStop()
> to stop it.
> 5. Use AudioDeviceRemoveIOProc() when done to clean up
So far, so good...
> What I don't understand...
> 1. What is an ioProc? What would I include in this function if I want
> to record from the input audio device?
> 2. Do I get the sound from the device using this function? Does it go
> into a buffer which then can be saved into an aiff file?
1. An IOProc is a callback function that will be called by the
CoreAudio system repeatedly to feed you with data. You are fed via
the AudioBufferList pointers that point to your input/output buffers.
2. To grab the sound from the microphone, you would use the
inInputData->mBuffers[0].mData pointer to retrieve the data. On my
system, this is a list of floats multiplexed in a left, right, left,
right fashion. So, you essentially take that data from that buffer
and throw it into whatever file format you wish to use. I believe
most audio file formats will retain a similar multiplexed data
structure, so it shouldn't be too difficult to do the conversion
yourself.
I'm not sure that writing the data to disk during the IOProc is
necessary, given what you described what you want to do. You can pass
a pointer along to the IOProc that would allow you to send Cocoa
messages to the object that set up the IOProc in the first place. In
my app, I ask my measurement object for its inputBuffer pointer and
fill it accordingly.
> As you can see, I have read the core audio documentation, but am
> missing a few conceptual ideas in how to get this to work. Thank you
> in advance for any explanation you can give.
If you plan on doing things purely in Cocoa, and want to try a
Cocoa-based solution, I would suggest you also take a look at the
MTCoreAudio framework
(http://aldebaran.armory.com/~zenomt/macosx/MTCoreAudio/). The
included examples are great for illustrating what you can do in a
Cocoa app. They cover device setup, input, and output.
For all the pros on the list, please feel free to correct any mistakes
I made, as I'm also in the learning phase. ;)
Hope this helps,
Chris
http://www.supermegaultragroovy.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden