How to use AEAudioFileReader?

edited October 2016

Hello I need some guide on how to use readFileatURL method. I want to read the mdata and use the floats to plot a waveform.
Do i use this in the audio thread? or before?

i receive the error

ExtAudioFileSetProperty(kExtAudioFileProperty_ClientDataFormat): -50

` UInt32 leng;
AudioStreamBasicDescription desc;
desc.mSampleRate = 44100; // GIVE YOUR SAMPLING RATE
desc.mFormatID = kAudioFormatLinearPCM;
desc.mFormatFlags = kLinearPCMFormatFlagIsFloat;
desc.mChannelsPerFrame = 2; // stereo
desc.mFramesPerPacket = 1;
desc.mBytesPerPacket = desc.mFramesPerPacket * desc.mBytesPerFrame; // = sizeof(Float32)

AudioBufferList buffer;


AudioBuffer mBuffer;

[AEAudioFileReader readFileAtURL:amen.url targetAudioDescription:desc readBlock: ^(const AudioBufferList *buffer,UInt32(mBuffer)){
    printf("argument to a method call");

} completionBlock:^(NSError* error){
    printf("%s", error);
}]; `

Thanks

Comments

  • I was able to get integers by adding better parameters

    AudioStreamBasicDescription desc; desc.mSampleRate = 44100; // GIVE YOUR SAMPLING RATE desc.mFormatID = kAudioFormatLinearPCM; desc.mFormatFlags = kLinearPCMFormatFlagIsFloat; desc.mChannelsPerFrame = 1; // Mono desc.mFramesPerPacket = 1; desc.mBytesPerPacket = sizeof(Float32); desc.mBitsPerChannel = 32; desc.mBytesPerFrame = sizeof(Float32); desc.mReserved = 0;

    I just need to know how to convert the integers to float

Sign In or Register to comment.