~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/maccore/src/AudioUnit/AudioUnit.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
ļ»æ//
2
2
// AudioUnit.cs: AudioUnit wrapper class
3
3
//
4
 
// Author:
 
4
// Authors:
5
5
//   AKIHIRO Uehara (u-akihiro@reinforce-lab.com)
 
6
//   Marek Safar (marek.safar@gmail.com)
6
7
//
7
8
// Copyright 2010 Reinforce Lab.
 
9
// Copyright 2011, 2012 Xamarin Inc
8
10
//
9
11
// Permission is hereby granted, free of charge, to any person obtaining
10
12
// a copy of this software and associated documentation files (the
36
38
{
37
39
        public enum AudioUnitStatus {
38
40
                NoError = 0,
 
41
                OK = NoError,
39
42
                ParameterError = -50,
40
43
                InvalidProperty = -10879,
41
44
                InvalidParameter = -10878,
55
58
                InvalidOfflineRender = -10848,
56
59
                Unauthorized = -10847,
57
60
        }
 
61
 
 
62
        public enum AudioCodecManufacturer : uint
 
63
        {
 
64
                AppleSoftware   = 0x6170706c,   // 'appl'
 
65
                AppleHardware   = 0x61706877,   // 'aphw'
 
66
        }
58
67
        
59
68
        public class AudioUnitException : Exception {
60
69
                static string Lookup (int k)
120
129
                {
121
130
                }
122
131
        }
 
132
 
 
133
        public delegate AudioUnitStatus RenderDelegate (AudioUnitRenderActionFlags actionFlags, AudioTimeStamp timeStamp, uint busNumber, uint numberFrames, AudioBuffers data);
 
134
 
 
135
        delegate AudioUnitStatus RenderCallbackShared (IntPtr clientData, ref AudioUnitRenderActionFlags actionFlags, ref AudioTimeStamp timeStamp, uint busNumber, uint numberFrames, IntPtr data);
 
136
 
 
137
        struct AURenderCallbackStruct
 
138
        {
 
139
                public RenderCallbackShared Proc;
 
140
                public IntPtr ProcRefCon; 
 
141
        }
123
142
        
124
 
        public class AudioUnit : IDisposable, MonoMac.ObjCRuntime.INativeObject {
 
143
        public class AudioUnit : IDisposable, MonoMac.ObjCRuntime.INativeObject
 
144
        {
 
145
                static readonly RenderCallbackShared CreateRenderCallback = RenderCallbackImpl;
 
146
 
125
147
                GCHandle gcHandle;
126
148
                IntPtr handle;
127
149
                bool _isPlaying;
128
150
 
129
 
                public IntPtr Handle { get { return handle; }}
130
 
 
131
 
                public event EventHandler<AudioUnitEventArgs> RenderCallback;
132
 
                //public event EventHandler<AudioUnitEventArgs> InputCallback;
133
 
                public bool IsPlaying { get { return _isPlaying; } }
 
151
                RenderDelegate render;
134
152
 
135
153
                internal AudioUnit (IntPtr ptr)
136
154
                {
137
155
                        handle = ptr;
 
156
                        gcHandle = GCHandle.Alloc(this);
138
157
                }
139
158
                
140
159
                public AudioUnit (AudioComponent component)
148
167
                        if (err != 0)
149
168
                                throw new AudioUnitException (err);
150
169
                        
151
 
                        _isPlaying = false;
152
 
                        
153
170
                        gcHandle = GCHandle.Alloc(this);
 
171
 
 
172
#pragma warning disable 612
 
173
                        BrokenSetRender ();
 
174
#pragma warning restore 612
 
175
                }
 
176
 
 
177
                [Obsolete]
 
178
                void BrokenSetRender ()
 
179
                {
154
180
                        var callbackStruct = new AURenderCallbackStrct();
155
181
                        callbackStruct.inputProc = renderCallback; // setting callback function            
156
182
                        callbackStruct.inputProcRefCon = GCHandle.ToIntPtr(gcHandle); // a pointer that passed to the renderCallback (IntPtr inRefCon) 
157
 
                        err = AudioUnitSetProperty(handle,
 
183
                        var err = AudioUnitSetProperty(handle,
158
184
                                                   AudioUnitPropertyIDType.SetRenderCallback,
159
185
                                                   AudioUnitScopeType.Input,
160
186
                                                   0, // 0 == speaker                
163
189
                        if (err != 0)
164
190
                                throw new AudioUnitException (err);
165
191
                }
 
192
 
 
193
                public AudioComponent Component {
 
194
                        get {
 
195
                                return new AudioComponent (AudioComponentInstanceGetComponent (handle));
 
196
                        }
 
197
                }
 
198
 
 
199
                public IntPtr Handle {
 
200
                        get {
 
201
                                return handle;
 
202
                        }
 
203
                }
 
204
 
 
205
                [Obsolete ("Use SetRenderCallback")]
 
206
                public event EventHandler<AudioUnitEventArgs> RenderCallback;
 
207
 
 
208
                public bool IsPlaying { get { return _isPlaying; } }
166
209
                
 
210
                [Obsolete]
167
211
                // callback funtion should be static method and be attatched a MonoPInvokeCallback attribute.        
168
212
                [MonoMac.MonoPInvokeCallback(typeof(AURenderCallback))]
169
213
                static int renderCallback(IntPtr inRefCon, ref AudioUnitRenderActionFlags _ioActionFlags,
190
234
                        return 0; // noerror
191
235
                }
192
236
 
193
 
                public void SetAudioFormat(MonoMac.AudioToolbox.AudioStreamBasicDescription audioFormat, AudioUnitScopeType scope, uint audioUnitElement)
 
237
                public void SetAudioFormat(MonoMac.AudioToolbox.AudioStreamBasicDescription audioFormat, AudioUnitScopeType scope, uint audioUnitElement = 0)
194
238
                {
195
239
                        int err = AudioUnitSetProperty(handle,
196
240
                                                       AudioUnitPropertyIDType.StreamFormat,
201
245
                        if (err != 0)
202
246
                                throw new AudioUnitException (err);
203
247
                }
204
 
                public MonoMac.AudioToolbox.AudioStreamBasicDescription GetAudioFormat(AudioUnitScopeType scope, uint audioUnitElement)
 
248
 
 
249
                public AudioStreamBasicDescription GetAudioFormat(AudioUnitScopeType scope, uint audioUnitElement = 0)
205
250
                {
206
251
                        MonoMac.AudioToolbox.AudioStreamBasicDescription audioFormat = new AudioStreamBasicDescription();
207
252
                        uint size = (uint)Marshal.SizeOf(audioFormat);
218
263
                        return audioFormat;
219
264
                }
220
265
                
221
 
                public void SetEnableIO(bool enableIO, AudioUnitScopeType scope, uint audioUnitElement)
 
266
                public AudioUnitStatus SetEnableIO (bool enableIO, AudioUnitScopeType scope, uint audioUnitElement = 0)
222
267
                {                                   
223
 
                        uint flag = (uint)(enableIO ? 1 : 0);
224
 
                        int err = AudioUnitSetProperty(handle,
225
 
                                                       AudioUnitPropertyIDType.EnableIO,
226
 
                                                       scope,
227
 
                                                       audioUnitElement,
228
 
                                                       ref flag,
229
 
                                                       (uint)Marshal.SizeOf(typeof(uint)));
230
 
                        if (err != 0)
231
 
                                throw new AudioUnitException (err);
232
 
                }
233
 
                        
 
268
                        uint flag = enableIO ? (uint)1 : 0;
 
269
                        return AudioUnitSetProperty (handle, AudioUnitPropertyIDType.EnableIO, scope, audioUnitElement, ref flag, sizeof (uint));
 
270
                }
 
271
 
 
272
                public AudioUnitStatus SetMaximumFramesPerSlice (uint value, AudioUnitScopeType scope, uint audioUnitElement = 0)
 
273
                {
 
274
                        return AudioUnitSetProperty (handle, AudioUnitPropertyIDType.MaximumFramesPerSlice, scope, audioUnitElement, ref value, sizeof (uint));
 
275
                }
 
276
 
 
277
                #region SetRenderCallback
 
278
 
 
279
                public AudioUnitStatus SetRenderCallback (RenderDelegate renderDelegate, AudioUnitScopeType scope, uint audioUnitElement = 0)
 
280
                {
 
281
                        var cb = new AURenderCallbackStruct ();
 
282
                        cb.Proc = CreateRenderCallback;
 
283
                        cb.ProcRefCon = GCHandle.ToIntPtr (gcHandle);
 
284
 
 
285
                        this.render = renderDelegate;
 
286
 
 
287
                        return AudioUnitSetProperty (handle, AudioUnitPropertyIDType.SetRenderCallback, scope, audioUnitElement, ref cb, Marshal.SizeOf (cb));
 
288
                }
 
289
 
 
290
                [MonoPInvokeCallback (typeof (RenderCallbackShared))]
 
291
                static AudioUnitStatus RenderCallbackImpl (IntPtr clientData, ref AudioUnitRenderActionFlags actionFlags, ref AudioTimeStamp timeStamp, uint busNumber, uint numberFrames, IntPtr data)
 
292
                {
 
293
                        GCHandle gch = GCHandle.FromIntPtr (clientData);
 
294
                        var au = (AudioUnit) gch.Target;
 
295
 
 
296
                        return au.render (actionFlags, timeStamp, busNumber, numberFrames, new AudioBuffers (data));
 
297
                }
 
298
 
 
299
                #endregion
 
300
 
234
301
                public int Initialize ()
235
302
                {
236
303
                        return AudioUnitInitialize(handle);
238
305
 
239
306
                public int Uninitialize ()
240
307
                {
241
 
                        return AudioUnitUnInitialize (handle);
 
308
                        return AudioUnitUninitialize (handle);
242
309
                }
243
310
 
244
311
                public void Start()
257
324
                        }
258
325
                }
259
326
 
 
327
                #region Render
 
328
 
 
329
                public AudioUnitStatus Render (ref AudioUnitRenderActionFlags actionFlags, AudioTimeStamp timeStamp, uint busNumber, uint numberFrames, AudioBuffers data)
 
330
                {
 
331
                        return AudioUnitRender (handle, ref actionFlags, ref timeStamp, busNumber, numberFrames, (IntPtr) data);
 
332
                }
 
333
 
 
334
                [Obsolete]
260
335
                public void Render(AudioUnitRenderActionFlags flags,
261
336
                                   AudioTimeStamp timeStamp,
262
337
                                   int outputBusnumber,
272
347
                                throw new AudioUnitException (err);
273
348
                }
274
349
 
 
350
                [Obsolete]
275
351
                public AudioUnitStatus TryRender(AudioUnitRenderActionFlags flags,
276
352
                                                AudioTimeStamp timeStamp,
277
353
                                                int outputBusnumber,
284
360
                                                                numberFrames,
285
361
                                                                data);
286
362
                }
 
363
 
 
364
                #endregion
 
365
 
 
366
                public AudioUnitStatus SetParameter (AudioUnitParameterType type, float value, AudioUnitScopeType scope, uint audioUnitElement = 0)
 
367
                {
 
368
                        return AudioUnitSetParameter (handle, type, scope, audioUnitElement, value, 0);
 
369
                }
287
370
                
288
 
                #region IDisposable ćƒ”ćƒ³ćƒ
289
371
                public void Dispose()
290
372
                {
291
373
                        Dispose (true);
292
374
                        GC.SuppressFinalize (this);
293
375
                }
294
376
                
295
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioComponentInstanceDispose")]
 
377
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
296
378
                static extern int AudioComponentInstanceDispose(IntPtr inInstance);
297
379
 
298
380
                public void Dispose (bool disposing)
299
381
                {
300
382
                        if (handle != IntPtr.Zero){
301
383
                                Stop ();
302
 
                                AudioUnitUnInitialize (handle);
 
384
                                AudioUnitUninitialize (handle);
303
385
                                AudioComponentInstanceDispose (handle);
304
386
                                gcHandle.Free();
305
387
                                handle = IntPtr.Zero;
306
388
                        }
307
389
                }
308
390
 
309
 
                /// <summary>
310
 
                /// AudioUnit call back method declaration
311
 
                /// </summary>
 
391
                [Obsolete]
312
392
                internal delegate int AURenderCallback(IntPtr inRefCon,
313
393
                                              ref AudioUnitRenderActionFlags ioActionFlags,
314
394
                                              ref AudioTimeStamp inTimeStamp,
316
396
                                              int inNumberFrames,
317
397
                                              AudioBufferList ioData);
318
398
                
 
399
                [Obsolete]
319
400
                [StructLayout(LayoutKind.Sequential)]
320
401
                class AURenderCallbackStrct {
321
402
                        public AURenderCallback inputProc;
324
405
                        public AURenderCallbackStrct() { }
325
406
                }    
326
407
 
327
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioComponentInstanceNew")]
 
408
                [DllImport(MonoMac.Constants.AudioUnitLibrary, EntryPoint = "AudioComponentInstanceNew")]
328
409
                static extern int AudioComponentInstanceNew(IntPtr inComponent, out IntPtr inDesc);
329
410
 
330
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioComponentInstanceNew")]
 
411
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
331
412
                static extern IntPtr AudioComponentInstanceGetComponent (IntPtr inComponent);
332
 
                public AudioComponent Component {
333
 
                        get {
334
 
                                return new AudioComponent (AudioComponentInstanceGetComponent (handle));
335
 
                        }
336
 
                }
337
413
                
338
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary)]
 
414
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
339
415
                static extern int AudioUnitInitialize(IntPtr inUnit);
340
416
                
341
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary)]
342
 
                static extern int AudioUnitUnInitialize(IntPtr inUnit);
 
417
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
 
418
                static extern int AudioUnitUninitialize(IntPtr inUnit);
343
419
 
344
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary)]
 
420
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
345
421
                static extern int AudioOutputUnitStart(IntPtr ci);
346
422
 
347
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary)]
 
423
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
348
424
                static extern int AudioOutputUnitStop(IntPtr ci);
349
425
 
350
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary)]
 
426
                [Obsolete]
 
427
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
351
428
                static extern int AudioUnitRender(IntPtr inUnit,
352
429
                                                  ref AudioUnitRenderActionFlags ioActionFlags,
353
430
                                                  ref AudioTimeStamp inTimeStamp,
355
432
                                                  int inNumberFrames,
356
433
                                                  AudioBufferList ioData);
357
434
 
358
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioUnitSetProperty")]
 
435
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
 
436
                static extern AudioUnitStatus AudioUnitRender(IntPtr inUnit, ref AudioUnitRenderActionFlags ioActionFlags, ref AudioTimeStamp inTimeStamp,
 
437
                                                  uint inOutputBusNumber, uint inNumberFrames, IntPtr ioData);
 
438
 
 
439
 
 
440
                [Obsolete]
 
441
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
359
442
                static extern int AudioUnitSetProperty(IntPtr inUnit,
360
443
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitPropertyIDType inID,
361
444
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitScopeType inScope,
363
446
                                                       AURenderCallbackStrct inData,
364
447
                                                       uint inDataSize);
365
448
 
366
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioUnitSetProperty")]
 
449
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
367
450
                static extern int AudioUnitSetProperty(IntPtr inUnit,
368
451
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitPropertyIDType inID,
369
452
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitScopeType inScope,
371
454
                                                       ref MonoMac.AudioToolbox.AudioStreamBasicDescription inData,
372
455
                                                       uint inDataSize);
373
456
        
374
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioUnitSetProperty")]
375
 
                static extern int AudioUnitSetProperty(IntPtr inUnit,
376
 
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitPropertyIDType inID,
377
 
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitScopeType inScope,
378
 
                                                       [MarshalAs(UnmanagedType.U4)] uint inElement,
379
 
                                                       ref uint flag,
380
 
                                                       uint inDataSize);
 
457
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
 
458
                static extern AudioUnitStatus AudioUnitSetProperty (IntPtr inUnit, AudioUnitPropertyIDType inID, AudioUnitScopeType inScope, uint inElement,
 
459
                                                       ref uint inData, uint inDataSize);
 
460
 
 
461
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
 
462
                static extern AudioUnitStatus AudioUnitSetProperty (IntPtr inUnit, AudioUnitPropertyIDType inID, AudioUnitScopeType inScope, uint inElement,
 
463
                                                       ref AURenderCallbackStruct inData, int inDataSize);
 
464
 
381
465
        
382
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioUnitGetProperty")]
 
466
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
383
467
                static extern int AudioUnitGetProperty(IntPtr inUnit,
384
468
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitPropertyIDType inID,
385
469
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitScopeType inScope,
387
471
                                                       ref MonoMac.AudioToolbox.AudioStreamBasicDescription outData,
388
472
                                                       ref uint ioDataSize);
389
473
 
390
 
                [DllImport(MonoMac.Constants.AudioToolboxLibrary, EntryPoint = "AudioUnitGetProperty")]
 
474
                [DllImport(MonoMac.Constants.AudioUnitLibrary)]
391
475
                static extern int AudioUnitGetProperty(IntPtr inUnit,
392
476
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitPropertyIDType inID,
393
477
                                                       [MarshalAs(UnmanagedType.U4)] AudioUnitScopeType inScope,
395
479
                                                       ref uint flag,
396
480
                                                       ref uint ioDataSize
397
481
                        );
398
 
                
 
482
 
 
483
                [DllImport (Constants.AudioUnitLibrary)]
 
484
                static extern AudioUnitStatus AudioUnitSetParameter (IntPtr inUnit, AudioUnitParameterType inID, AudioUnitScopeType inScope,
 
485
                        uint inElement, float inValue, uint inBufferOffsetInFrames);
399
486
        }
400
487
 
401
488
        public enum AudioUnitPropertyIDType {
404
491
                SampleRate = 2,
405
492
                ParameterList = 3,
406
493
                ParameterInfo = 4,
 
494
                CPULoad = 6,
407
495
                StreamFormat = 8,
408
496
                ElementCount = 11,
409
497
                Latency = 12,
410
498
                SupportedNumChannels = 13,
411
499
                MaximumFramesPerSlice = 14,
 
500
                ParameterValueStrings = 16,
412
501
                AudioChannelLayout = 19,
413
502
                TailTime = 20,
414
503
                BypassEffect = 21,
416
505
                SetRenderCallback = 23,
417
506
                FactoryPresets = 24,
418
507
                RenderQuality = 26,
 
508
                HostCallbacks = 27,
419
509
                InPlaceProcessing = 29,
420
510
                ElementName = 30,
421
511
                SupportedChannelLayoutTags = 32,
422
512
                PresentPreset = 36,
 
513
                OfflineRender = 37,
 
514
                DependentParameters = 45,
 
515
                InputSampleInOutput = 49,
423
516
                ShouldAllocateBuffer = 51,
424
 
 
425
 
                //Output property
426
 
                CurrentDevice                   = 2000,
427
 
                ChannelMap                              = 2002, // this will also work with AUConverter
428
 
                EnableIO                                = 2003,
429
 
                StartTime                               = 2004,
430
 
                SetInputCallback                = 2005,
431
 
                HasIO                                   = 2006,
432
 
                StartTimestampsAtZero  = 2007   // this will also work with AUConverter
433
 
        };
 
517
                ParameterHistoryInfo = 53,
 
518
                Nickname = 54,
 
519
#if MONOMAC
 
520
                FastDispatch                            = 5,
 
521
                SetExternalBuffer                       = 15,
 
522
                GetUIComponentList                      = 18,
 
523
                ContextName                                     = 25,
 
524
                CocoaUI                                         = 31,
 
525
                ParameterIDName                         = 34,
 
526
                ParameterClumpName                      = 35,
 
527
                ParameterStringFromValue        = 33,
 
528
                ParameterValueFromString        = 38,
 
529
                IconLocation                            = 39,
 
530
                PresentationLatency                     = 40,
 
531
                AUHostIdentifier                        = 46,
 
532
                MIDIOutputCallbackInfo          = 47,
 
533
                MIDIOutputCallback                      = 48,
 
534
                ClassInfoFromDocument           = 50,
 
535
                FrequencyResponse                       = 52,
 
536
#endif
 
537
                // Output Unit
 
538
                CurrentDevice                           = 2000,
 
539
                IsRunning                                       = 2001,
 
540
            ChannelMap                                  = 2002, // this will also work with AUConverter
 
541
            EnableIO                                    = 2003,
 
542
            StartTime                                   = 2004,
 
543
            SetInputCallback                    = 2005,
 
544
            HasIO                                               = 2006,
 
545
            StartTimestampsAtZero               = 2007, // this will also work with AUConverter
 
546
 
 
547
            // TODO: Many more are missing but maybe we shold split it by AudioComponentType 
 
548
        }
 
549
 
 
550
        public enum AudioUnitParameterType
 
551
        {
 
552
                // Reverb applicable to the 3DMixer
 
553
                ReverbFilterFrequency                           = 14,
 
554
                ReverbFilterBandwidth                           = 15,
 
555
                ReverbFilterGain                                        = 16,
 
556
 
 
557
                // AUMultiChannelMixer
 
558
                MultiChannelMixerVolume                         = 0,
 
559
                MultiChannelMixerEnable                         = 1,
 
560
                MultiChannelMixerPan                            = 2,
 
561
 
 
562
                // AUMatrixMixer unit
 
563
                MatrixMixerVolume                                       = 0,
 
564
                MatrixMixerEnable                                       = 1,
 
565
        
 
566
                // AudioDeviceOutput, DefaultOutputUnit, and SystemOutputUnit units
 
567
                HALOutputVolume                                         = 14, 
 
568
 
 
569
                // AUTimePitch, AUTimePitch (offline), AUPitch units
 
570
                TimePitchRate                                           = 0,
 
571
#if MONOMAC
 
572
                TimePitchPitch                                          = 1,
 
573
                TimePitchEffectBlend                            = 2,
 
574
#endif
 
575
 
 
576
                // AUNewTimePitch
 
577
                NewTimePitchRate                                        = 0,
 
578
                NewTimePitchPitch                                       = 1,
 
579
                NewTimePitchOverlap                                     = 4,
 
580
                NewTimePitchEnablePeakLocking           = 6,
 
581
 
 
582
                // AUSampler unit
 
583
                AUSamplerGain                                           = 900,
 
584
                AUSamplerCoarseTuning                           = 901,
 
585
                AUSamplerFineTuning                                     = 902,
 
586
                AUSamplerPan                                            = 903,
 
587
 
 
588
                // AUBandpass
 
589
                BandpassCenterFrequency                         = 0,
 
590
                BandpassBandwidth                                       = 1,
 
591
 
 
592
                // AUHipass
 
593
                HipassCutoffFrequency                           = 0,
 
594
                HipassResonance                                         = 1,
 
595
 
 
596
                // AULowpass
 
597
                LowPassCutoffFrequency                          = 0,
 
598
                LowPassResonance                                        = 1,
 
599
 
 
600
                // AUHighShelfFilter
 
601
                HighShelfCutOffFrequency                        = 0,
 
602
                HighShelfGain                                           = 1,
 
603
 
 
604
                // AULowShelfFilter
 
605
                AULowShelfCutoffFrequency                       = 0,
 
606
                AULowShelfGain                                          = 1,
 
607
 
 
608
                // AUDCFilter
 
609
                AUDCFilterDecayTime                                     = 0,            
 
610
 
 
611
                // AUParametricEQ
 
612
                ParametricEQCenterFreq                          = 0,
 
613
                ParametricEQQ                                           = 1,
 
614
                ParametricEQGain                                        = 2,
 
615
 
 
616
                // AUPeakLimiter
 
617
                LimiterAttackTime                                       = 0,
 
618
                LimiterDecayTime                                        = 1,
 
619
                LimiterPreGain                                          = 2,
 
620
 
 
621
                // AUDynamicsProcessor
 
622
                DynamicsProcessorThreshold                      = 0,
 
623
                DynamicsProcessorHeadRoom                       = 1,
 
624
                DynamicsProcessorExpansionRatio         = 2,
 
625
                DynamicsProcessorExpansionThreshold     = 3,
 
626
                DynamicsProcessorAttackTime                     = 4,
 
627
                DynamicsProcessorReleaseTime            = 5,
 
628
                DynamicsProcessorMasterGain                     = 6,
 
629
                DynamicsProcessorCompressionAmount      = 1000,
 
630
                DynamicsProcessorInputAmplitude         = 2000,
 
631
                DynamicsProcessorOutputAmplitude        = 3000,
 
632
 
 
633
                // AUVarispeed
 
634
                VarispeedPlaybackRate                           = 0,
 
635
                VarispeedPlaybackCents                          = 1,
 
636
 
 
637
                // Distortion unit 
 
638
                DistortionDelay                                         = 0,
 
639
                DistortionDecay                                         = 1,
 
640
                DistortionDelayMix                                      = 2,
 
641
                DistortionDecimation                            = 3,
 
642
                DistortionRounding                                      = 4,
 
643
                DistortionDecimationMix                         = 5,
 
644
                DistortionLinearTerm                            = 6,  
 
645
                DistortionSquaredTerm                           = 7,    
 
646
                DistortionCubicTerm                                     = 8,  
 
647
                DistortionPolynomialMix                         = 9,
 
648
                DistortionRingModFreq1                          = 10,
 
649
                DistortionRingModFreq2                          = 11,
 
650
                DistortionRingModBalance                        = 12,
 
651
                DistortionRingModMix                            = 13,
 
652
                DistortionSoftClipGain                          = 14,
 
653
                DistortionFinalMix                                      = 15,
 
654
 
 
655
                // AUDelay
 
656
                DelayWetDryMix                                          = 0,
 
657
                DelayTime                                                       = 1,
 
658
                DelayFeedback                                           = 2,
 
659
                DelayLopassCutoff                                       = 3,
 
660
 
 
661
#if MONOMAC
 
662
                // TODO
 
663
#else
 
664
                // AUNBandEQ
 
665
                AUNBandEQGlobalGain                                     = 0,
 
666
                AUNBandEQBypassBand                                     = 1000,
 
667
                AUNBandEQFilterType                                     = 2000,
 
668
                AUNBandEQFrequency                                      = 3000,
 
669
                AUNBandEQGain                                           = 4000,
 
670
                AUNBandEQBandwidth                                      = 5000,
 
671
 
 
672
                // iOS reverb
 
673
                Reverb2DryWetMix                                        = 0,
 
674
                Reverb2Gain                                                     = 1,
 
675
                Reverb2MinDelayTime                                     = 2,
 
676
                Reverb2MaxDelayTime                                     = 3,
 
677
                Reverb2DecayTimeAt0Hz                           = 4,
 
678
                Reverb2DecayTimeAtNyquist                       = 5,
 
679
                Reverb2RandomizeReflections                     = 6,
 
680
#endif
 
681
        }
434
682
        
435
 
        public enum AudioUnitScopeType {
436
 
                Global = 0,
437
 
                Input = 1,
438
 
                Output = 2
439
 
        }
 
683
    public enum AudioUnitScopeType {
 
684
                Global          = 0,
 
685
                Input           = 1,
 
686
                Output          = 2,
 
687
                Group           = 3,
 
688
                Part            = 4,
 
689
                Note            = 5,
 
690
                Layer           = 6,
 
691
                LayerItem       = 7
 
692
    }
440
693
 
441
 
        [Flags]
442
 
        public enum AudioUnitRenderActionFlags {
 
694
        [Flags]
 
695
    public enum AudioUnitRenderActionFlags {
443
696
                PreRender = (1 << 2),
444
697
                PostRender = (1 << 3),
445
698
                OutputIsSilence = (1 << 4),
446
699
                OfflinePreflight = (1 << 5),
447
700
                OfflineRender = (1 << 6),
448
701
                OfflineComplete = (1 << 7),
449
 
                PostRenderError = (1 << 8)
450
 
        };
451
 
        #endregion    
452
 
        
 
702
                PostRenderError = (1 << 8),
 
703
                DoNotCheckRenderArgs = (1 << 9)
 
704
    };
453
705
}