예제 #1
0
        public MidiPort CreateOutputPort(string name)
        {
            MIDIPortRef port;

            CoreMidiInterop.MIDIOutputPortCreate(Handle, Midi.ToCFStringRef(name), out port);
            return(new MidiPort(port, true));
        }
예제 #2
0
        public MidiEndpoint CreateVirtualSource(string name, out MidiError statusCode)
        {
            IntPtr ptr;

            statusCode = (MidiError)CoreMidiInterop.MIDISourceCreate(Handle, Midi.ToCFStringRef(name), out ptr);
            return(statusCode == MidiError.Ok ? new MidiEndpoint(ptr, name, true, null) : null);
        }
예제 #3
0
        public Task <IMidiDevice> OpenDevice(string id)
        {
            var devices = GetDevices().ToArray();
            var device  = devices.First(i => i.Id == id);

            return(Task.FromResult((IMidiDevice) new IOSMidiDevice(this, CMidi.GetDevice(Array.IndexOf(devices, device)), device)));
        }
예제 #4
0
        public MidiClient(string name)
        {
            IntPtr h;

            name_string = Midi.ToCFStringRef(name);
            CoreMidiInterop.MIDIClientCreate(name_string, OnNotify, IntPtr.Zero, out h);
            Handle = h;
        }
예제 #5
0
        public MidiPort CreateInputPort(string name)
        {
            MIDIPortRef port;
            var         d = new ReadDispatcher();

            CoreMidiInterop.MIDIInputPortCreate(Handle, Midi.ToCFStringRef(name), d.DispatchRead, IntPtr.Zero, out port);
            d.Port = new MidiPort(port, true);
            return(d.Port);
        }
예제 #6
0
        public MidiEndpoint CreateVirtualDestination(string name, out MidiError statusCode)
        {
            IntPtr ptr;
            var    d = new ReadDispatcher();

            statusCode = (MidiError)CoreMidiInterop.MIDIDestinationCreate(Handle, Midi.ToCFStringRef(name),
                                                                          d.DispatchProc, IntPtr.Zero, out ptr);
            return(statusCode == MidiError.Ok ? new MidiEndpoint(ptr, name, true, d) : null);
        }
예제 #7
0
        void SetStringProp(IntPtr id, string value)
        {
            if (id == IntPtr.Zero)
            {
                return;
            }
            CFStringRef str;

            CoreMidiInterop.MIDIObjectSetStringProperty(Handle, id, Midi.ToCFStringRef(value));
        }
예제 #8
0
        public MidiClient(string name)
        {
            IntPtr h;

            name_string = Midi.ToCFStringRef(name);
            int ret = CoreMidiInterop.MIDIClientCreate(name_string, null, IntPtr.Zero, out h);

            if (ret != 0)
            {
                throw new MidiException($"Failed to create MIDI client for {name}: error code {ret}");
            }
            Handle = h;
        }
예제 #9
0
        IEnumerable <MidiEntity> EnumerateMidiEntities()
        {
            var dcount = MIDI.DeviceCount;

            for (nint d = 0; d < dcount; d++)
            {
                var dev    = MIDI.GetDevice(d);
                var ecount = dev.EntityCount;
                for (nint e = 0; e < ecount; e++)
                {
                    yield return(dev.GetEntity(e));
                }
            }
        }
예제 #10
0
 public IEnumerable <MidiDeviceDetails> GetDevices()
 {
     return(Enumerable.Range(0, (int)CMidi.DeviceCount).Select(i => CreateMidiDeviceDetails(CMidi.GetDevice(i))));
 }