void _audioUnit_RenderCallback(object sender, AudioUnitEventArgs e) { // reading buffer uint numberFrames = e.NumberFrames; numberFrames = _extAudioFile.Read(numberFrames, e.Data); // is EOF? if (numberFrames != e.NumberFrames) { // loop back to file head _extAudioFile.Seek(0); Stop(); } }
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); }