Re: Trying to get all samples from an audio file on disk into memory
Re: Trying to get all samples from an audio file on disk into memory
- Subject: Re: Trying to get all samples from an audio file on disk into memory
- From: Yuriy Romanchenko <email@hidden>
- Date: Sun, 01 Mar 2015 20:20:10 +0200
Sorry, my mistake.
You should allocate ioData.mBuffers[0].mDataByteSize bytes.
ioData.mBuffers[0].mData = malloc(ioData.mBuffers[0].mDataByteSize);
Regards,
Yuri.
On Mar 1, 2015, at 19:52, Patrick J. Collins <email@hidden> wrote:
> I don't understand this line:
>
>> ioData.mBuffers[0].mData = ioData.mBuffers[0].mDataByteSize;
>
> What is that doing? XCode tells me "Incompatible integer to pointer
> conversion assigning 'void *' from UInt32 (aka 'unsigned int')"
>
> I also don't understand how am I allocating space for the size of the
> buffer? Shouldn't that need to be based on the number of samples?
>
> This is what I am doing now, and I get that warning plus a crash on the ExtAudioFileRead call.
>
>
>
> ExtAudioFileRef inputFile;
>
> CheckResult(ExtAudioFileOpenURL((__bridge CFURLRef)self.url,
> &inputFile),
> "ExtAudioFileOpenURL failed");
>
> AudioStreamBasicDescription asbd;
> UInt32 propSize = sizeof(asbd);
> CheckResult(ExtAudioFileGetProperty(inputFile, kExtAudioFileProperty_FileDataFormat, &propSize, &asbd), "get description failed");
>
> UInt32 numberOfFrames = 0;
> propSize = sizeof(SInt64);
> CheckResult(ExtAudioFileGetProperty(inputFile, kExtAudioFileProperty_FileLengthFrames, &propSize, &numberOfFrames), "GetProperty failed");
>
> AudioBufferList ioData = {0};
> ioData.mNumberBuffers = 1;
> ioData.mBuffers[0].mNumberChannels = 1;
> ioData.mBuffers[0].mDataByteSize = asbd.mBytesPerPacket * numberOfFrames;
> ioData.mBuffers[0].mData = ioData.mBuffers[0].mDataByteSize;
>
> ExtAudioFileRead(inputFile, &numberOfFrames, &ioData);
>
> // output samples to check that they sound right...
>
> free(ioData.mBuffers[0].mData);
> ExtAudioFileDispose(inputFile);
>
>
> Patrick J. Collins
> http://collinatorstudios.com
_______________________________________________
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