Re: Converting audio file data to Float32
Re: Converting audio file data to Float32
- Subject: Re: Converting audio file data to Float32
- From: "E. Tejkowski" <email@hidden>
- Date: Mon, 9 Nov 2009 04:17:23 -0600
On Nov 9, 2009, at 3:09 AM, tahome izwah wrote:
Looks like the conversion to your float buffer[] is wrong - could you
provide the relevant conversion code so we can take a look?
Thanks for looking.
-E
const UInt32 kSrcBufSize = 1024;
CAStreamBasicDescription dest;
//32 bit mono
dest.mSampleRate = 44100;
dest.mFormatID = 'lpcm';
dest.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked;
dest.mBytesPerPacket = 4;
dest.mFramesPerPacket = 1;
dest.mBytesPerFrame = 4;
dest.mChannelsPerFrame = 1;
dest.mBitsPerChannel = sizeof (Float32) * 8;
dest.mReserved = srcFormat.mReserved;
----------------------------------
ConvertFileToBuffer
srcFormat.Print();
//Source: 1 ch, 44100 Hz, 'lpcm' (0x0C) 16-bit little-endian signed
integer
destFormat.Print();
//Dest: 1 ch, 44100 Hz, 'lpcm' (0x09) 32-bit little-endian float
Float32 outBuff[kSrcBufSize];
while (1)
{
AudioBufferList aBL;
aBL.mNumberBuffers = 1;
aBL.mBuffers[0].mNumberChannels = 1;
aBL.mBuffers[0].mDataByteSize = kSrcBufSize;
aBL.mBuffers[0].mData = outBuff;
UInt32 numFrames = (kSrcBufSize / clientFormat.mBytesPerFrame);
err = ExtAudioFileRead (infile, &numFrames, &aBL);
XThrowIfError (err, "ExtAudioFileRead");
if (!numFrames) {
// this is our termination condition
NSLog(@"TERMINATION\n");
break;
}
for (i=0; i<kSrcBufSize; i++) {
NSLog(@"outBuff[%d] = %f\n", i, (float) outBuff[ii]);
}
}
}
_______________________________________________
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