示例#1
0
        public MidiRouter()
        {
            Midi.Restart ();
            client = new MidiClient ("MidiRouter");

            InputPort1 = client.CreateInputPort ("mdrInput1");
            InputPort2 = client.CreateInputPort ("mdrInput2");

            outputPort = client.CreateOutputPort ("mdrOutput");

            InputPort1.MessageReceived += HandleMessageReceivedInput1;
            InputPort2.MessageReceived += HandleMessageReceivedInput2;
        }
示例#2
0
        public void SimpleMidiTest()
        {
            //create midi client to use core midi features
            MidiClient client = new MidiClient ("MidiMod");

            //create input port to listen to incoming midi data
            MidiPort inputPort = client.CreateInputPort ("MidiMod Input Port");
            inputPort.MessageReceived += delegate(object sender, MidiPacketsEventArgs e) {
                Console.WriteLine("message received");
            };

            //connect midi devices to inputport (only source 0)
            var ep = MidiEndpoint.GetSource (0);
            inputPort.ConnectSource (ep);
        }
示例#3
0
        public void SetupMidi()
        {
            //Midi.Restart ();

            //create new client
            client = new MidiClient ("MidiMod");

            //create input and output port
            outputPort = client.CreateOutputPort ("MidiMod Output Port");
            inputPort = client.CreateInputPort ("MidiMod Input Port");

            //create event handlers
            //			client.ObjectAdded += HandleObjectAdded;
            //			client.ObjectRemoved += HandleObjectRemoved;
            //			client.PropertyChanged += HandlePropertyChanged;
            //			client.ThruConnectionsChanged += HandleThruConnectionsChanged;
            //			client.SerialPortOwnerChanged += HandleSerialPortOwnerChanged;
            //			client.IOError += HandleIOError;
            inputPort.MessageReceived += HandleMessageReceived;

            //connect midi devices
            ConnectMidiDevices ();
        }
示例#4
0
		internal MidiPort (MidiClient client, string portName, bool input)
		{
			using (var nsstr = new NSString (portName)){
				GCHandle gch = GCHandle.Alloc (this);
				int code;
				
				if (input)
					code = MIDIInputPortCreate (client.handle, nsstr.Handle, Read, GCHandle.ToIntPtr (gch), out handle);
				else
					code = MIDIOutputPortCreate (client.handle, nsstr.Handle, out handle);
				
				if (code != 0){
					gch.Free ();
					handle = IntPtr.Zero;
					throw new MidiException ((MidiError) code);
				}
				Client = client;
				PortName = portName;
				this.input = input;
			}
		}
示例#5
0
		internal MidiEndpoint (MidiClient client, string name)
		{
			using (var nsstr = new NSString (name)){
				GCHandle gch = GCHandle.Alloc (this);
				int code;
				
				code = MIDIDestinationCreate (client.handle, nsstr.Handle, Read, GCHandle.ToIntPtr (gch), out handle);
				
				if (code != 0){
					gch.Free ();
					handle = IntPtr.Zero;
					throw new MidiException ((MidiError) code);
				}
				EndpointName = name;
			}
		}