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
 public void Start(int indev, int outdev)
 {
     using (var output = MidiDeviceManager.OpenOutput(outdev))
         output.WriteSysEx(0, sysex);
     input_device = MidiDeviceManager.OpenInput(indev, BufferSize);
     new Action(delegate {
         try {
             Loop();
         } catch (Exception ex) {
             Console.WriteLine("ERROR INSIDE THE LOOP: " + ex);
         }
         wait_handle.Set();
     }).BeginInvoke(null, null);
 }