I have the following code that works perfectly to record tracks on iOS.
string Documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); AudioSettings RecordSettings = new AudioSettings(); RecordSettings.Format = AudioToolbox.AudioFormatType.MPEG4AAC; RecordSettings.EncoderAudioQualityForVBR = AVAudioQuality.Max; RecordSettings.NumberChannels = 2; RecordSettings.SampleRate = SoundPlayer.PlaybackMixerNode.GetBusInputFormat(0).SampleRate; var url = new NSUrl(Path.Combine(Documents, "track" + CurrentTrack + ".aac")); var trackFile = new AVAudioFile(url, RecordSettings, out error);
However, the same code fails on MacOS, with the error:
Could not initialize an instance of the type 'AVFoundation.AVAssetExportSession': the native 'initWithAsset:presetName:' method returned nil.
I have tried messing with the path, adding the "Documents" folder, and printing out the path, which I can get to:
/Users/username/Documents/Xylophone/track1.aac, but this doesn't change the error. I have also tried loading with and without the
AudioSettings, no change.