52
53
var dict = new NSMutableDictionary ();
54
dict.SetObject (new NSNumber ((int) AudioFormat), AVAudioPlayer.AVFormatIDKey);
55
dict.SetObject (new NSNumber (SampleRate), AVAudioPlayer.AVSampleRateKey);
56
dict.SetObject (new NSNumber (NumberChannels), AVAudioPlayer.AVNumberOfChannelsKey);
55
dict.SetObject (new NSNumber ((int) AudioFormat), AVAudioSettings.AVFormatIDKey);
56
dict.SetObject (new NSNumber (SampleRate), AVAudioSettings.AVSampleRateKey);
57
dict.SetObject (new NSNumber (NumberChannels), AVAudioSettings.AVNumberOfChannelsKey);
58
59
if (AudioFormat == AudioFormatType.LinearPCM){
59
60
IntPtr thandle = CFBoolean.True.Handle;
62
63
if (LinearPcmBitDepth != 0){
63
64
if (LinearPcmBitDepth == 8 || LinearPcmBitDepth == 16 || LinearPcmBitDepth == 32 || LinearPcmBitDepth == 24)
64
dict.SetObject (new NSNumber (LinearPcmBitDepth), AVAudioRecorder.AVLinearPCMBitDepthKey);
65
dict.SetObject (new NSNumber (LinearPcmBitDepth), AVAudioSettings.AVLinearPCMBitDepthKey);
66
67
throw new Exception ("Invalid value for LinearPcmBitDepth, must be one of 8, 16, 24 or 32");
68
dict.LowlevelSetObject (LinearPcmBigEndian ? thandle : fhandle, AVAudioRecorder.AVLinearPCMIsBigEndianKey.Handle);
69
dict.LowlevelSetObject (LinearPcmFloat ? thandle : fhandle, AVAudioRecorder.AVLinearPCMIsFloatKey.Handle);
70
dict.LowlevelSetObject (LinearPcmNonInterleaved ? thandle : fhandle, AVAudioRecorder.AVLinearPCMIsNonInterleaved.Handle);
69
dict.LowlevelSetObject (LinearPcmBigEndian ? thandle : fhandle, AVAudioSettings.AVLinearPCMIsBigEndianKey.Handle);
70
dict.LowlevelSetObject (LinearPcmFloat ? thandle : fhandle, AVAudioSettings.AVLinearPCMIsFloatKey.Handle);
71
dict.LowlevelSetObject (LinearPcmNonInterleaved ? thandle : fhandle, AVAudioSettings.AVLinearPCMIsNonInterleaved.Handle);
72
dict.SetObject (new NSNumber ((int) AudioQuality), AVAudioRecorder.AVEncoderAudioQualityKey);
73
dict.SetObject (new NSNumber ((int) AudioQuality), AVAudioSettings.AVEncoderAudioQualityKey);
73
74
if (EncoderBitRate.HasValue)
74
dict.SetObject (new NSNumber ((int) EncoderBitRate.Value), AVAudioRecorder.AVEncoderBitRateKey);
75
dict.SetObject (new NSNumber ((int) EncoderBitRate.Value), AVAudioSettings.AVEncoderBitRateKey);
75
76
if (EncoderBitRatePerChannel.HasValue)
76
dict.SetObject (new NSNumber ((int) EncoderBitRatePerChannel.Value), AVAudioRecorder.AVEncoderBitRatePerChannelKey);
77
dict.SetObject (new NSNumber ((int) EncoderBitRatePerChannel.Value), AVAudioSettings.AVEncoderBitRatePerChannelKey);
77
78
if (EncoderBitDepthHint.HasValue){
78
79
var n = EncoderBitDepthHint.Value;
79
80
if (n < 8 || n > 32)
80
81
throw new Exception ("EncoderBitDepthHint should be a value between 8 and 32");
81
dict.SetObject (new NSNumber ((int) EncoderBitDepthHint.Value), AVAudioRecorder.AVEncoderBitDepthHintKey);
82
dict.SetObject (new NSNumber ((int) EncoderBitDepthHint.Value), AVAudioSettings.AVEncoderBitDepthHintKey);
83
84
if (SampleRateConverterAudioQuality.HasValue)
84
dict.SetObject (new NSNumber ((int) SampleRateConverterAudioQuality.Value), AVAudioRecorder.AVSampleRateConverterAudioQualityKey);
85
dict.SetObject (new NSNumber ((int) SampleRateConverterAudioQuality.Value), AVAudioSettings.AVSampleRateConverterAudioQualityKey);
90
91
public partial class AVAudioRecorder {
91
[Obsolete ("Use the factory AVAudioRecorder.ToUrl as this method had an invalid signature up to MonoMac 1.4.4")]
92
[Obsolete ("Use static Create method as this method had an invalid signature up to MonoMac 1.4.4", true)]
92
93
public AVAudioRecorder (NSUrl url, NSDictionary settings, NSError outError)
94
95
throw new Exception ("This constructor is no longer supported, use the AVAudioRecorder.ToUrl factory method instead");
98
public static AVAudioRecorder Create (NSUrl url, AudioSettings settings, out NSError error)
100
if (settings == null)
101
throw new ArgumentNullException ("settings");
103
return ToUrl (url, settings.Dictionary, out error);
106
[Advice ("Use Create method")]
97
107
public static AVAudioRecorder ToUrl (NSUrl url, AVAudioRecorderSettings settings, out NSError error)
99
109
if (settings == null)