public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            var componentDescription = new AudioComponentDescription {
                ComponentType = AudioComponentType.Effect,
                ComponentSubType = 0x666c7472,
                ComponentManufacturer = (AudioComponentManufacturerType)0x44656d6f,
                ComponentFlags = 0,
                ComponentFlagsMask = 0
            };

            AUAudioUnit.RegisterSubclass (
                new Class (typeof(AUv3FilterDemo)),
                componentDescription,
                "Local FilterDemo",
                int.MaxValue
            );

            EmbedPlugInView ();

            playEngine = new SimplePlayEngine ();

            playEngine.SelectEffectWithComponentDescription (componentDescription, ConnectParametersToControls);

            playEngine.AudioUnit.TransportStateBlock = (ref AUHostTransportStateFlags transportStateFlags, ref double currentSamplePosition, ref double cycleStartBeatPosition, ref double cycleEndBeatPosition) => {
                transportStateFlags = AUHostTransportStateFlags.Recording;

                currentSamplePosition = 10.0;
                cycleStartBeatPosition = 0.0;
                cycleEndBeatPosition = 20.0;

                return true;
            };
        }
Beispiel #2
0
		bool createAUGraph ()
		{
			AUGraphError result = 0;
			int samplerNode, ioNode;

			var cd = new AudioComponentDescription () {
				ComponentManufacturer = AudioComponentManufacturerType.Apple,
				ComponentFlags = 0,
				ComponentFlagsMask = 0
			};

			processingGraph = new AUGraph ();

			cd.ComponentType = AudioComponentType.MusicDevice;
			cd.ComponentSubType = (int)AudioTypeMusicDevice.Sampler; //0x73616d70;

			samplerNode = processingGraph.AddNode (cd);

			cd.ComponentType = AudioComponentType.Output;
			cd.ComponentSubType = (int)AudioTypeOutput.Remote; //0x72696f63;

			ioNode = processingGraph.AddNode (cd);

			processingGraph.Open ();

			result = processingGraph.ConnnectNodeInput (samplerNode, 0, ioNode, 0);
			if (result != AUGraphError.OK)
				throw new Exception ("Unable to open the audio processing graph.  Error code: " + result);
			samplerUnit = processingGraph.GetNodeInfo (samplerNode);
			ioUnit = processingGraph.GetNodeInfo (ioNode);

			return true;
		}
Beispiel #3
0
		bool CreateAUGraph ()
		{
			processingGraph = new AUGraph ();

			int samplerNode, ioNode;

			var musicSampler = new AudioComponentDescription () {
				ComponentManufacturer = AudioComponentManufacturerType.Apple,
				ComponentType = AudioComponentType.MusicDevice,
				ComponentSubType = (int)AudioTypeMusicDevice.Sampler
			};
			samplerNode = processingGraph.AddNode (musicSampler);

			var remoteOutput = new AudioComponentDescription () {
				ComponentManufacturer = AudioComponentManufacturerType.Apple,
				ComponentType = AudioComponentType.Output,
				ComponentSubType = (int)AudioTypeOutput.Remote
			};
			ioNode = processingGraph.AddNode (remoteOutput);

			processingGraph.Open ();

			processingGraph.ConnnectNodeInput (
				sourceNode: samplerNode,
				sourceOutputNumber: 0,
				destNode: ioNode,
				destInputNumber: 0);

			samplerUnit = processingGraph.GetNodeInfo (samplerNode);


			return true;
		}
		void UpdateEffectsList ()
		{
			DispatchQueue.DefaultGlobalQueue.DispatchAsync (() => {
				var anyEffectDescription = new AudioComponentDescription {
					ComponentType = AudioComponentType.Effect,
					ComponentSubType = 0,
					ComponentManufacturer = 0,
					ComponentFlags = 0,
					ComponentFlagsMask = 0
				};

				availableEffects = AVAudioUnitComponentManager.SharedInstance.GetComponents (anyEffectDescription);
				DispatchQueue.MainQueue.DispatchAsync (componentsFoundCallback);
			});
		}
		public static AudioComponent FindNextComponent (AudioComponent cmp, AudioComponentDescription cd)
		{
			// Getting component hanlder
			IntPtr handle;
			if (cmp == null)
				handle = AudioComponentFindNext(IntPtr.Zero, cd);
			else
				handle = AudioComponentFindNext(cmp.Handle, cd);
			
			// creating an instance
			if (handle != IntPtr.Zero)
				return new AudioComponent (handle);
			else
				return null;
		}
Beispiel #6
0
 static int CountMatches(AudioComponentDescription desc)
 {
     if (desc == null)
         throw new ArgumentNullException ("desc");
     return AudioComponentCount (desc);
 }
Beispiel #7
0
 static extern IntPtr AudioComponentFindNext(IntPtr inComponent, AudioComponentDescription inDesc);
Beispiel #8
0
 public static AudioComponent FindComponent(AudioComponentDescription cd)
 {
     return FindNextComponent(null, cd);
 }
Beispiel #9
0
 static extern AUGraphError AUGraphAddNode(IntPtr inGraph, AudioComponentDescription inDescription, out int outNode);
Beispiel #10
0
 public static AudioComponent FindNextComponent(AudioComponent cmp, AudioComponentDescription cd)
 {
     return FindNextComponent (cmp, ref cd);
 }
Beispiel #11
0
		public void CopyTo (AudioComponentDescription cd)
		{
			cd.ComponentType = ComponentType;
			cd.ComponentSubType = ComponentSubType;
			cd.ComponentManufacturer = ComponentManufacturer;
			cd.ComponentFlags = ComponentFlags;
			cd.ComponentFlagsMask = ComponentFlagsMask;
		}
Beispiel #12
0
 public AVAudioUnitEffect(AudioComponentDescription desc)
     : this(new AudioComponentDescriptionNative (desc))
 {
 }
		public void SelectEffectWithComponentDescription (AudioComponentDescription? componentDescription, Action completionHandler)
		{
			if (isPlaying)
				player.Pause ();

			if (effect != null) {
				engine.DisconnectNodeInput (effect);
				engine.DisconnectNodeInput (engine.MainMixerNode);

				engine.Connect (player, engine.MainMixerNode, file.ProcessingFormat);

				engine.DetachNode (effect);

				effect = null;
				AudioUnit = null;
				PresetList = new AUAudioUnitPreset[0];
			}

			if (componentDescription.HasValue) {
				AVAudioUnit.FromComponentDescription (componentDescription.Value, AudioComponentInstantiationOptions.OutOfProcess, (avAudioUnitEffect, AVError) => {
					if (AVError != null || avAudioUnitEffect == null) {
						Console.WriteLine ("SelectEffectWithComponentDescription error!");
						return;
					}

					effect = avAudioUnitEffect;
					engine.AttachNode (avAudioUnitEffect);

					engine.DisconnectNodeInput (engine.MainMixerNode);

					engine.Connect (player, avAudioUnitEffect, file.ProcessingFormat);
					engine.Connect (avAudioUnitEffect, engine.MainMixerNode, file.ProcessingFormat);

					AudioUnit = avAudioUnitEffect.AUAudioUnit;
					PresetList = avAudioUnitEffect.AUAudioUnit.FactoryPresets ?? new AUAudioUnitPreset[0];
					Done (completionHandler);
				});
			} else {
				Done (completionHandler);
			}
		}
Beispiel #14
0
		static extern AUGraphError AUGraphAddNode(IntPtr inGraph, ref AudioComponentDescription inDescription, out int /* AUNode = SInt32* */ outNode);
Beispiel #15
0
		// AudioComponentDescription struct in only correctly fixed for unified
		// Following current Api behaviour of returning an AudioUnit instead of an error
		public AudioUnit GetNodeInfo (int node, out AudioComponentDescription cd, out AUGraphError error)
		{
			if (Handle == IntPtr.Zero)
				throw new ObjectDisposedException ("AUGraph");

			IntPtr ptr;
			error = AUGraphNodeInfo (Handle, node, out cd, out ptr);

			if (error != AUGraphError.OK || ptr == IntPtr.Zero)
				return null;

			return new AudioUnit (ptr);
		}
Beispiel #16
0
		public int AddNode (AudioComponentDescription description)
		{
			int node;
#if XAMCORE_2_0
			var err = AUGraphAddNode (handle, ref description, out node);
#else
			var err = AUGraphAddNode (handle, description, out node);
#endif
			if (err != 0)
				throw new ArgumentException (String.Format ("Error code: {0}", err));
			
			return node;
		}
Beispiel #17
0
		public AudioComponentDescriptionNative (AudioComponentDescription other)
		{
			this.ComponentType = other.ComponentType;
			this.ComponentSubType = other.ComponentSubType;
			this.ComponentManufacturer = other.ComponentManufacturer;
			this.ComponentFlags = other.ComponentFlags;
			this.ComponentFlagsMask = other.ComponentFlagsMask;
		}
Beispiel #18
0
 public AVAudioUnitGenerator(AudioComponentDescription desc)
     : this(new AudioComponentDescriptionNative (desc))
 {
 }
Beispiel #19
0
 public static AudioComponent FindNextComponent(AudioComponent cmp, ref AudioComponentDescription cd)
 {
     var handle = cmp == null ? IntPtr.Zero : cmp.Handle;
     handle = AudioComponentFindNext (handle, ref cd);
     return  (handle != IntPtr.Zero) ? new AudioComponent (handle) : null;
 }
Beispiel #20
0
 public AVAudioUnitMidiInstrument(AudioComponentDescription desc)
     : this(new AudioComponentDescriptionNative (desc))
 {
 }
Beispiel #21
0
        public int AddNode(AudioComponentDescription description)
        {
            int node;
            var err = AUGraphAddNode (handle, description, out node);
            if (err != 0)
                throw new ArgumentException(String.Format("Error code:", err));

            return node;
        }
Beispiel #22
0
 public AVAudioUnitTimePitch(AudioComponentDescription desc)
     : this(new AudioComponentDescriptionNative (desc))
 {
 }
Beispiel #23
0
 static extern AUGraphError AUGraphNodeInfo(IntPtr inGraph, int inNode, out AudioComponentDescription outDescription, out IntPtr outAudioUnit);
Beispiel #24
0
 public AVAudioUnitVarispeed(AudioComponentDescription desc)
     : this(new AudioComponentDescriptionNative (desc))
 {
 }
Beispiel #25
0
 static extern int AudioComponentCount(AudioComponentDescription desc);
Beispiel #26
0
 static extern int AUGraphAddNode(IntPtr inGraph, AudioComponentDescription inDescription, ref int outNode);
Beispiel #27
0
 static extern int AudioComponentGetDescription(IntPtr component, out AudioComponentDescription desc);
Beispiel #28
0
 static extern int AUGraphNodeInfo(IntPtr inGraph, int inNode, AudioComponentDescription outDescription, IntPtr outAudioUnit);
Beispiel #29
0
        public int AddNode(AudioComponentDescription cd)
        {
            int node = 0;
            int err = AUGraphAddNode(handle, cd, ref node);
            if (err != 0)
                throw new ArgumentException(String.Format("Error code:", err));

            return node;
        }
		public AUAudioUnit CreateAudioUnit (AudioComponentDescription desc, out NSError error)
		{
			AudioUnit = new AUv3FilterDemo (desc, 0, out error);
			return AudioUnit;
		}