Re: reading audiofile into floatbuffer
Re: reading audiofile into floatbuffer
- Subject: Re: reading audiofile into floatbuffer
- From: stiwi kirch <email@hidden>
- Date: Sun, 18 Jan 2004 00:01:05 +0100
Ok. I am getting closer ;) With some code from Robert and Wesley it
kinda works. Thanks.
// in my .h file
AudioFileID mFileID;
AudioConverterRef mConverter;
AUBufferList mAUBuffer;
AudioBufferList *mTable;
void *mEntireFileBuffer // used by readFileIntoMemory;
AudioStreamBasicDescription mFloatASBD; // Roberts Float description;
AudioStreamBasicDescription mFileASBD; // returned from getFileInfo;
UInt64 mPacketCount; // returned from getFileInfo;
UInt64 mByteCount; // returned from getFileInfo;
UInt32 mMaxPacketSize; // returned from getFileInfo;
UInt32 mReadBytes; // returned from readFileIntoMemory;
UInt32 mReadPackets; // returned from readFileIntoMemory;
// in my .cpp file
call getFileInfo(fileName);
call readFileIntoMemory();
call createConverter();
call convertData();
OSStatus WaveTable::convertData()
{
OSStatus err = noErr;
UInt32 numFrames = mReadPackets;
mAUBuffer.Allocate(mFloatASBD, mReadPackets);
mTable = &mAUBuffer.PrepareBuffer(mFloatASBD, mReadPackets);
// is this the right way to get my AudioBufferList mTable?
err = AudioConverterFillComplexBuffer(mConverter, ACInputProc, this,
&numFrames, &mAUBuffer.GetBufferList(), NULL);
if (err != noErr)
printf("WaveTable::convertData: error filling complex buffer\n");
return err;
}
call someCheckingAndCleanup(); // dispose mEntireFileBuffer etc.
Now i am trying to read from my converted data buffer (mTable) like
this. (dummycode!)
int waveSize = mTable->mBuffers[0].mDataByteSize;
float* outputL = (float*)(mTable->mBuffers[0].mData);
float* outputR = (float*)(mTable->mBuffers[1].mData); // check if
mNumberBuffers == 2 ;)
for (int sample = 0; sample < waveSize; sample++)
{
doSomethingWith(outputL[sample]);
// doSomethingWith(outputR[sample]);
}
but this crashes my AU after cycling a few times through mTable!
Any suggestion?
stiwi
_______________________________________________
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.