private void GetMidiDeviceInfo() { m_midiOutCount = OutputDeviceBase.DeviceCount; m_midiInCount = InputDevice.DeviceCount; lblMidiOutCount.Text = m_midiOutCount.ToString(); lblMidiInCount.Text = m_midiInCount.ToString(); m_midiOuts = new Dictionary <int, string>(); for (int index = 0; index < m_midiOutCount; ++index) { MidiOutCaps deviceCapabilities = OutputDeviceBase.GetDeviceCapabilities(index); m_midiOuts.Add(index, deviceCapabilities.name); } m_midiIns = new Dictionary <int, string>(); for (int index = 0; index < m_midiInCount; ++index) { MidiInCaps deviceCapabilities = InputDevice.GetDeviceCapabilities(index); m_midiIns.Add(index, deviceCapabilities.name); } cmbMidiIn.DataSource = new BindingSource(m_midiIns, null); cmbMidiIn.DisplayMember = "Value"; cmbMidiIn.ValueMember = "Key"; cmbMidiIn.SelectedValue = Settings.MidiIn; cmbMidiOut.DataSource = new BindingSource(m_midiOuts, null); cmbMidiOut.DisplayMember = "Value"; cmbMidiOut.ValueMember = "Key"; cmbMidiOut.SelectedValue = Settings.MidiOut; }
public bool Connect() { lock (MidiCom.lock_obj) { if (this.m_Closing || InputDevice.DeviceCount == 0) { return(false); } if (!this.Connected()) { try { int deviceID1 = -1; for (int deviceID2 = 0; deviceID2 < InputDevice.DeviceCount; ++deviceID2) { if (InputDevice.GetDeviceCapabilities(deviceID2).name.Contains("CODE")) { deviceID1 = deviceID2; } } if (deviceID1 == -1) { this.Disconnect(); return(false); } Logger.Log(string.Format("MIDI-in : CODE found on device #{0}", (object)deviceID1)); this.inDevice = new InputDevice(deviceID1); this.inDevice.ChannelMessageReceived += new EventHandler <ChannelMessageEventArgs>(this.HandleChannelMessageReceived); this.inDevice.SysExMessageReceived += new EventHandler <SysExMessageEventArgs>(this.HandleSysExMessageReceived); this.inDevice.Error += new EventHandler <ErrorEventArgs>(this.inDevice_Error); this.inDevice.StartRecording(); int deviceID3 = -1; for (int deviceID2 = 0; deviceID2 < OutputDeviceBase.DeviceCount; ++deviceID2) { if (OutputDeviceBase.GetDeviceCapabilities(deviceID2).name.Contains("CODE")) { deviceID3 = deviceID2; } } if (deviceID3 == -1) { this.Disconnect(); return(false); } Logger.Log(string.Format("MIDI-out : CODE found on device #{0}", (object)deviceID3)); this.outDevice = new OutputDevice(deviceID3); this.outDevice.Error += new EventHandler <ErrorEventArgs>(this.inDevice_Error); this.outDevice.RunningStatusEnabled = false; Logger.Log("MIDI connected alright !"); } catch (Exception ex) { Logger.Log("Exception while creating devices"); this.Disconnect(); return(false); } } return(true); } }
public static void Start() { var x = Sanford.Multimedia.Midi.InputDevice.DeviceCount; for (int i = 0; i < x; i++) { var b = InputDevice.GetDeviceCapabilities(i); Console.WriteLine("ID: " + i + " Driver version: " + b.driverVersion + " Mid: " + b.mid + " name: " + b.name + " pid: " + b.pid + " Support: " + b.support); } InputDevice inDevice = new InputDevice(0); //ChannelStopper stopper = new ChannelStopper(); inDevice.ChannelMessageReceived += delegate(object sender, ChannelMessageEventArgs e) { //stopper.Process(e.Message); //Console.WriteLine(e.Message.Bytes[0] + "." + e.Message.Bytes[1] + "." + e.Message.Bytes[2]); byte b0 = e.Message.Bytes[0]; byte b1 = e.Message.Bytes[1]; byte b2 = e.Message.Bytes[2]; LrParameters.SetParameterByMidi(b0, b1, b2); }; inDevice.StartRecording(); }
public void midiInit() { for (var i = 0; i < InputDevice.DeviceCount; i++) { midiDeviceBox.Items.Add(InputDevice.GetDeviceCapabilities(i).name); } }
internal Device(int pDeviceID) { mInDeviceID = pDeviceID; mOutDeviceID = -1; mCap = InputDevice.GetDeviceCapabilities(pDeviceID); mName = mCap.name; }
private static SysExClient CreateClientForTd17() { int inputId = FindId(InputDevice.DeviceCount, i => InputDevice.GetDeviceCapabilities(i).name, "3- TD-17"); int outputId = FindId(OutputDeviceBase.DeviceCount, i => OutputDeviceBase.GetDeviceCapabilities(i).name, "3- TD-17"); return(new SysExClient(inputId, outputId, modelId: 0x4b, deviceId: 17)); }
public void ReScan() { MidiDeviceList mdlinput = new MidiDeviceList(); //Relist devices for (int i = 0; i < InputDevice.DeviceCount; i++) { MidiDevice md = new MidiDevice(); md.Name = InputDevice.GetDeviceCapabilities(i).name; md.DeviceIndex = i; md.Index = mdlinput.GetIndex(md.Name); mdlinput.Add(md); } MidiDeviceList newinput = new MidiDeviceList(); //Now cross match foreach (MidiDevice input in this.inputs) { //Device been disconnected if (!mdlinput.Contains(input.Name, input.Index)) { input.DeviceIndex = -1; input.Status = eTodoMidiStatus.Disconnected; newinput.Add(input); } } foreach (MidiDevice input in mdlinput) { } }
public MainWindow() { InitializeComponent(); var materialSkinManager = MaterialSkinManager.Instance; materialSkinManager.AddFormToManage(this); materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; materialSkinManager.ColorScheme = new ColorScheme(Primary.DeepOrange300, Primary.DeepOrange800, Primary.DeepOrange500, Accent.DeepOrange400, TextShade.WHITE); DeviceTypeMenu.SelectedIndex = 0; // Select all midi channels by default EventMidiChannelSelector.Items.Clear(); for (int i = 0; i < MidiChannelSelector.Items.Count; i++) { MidiChannelSelector.SetItemChecked(i, true); midiChannels.Add(i + 1); // populate the midi channel dropdown with the midi channels EventMidiChannelSelector.Items.Add("Ch" + (i + 1)); } for (int i = 0; i < InputDevice.DeviceCount; i++) { // loop through availible midi devices and push their names to the menu MidiDeviceSelector.Items.Add(InputDevice.GetDeviceCapabilities(i).name); TrayMenuConnect.DropDownItems.Add(InputDevice.GetDeviceCapabilities(i).name); } TrayMenuConnect.DropDownItemClicked += new ToolStripItemClickedEventHandler(TrayConnect_Click); }
// uzycie metody statycznej nie wymaga tworzenia obiektu // ale skolei statyczna metoda ma problem do odwolan do innych metod w klasie / obiektow // jak tu byl static to nie widzialem obiektu comboMidiInDevices nawet gdy klasa byla partial Form1 // public static void Init() public void Init() { // In MIDI Devices int iDevices = InputDevice.DeviceCount; comboMidiInDevices.Items.Clear(); // Wypisz urzadzenia for (int x = 0; x < iDevices; x++) { MidiInCaps caps = InputDevice.GetDeviceCapabilities(x); comboMidiInDevices.Items.Add(caps.name); // Zapamietaj indeks urzadzenia, ktory jest wybrany // if (caps.name == inString) // iSelectedIn = x; } // Out MIDI Devices int oDevices = OutputDevice.DeviceCount; comboMidiOutDevices.Items.Clear(); for (int x = 0; x < oDevices; x++) { MidiOutCaps caps = OutputDevice.GetDeviceCapabilities(x); comboMidiOutDevices.Items.Add(caps.name); // Zapamietaj indeks urzadzenia, ktory jest wybrany // if (caps.name == outString) // iSelectedOut = x; } } // Init
public bool Start() { if (!Running) { try { Name = InputDevice.GetDeviceCapabilities(DeviceID).name; midiinput = new InputDevice(DeviceID); midiinput.Error += inDevice_Error; midiinput.ChannelMessageReceived += HandlerAnyMessageReceived; midiinput.SysCommonMessageReceived += HandlerAnyMessageReceived; midiinput.SysExMessageReceived += HandlerAnyMessageReceived; midiinput.SysRealtimeMessageReceived += HandlerAnyMessageReceived; midiinput.StartRecording(); Running = true; return(true); } catch (Exception e) { Logger.Log(e); Logger.Log(e.StackTrace); return(false); } } else { return(false); } }
public static IEnumerable <string> GetInputDevices() { for (int deviceIndex = 0; deviceIndex < InputDevice.DeviceCount; deviceIndex++) { var deviceInfo = InputDevice.GetDeviceCapabilities(deviceIndex); yield return($"[ID={deviceIndex}] \"{deviceInfo.name}\", V{deviceInfo.driverVersion / 256}.{deviceInfo.driverVersion % 256}"); } }
private void LoadOrCreateConfig() { if (File.Exists("config.ini")) { Log.Info("Loading settings from file"); AppManager.Instance.PushToLog("Loading settings from config.ini"); Configuration = SharpConfig.Configuration.LoadFromFile("config.ini"); } else { Log.Info("No settings file found. Creating one..."); AppManager.Instance.PushToLog("No settings file found. Creating one..."); Configuration["Settings"]["Enable Remote"].BoolValue = true; Configuration["Settings"]["Remote Host"].StringValue = "127.0.0.1"; Configuration["Settings"]["Remote Port"].IntValue = 1028; Configuration["Settings"]["COM Port"].StringValue = "COM1"; Configuration["Settings"]["MIDI Input Device ID"].IntValue = 0; Configuration["Settings"]["MIDI Output Device ID"].IntValue = 0; Configuration["Settings"]["Default Radio Mode"].StringValue = "LSB"; Configuration["Settings"]["Default VFO"].StringValue = "A"; for (var i = 0; i < InputDevice.DeviceCount; i++) { if (InputDevice.GetDeviceCapabilities(i).name == MidiControllerStringId) { Configuration["Settings"]["Midi Input Device ID"].IntValue = i; } } for (var i = 0; i < OutputDevice.DeviceCount; i++) { if (OutputDevice.GetDeviceCapabilities(i).name == MidiControllerStringId) { Configuration["Settings"]["Midi Output Device ID"].IntValue = i; } } // Get MIDI input devices for (var i = 0; i < InputDevice.DeviceCount; i++) { Configuration["MIDI Input Devices"][InputDevice.GetDeviceCapabilities(i).name].IntValue = i; } // Get MIDI output devices for (var i = 0; i < OutputDevice.DeviceCount; i++) { Configuration["MIDI Output Devices"][OutputDevice.GetDeviceCapabilities(i).name].IntValue = i; } Configuration.SaveToFile("config.ini"); } Settings = Configuration["Settings"]; }
/// <summary> /// Gets a list of available midi devices. Array idnex equals midi device index. /// </summary> /// <returns>System.String[].</returns> public string[] GetDeviceList() { var devices = new string[InputDevice.DeviceCount]; for (var i = 0; i < InputDevice.DeviceCount; i++) { var deviceInfo = InputDevice.GetDeviceCapabilities(i); devices[i] = deviceInfo.name; } return(devices); }
public void RefreshMidiInput() { // Refresh list of Midi input devices midiInputs.Clear(); midiInputs.Add(new MidiInput("None", -1)); for (int i = 0; i < InputDevice.DeviceCount; i++) { MidiInCaps cap = InputDevice.GetDeviceCapabilities(i); midiInputs.Add(new MidiInput(cap.name, i)); } SettingMidiInput.DataSource = midiInputs; }
private static int GetMidiInputDevice(string partialDeviceName) { for (int i = 0; i < InputDevice.DeviceCount; i++) { var info = InputDevice.GetDeviceCapabilities(i); if (info.name.Contains(partialDeviceName)) { return(i); } } throw new Exception($"Cannot find input midi device with '{partialDeviceName}' in the name."); }
public MidiInput2(string deviceName = null, bool ignoreMissingDevice = false, [System.Runtime.CompilerServices.CallerMemberName] string name = "") { this.log = Log.Logger; this.name = name; string midiDeviceName = deviceName; if (string.IsNullOrEmpty(deviceName)) { midiDeviceName = Executor.Current.GetSetKey(this, name + ".DeviceName", string.Empty); } this.messageMapper = new Dictionary <Tuple <int, ChannelCommand, int>, Action <ChannelMessage> >(); this.midiMessages = new Subject <ChannelMessage>(); int selectedDeviceId = -1; for (int i = 0; i < InputDevice.DeviceCount; i++) { var midiCap = InputDevice.GetDeviceCapabilities(i); if (midiCap.name == midiDeviceName) { selectedDeviceId = i; break; } } if (selectedDeviceId == -1) { if (!ignoreMissingDevice) { throw new ArgumentException("Midi device not detected"); } else { this.log.Warning("Midi device not detected"); } } else { this.inputDevice = new InputDevice(selectedDeviceId); this.inputDevice.ChannelMessageReceived += inputDevice_ChannelMessageReceived; if (string.IsNullOrEmpty(deviceName)) { Executor.Current.SetKey(this, name + ".DeviceName", midiDeviceName); } } Executor.Current.Register(this); }
private static void StartMidi() { int deviceCount = InputDevice.DeviceCount; for (int i = 0; i < deviceCount; i++) { var deviceCap = InputDevice.GetDeviceCapabilities(i); Console.WriteLine("Using MIDI Device: " + deviceCap.name); var input = new InputDevice(i); input.ChannelMessageReceived += Input_ChannelMessageReceived; input.StartRecording(); } }
public SanfordMidiDevice(OutputDevice od, InputDevice id) { MessageQueue = new Queue <SysExMessage>(); OutputMidiDevice = od; var outputDeviceName = OutputDevice.GetDeviceCapabilities(od.DeviceID).name; InputMidiDevice = id; var inputDeviceName = InputDevice.GetDeviceCapabilities(id.DeviceID).name; InputMidiDevice.StartRecording(); InputMidiDevice.SysExMessageReceived += (s, e) => HandleMidiInMessage(e.Message); }
private void DeviceCount() { int count = liveInputManager.DeviceCount; for (int i = 0; i < count; i++) { string name = InputDevice.GetDeviceCapabilities(i).name; DeviceComboBox.Items.Add(new MidiDeviceItem() { Id = i, Name = name }); } }
private void Start() { SerialManager.Instance.SerialDataReceived += HandleSerialDataReceived; if (InputDevice.DeviceCount == 0) { Log.Error("No MIDI input devices available"); AppManager.Instance.PushToLog("No MIDI input devices available", AppManager.LogType.Error); } else { try { _context = SynchronizationContext.Current; var deviceId = AppManager.Instance.Settings["MIDI Input Device ID"].IntValue; _inputDevice = new InputDevice(deviceId); AppManager.Instance.PushToLog("Connected to " + InputDevice.GetDeviceCapabilities(deviceId).name, AppManager.LogType.Info); _inputDevice.ChannelMessageReceived += HandleChannelMessageReceived; _inputDevice.StartRecording(); } catch (Exception ex) { AppManager.Instance.PushToLog(ex.Message, AppManager.LogType.Error); throw new ApplicationException("Error: " + ex); } } if (OutputDevice.DeviceCount == 0) { Log.Error("No MIDI output devices available"); AppManager.Instance.PushToLog("No MIDI output devices available", AppManager.LogType.Error); } else { try { _context = SynchronizationContext.Current; var deviceId = AppManager.Instance.Settings["MIDI Output Device ID"].IntValue; _outputDevice = new OutputDevice(deviceId); AppManager.Instance.PushToLog("Using output device: " + OutputDevice.GetDeviceCapabilities(deviceId).name, AppManager.LogType.Info); Greet(); } catch (Exception ex) { AppManager.Instance.PushToLog(ex.Message, AppManager.LogType.Error); throw new ApplicationException("Error: " + ex); } } }
public InputDeviceDialog() { InitializeComponent(); if (InputDevice.DeviceCount > 0) { for (int i = 0; i < InputDevice.DeviceCount; i++) { inputComboBox.Items.Add(InputDevice.GetDeviceCapabilities(i).name); } inputComboBox.SelectedIndex = inputDeviceID; } }
public string GetDetail() { MidiInCaps midiincap = InputDevice.GetDeviceCapabilities(DeviceID); string res = ""; res = res + "ControllerName: " + midiincap.name + "\r\n"; res = res + "DriverVersion: " + midiincap.driverVersion.ToString() + "\r\n"; res = res + "ManufacturerID: " + midiincap.mid.ToString() + "\r\n"; res = res + "ProductID: " + midiincap.pid.ToString() + "\r\n"; res = res + "SupportID: " + midiincap.support.ToString() + "\r\n"; return(res); }
private string[] GetDriverNames() { var drivers = new string[InputDevice.DeviceCount]; if (InputDevice.DeviceCount > 0) { for (int i = 0; i < InputDevice.DeviceCount; i++) { drivers[i] = InputDevice.GetDeviceCapabilities(i).name; } } return(drivers); }
public void GetMidiInfo() { for (int i = 0; i < InputDevice.DeviceCount; i++) { MidiInCaps caps = InputDevice.GetDeviceCapabilities(i); im[i] = new InputMidi(caps.name, i); } for (int i = 0; i < OutputDevice.DeviceCount; i++) { MidiOutCaps caps = OutputDevice.GetDeviceCapabilities(i); om[i] = new OutputMidi(caps.name, i); } }
private int CountInputByName(string name) { int result = 0; for (int i = 0; i < InputDevice.DeviceCount; i++) { if (InputDevice.GetDeviceCapabilities(i).name == name) { result++; } } return(result); }
public static List <string> AvailableMidiDevices() { if (deviceNames == null) { deviceNames = new List <string>(); for (int i = 0; i < InputDevice.DeviceCount; i++) { MidiInCaps deviceCaps = InputDevice.GetDeviceCapabilities(i); deviceNames.Add(deviceCaps.name); UnityEngine.Debug.Log(string.Format("Midi Device {0}: {1}", i, deviceCaps.name)); } } return(deviceNames); }
private void Initialize(int i) { active = false; index = i; caps = InputDevice.GetDeviceCapabilities(index); try { device = new InputDevice(index); } catch (Exception ex) { //throw; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { DeviceListener deviceListener = new DeviceListener(); deviceListener.Load(MessagesTextBox); MessagesTextBox.TextChanged += MessagesTextBox_TextChanged; LabelDeviceCount.Content = $"Device count: {InputDevice.DeviceCount}"; LabelDeviceName.Content = $"Device name: {InputDevice.GetDeviceCapabilities(0).name}"; LabelDeviceMID.Content = $"Device MID: {InputDevice.GetDeviceCapabilities(0).mid}"; LabelDevicePID.Content = $"Device PID: {InputDevice.GetDeviceCapabilities(0).pid}"; LabelDeviceSPP.Content = $"Device Support: {InputDevice.GetDeviceCapabilities(0).support}"; LabelDeviceDV.Content = $"Device Driver ver: {InputDevice.GetDeviceCapabilities(0).driverVersion}"; }
/// <summary> /// connexion au launchpad /// </summary> /// <param name="name"></param> /// <exception cref="AlreadyConnectedMidiDevice"></exception> /// <exception cref="ErrorMidiConnexionException"></exception> public static void Connect() { _VirtualMidiPort = new TeVirtualMIDI("VirtualPort"); _msg = new ChannelMessageBuilder(); if (!connected) { try { OutDevCount = OutputDevice.DeviceCount; InDevCount = InputDevice.DeviceCount; for (int i = 0; i < OutDevCount; i++) { if (OutputDevice.GetDeviceCapabilities(i).name == midiDeviceName) { LaunchpadOutID = i; } } for (int i = 0; i < InDevCount; i++) { if (InputDevice.GetDeviceCapabilities(i).name == midiDeviceName) { LaunchpadInID = i; } } _InputLaunchPad = new InputDevice(LaunchpadInID); _InputLaunchPad.ChannelMessageReceived += HandleChannelMessageReceived; _OutputLaunchPad = new OutputDevice(LaunchpadOutID); _InputLaunchPad.StartRecording(); connected = true; } catch (Exception) { throw new ErrorMidiConnexionException(); } } else { throw new AlreadyConnectedMidiDevice(); } }
private InputDevice CreateMidiIn(string name) { for (int i = 0; i < InputDevice.DeviceCount; i++) { var caps = InputDevice.GetDeviceCapabilities(i); if (caps.name.Equals(name, StringComparison.OrdinalIgnoreCase)) { var device = new InputDevice(i); device.MessageReceived += DeviceOnMessageReceived; device.StartRecording(); return(device); } } return(null); }