Ejemplo n.º 1
0
        public bool OpenDevice(string name = null)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(name))
                {
                    _info = MidiDeviceManager.AllDevices.FirstOrDefault(device =>
                                                                        device.IsInput && device.Name.ToLower().Contains(name.ToLower()));
                }
                else
                {
                    _info = MidiDeviceManager.AllDevices.FirstOrDefault(device =>
                                                                        device.ID == MidiDeviceManager.DefaultInputDeviceId);
                }

                _input = MidiDeviceManager.OpenInput(_info.ID);
                _input.SetFilter(MidiFilter.Active | MidiFilter.SysEx | MidiFilter.Clock | MidiFilter.Play | MidiFilter.Tick | MidiFilter.Undefined | MidiFilter.Reset | MidiFilter.RealTime | MidiFilter.AF | MidiFilter.Program | MidiFilter.PitchBend | MidiFilter.SystemCommon);
                _data = new byte[1024];
                return(true);
            }
            catch (Exception e)
            {
                #if VRC_CLIENT
                VRC.Core.Logger.LogError($"Error opening Default Device: {e.Message}");
                #else
                Debug.Log($"Error opening Default Device: {e.Message}");
                #endif
                return(false);
            }
        }
Ejemplo n.º 2
0
 private MidiOutPort(
     string deviceId,
     MidiDeviceInfo deviceInfo,
     MidiDeviceInfo.PortInfo portInfo)
 {
     _midiManager = ContextHelper.Current.GetSystemService(Context.MidiService).JavaCast <MidiManager>();
     DeviceId     = deviceId ?? throw new ArgumentNullException(nameof(deviceId));
     _deviceInfo  = deviceInfo ?? throw new ArgumentNullException(nameof(deviceInfo));
     _portInfo    = portInfo ?? throw new ArgumentNullException(nameof(portInfo));
 }
Ejemplo n.º 3
0
        public MidiOutput(MidiDeviceInfo info)
        {
            if (info == null)
                throw new ArgumentNullException(nameof(info));

            _deviceInfo = info;

            if (!_deviceInfo.SupportsOutput)
                throw new InvalidOperationException("MIDI device does not support output");
        }
Ejemplo n.º 4
0
        public void onDeviceAdded(MidiDeviceInfo info)
        {
            int nombrePort = info.InputPortCount;

            for (int i = 0; i < nombrePort; i++)
            {
                InfosPorts infosPort = new InfosPorts(info, i);
                portInfo = infosPort.getDeviceInfo();
                index    = infosPort.getPortIndex();
            }
        }
Ejemplo n.º 5
0
 public MidiPortDetails(MidiDeviceInfo device, MidiDeviceInfo.PortInfo port)
 {
     if (device == null)
     {
         throw new ArgumentNullException(nameof(device));
     }
     if (port == null)
     {
         throw new ArgumentNullException(nameof(port));
     }
     this.device = device;
     this.port   = port;
 }
Ejemplo n.º 6
0
 public MidiInput(MidiDeviceInfo info)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 public InfosPorts(MidiDeviceInfo info, int i)
 {
     this.info  = info;
     this.index = i;
 }
        public override void OnDeviceRemoved(MidiDeviceInfo device)
        {
            DeviceRemoved?.Invoke(this, device);

            base.OnDeviceRemoved(device);
        }
 private void OnMidiDeviceAdded(object sender, MidiDeviceInfo e)
 {
     _devices = null;
     UpdateInputDevices(false);
     UpdateOutputDevices(false);
 }
 private void OnMidiDeviceRemoved(object sender, MidiDeviceInfo e)
 {
     _devices = null;
     UpdateInputDevices(true);
     UpdateOutputDevices(true);
 }