Re: AudioConverter
Re: AudioConverter
- Subject: Re: AudioConverter
- From: Christof Faller <email@hidden>
- Date: Tue, 21 Jan 2003 16:38:21 +0200
Here just a snipped of code, how I use AudioConverter for audio output:
(let me know if you have any additional questions)
OSStatus MyACInputProc2(
AudioConverterRef inAudioConverter,
UInt32* outDataSize,
void** outData,
void* inUserData)
{
UInt32 nBytes;
// you determine how many frames you provide at once
// (in this case it is FRAME_SIZE2 frames per block)
nBytes = FRAME_SIZE2*SAMPLESIZE*NOUTCHAN2;
// function call to put the samples into the global
// buffer myaudiobuf
getaudiodata(myaudiobuf);
// pass data to AudioConverter
*outData = myaudiobuf;
*outDataSize = nBytes;
return noErr;
}
OSStatus OutputIOProc(
AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* device)
{
OSStatus myErr;
char outOK;
int nOutCh, nOutFrames;
int clientNum;
UInt32 nBytes;
Float32 *outBuf;
Float32* buf;
int i, n;
long message;
unsigned char *data1, *data2;
/* error checking, init */
outOK = (outOutputData != NULL) && (outOutputData->mNumberBuffers >
0);
if (outOK == 0) {
fprintf(stderr, "Output or input not active!\n");
exit(0);
}
nOutCh = outOutputData->mBuffers[0].mNumberChannels;
if (nOutCh != NOUTCHAN1) {
fprintf(stderr, "Number of output channels wrong!\n");
exit(0);
}
nOutFrames = outOutputData->mBuffers[0].mDataByteSize / nOutCh /
sizeof(Float32);
if (nOutFrames != FRAME_SIZE1) {
fprintf(stderr, "Device buffer size not equal to FRAME_SIZE1!\n");
exit(0);
}
outBuf = outOutputData->mBuffers[0].mData;
nBytes = outOutputData->mBuffers[0].mDataByteSize;
myErr = AudioConverterFillBuffer(
converter2,
MyACInputProc2,
NULL,
&nBytes,
outBuf);
if (myErr != noErr) {
fprintf(stderr, "Error while using AudioConverter 2!\n");
exit(0);
}
return noErr;
}
_______________________________________________
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.