Output Capture
Output Capture
- Subject: Output Capture
- From: email@hidden
- Date: Wed, 18 Jul 2007 12:57:50 -0600
Hi, I have set up a little callback to get the samples from the
default device. I just copy the input and output into global buffers
and then draw those on a gworld with SetCPixel(). Anyway, I can see
my voice when I speak, but I have tried everything and can't seem to
capture the mac's sound output. Does anyone know of code to get the
output as an input? Is it supported by the OS?
FYI I am using this for echo cancellation. Ideally I'd like to get
the Mac's entire sound output, but just the output of the app is fine
too.
Thanx,
--Zack
////////////////////////////////////////////////////////////
#include <CoreAudio/CoreAudio.h>
float inSamples[512];
float outSamples[512];
OSStatus recordIOProc ( AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* inClientData )
{
int spot;
if( inInputData )
{
spot = 0;
for( int i = 0; i < inInputData->mNumberBuffers; i++ )
{
for( int j = 0; j < inInputData->mBuffers[i].mDataByteSize/sizeof
( float ); j++ )
{
inSamples[spot++] = ((float*) inInputData->mBuffers[i].mData)[j];
if( spot >= 512 ) break;
}
if( spot >= 512 ) break;
}
}
if( outOutputData )
{
spot = 0;
for( int i = 0; i < outOutputData->mNumberBuffers; i++ )
{
for( int j = 0; j < outOutputData->mBuffers[i].mDataByteSize/sizeof
( float ); j++ )
{
outSamples[spot++] = ((float*) outOutputData->mBuffers[i].mData)[j];
if( spot >= 512 ) break;
}
if( spot >= 512 ) break;
}
}
return noErr;
}
AudioDeviceID audioDevice;
Boolean audioDeviceInited = false;
void InitSoundCapture( void )
{
if( audioDeviceInited ) return;
UInt32 theSize = sizeof( AudioDeviceID );
AudioHardwareGetProperty( kAudioHardwarePropertyDefaultOutputDevice,
&theSize, &audioDevice );
//AudioHardwareGetProperty
( kAudioHardwarePropertyDefaultSystemOutputDevice, &theSize,
&audioDevice );
AudioDeviceAddIOProc( audioDevice, recordIOProc, NULL );
AudioDeviceStart( audioDevice, recordIOProc );
audioDeviceInited = true;
}
void DisposeSoundCapture( void )
{
if( !audioDeviceInited ) return;
AudioDeviceStop( audioDevice, recordIOProc );
AudioDeviceRemoveIOProc( audioDevice, recordIOProc );
audioDeviceInited = false;
}
_______________________________________________
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