void prepareExtAudioFile() { // Opening Audio File _extAudioFile = ExtAudioFile.OpenURL(_url); // Getting file data format _srcFormat = _extAudioFile.FileDataFormat; // Setting the channel number of the output format same to the input format _dstFormat = AudioUnitUtils.AUCanonicalASBD(_sampleRate, _srcFormat.ChannelsPerFrame); // setting reading format as audio unit cannonical format _extAudioFile.ClientDataFormat = _dstFormat; // getting total frame _totalFrames = _extAudioFile.FileLengthFrames; // Seeking to the file head _extAudioFile.Seek(0); }
void prepareExtAudioFile() { // Opening Audio File _extAudioFile = ExtAudioFile.OpenURL(_url); // Getting file data format _srcFormat = _extAudioFile.FileDataFormat; // Setting the channel number of the output format same to the input format _dstFormat = AudioUnitUtils.AUCanonicalASBD(_sampleRate, _srcFormat.ChannelsPerFrame); // setting reading format as audio unit cannonical format _extAudioFile.ClientDataFormat = _dstFormat; // getting total frame _totalFrames = _extAudioFile.FileLengthFrames; // Aloocating AudoBufferList _buffer = new AudioBufferList((uint)_srcFormat.ChannelsPerFrame, (uint)(sizeof(uint) * _totalFrames)); _numberOfChannels = _srcFormat.ChannelsPerFrame; // Reading all frame into the buffer _extAudioFile.Read((uint)_totalFrames, _buffer); }