• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Output Capture
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Output Capture
      • From: Jeff Moore <email@hidden>
  • Prev by Date: Logic Pro MIDI Device Plug-in
  • Next by Date: Re: Output Capture
  • Previous by thread: Logic Pro MIDI Device Plug-in
  • Next by thread: Re: Output Capture
  • Index(es):
    • Date
    • Thread