// 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 MIDIOutDevice(int deviceID) : base(deviceID) { // query number of input devices int numOutputDevices = midiOutGetNumDevs(); if (numOutputDevices <= 0) { return; } // look for the input device that's MIDI controller for (int i = 0; i < numOutputDevices; i++) { MidiOutCaps caps = GetDeviceCapabilities(i); } // open the output device midiOutProc = HandleMessage; int result = midiOutOpen(ref hndle, deviceID, midiOutProc, 0, CALLBACK_FUNCTION); if (result != MIDIExceptions.MMSYSERR_NOERROR) { throw new OutputDeviceException(result); } }
void Start() { var numDevs = midiOutGetNumDevs(); MidiOutCaps myCaps = new MidiOutCaps(); var res = midiOutGetDevCaps(0, ref myCaps, (System.UInt32)Marshal.SizeOf(myCaps)); chatVertScroll = GameObject.Find("Chat Scrollbar Vertical").GetComponent <Scrollbar>(); client = new TcpClient("irc.chat.twitch.tv", port); stream = client.GetStream(); // Send the message to the connected TcpServer. string loginstring = "PASS oauth:" + oauth + "\r\nNICK " + nickname + "\r\n"; Byte[] login = System.Text.Encoding.ASCII.GetBytes(loginstring); stream.Write(login, 0, login.Length); // send message to join channel string joinstring = "JOIN " + "#" + channel + "\r\n"; Byte[] join = System.Text.Encoding.ASCII.GetBytes(joinstring); stream.Write(join, 0, join.Length); coroutine = UpdateImage(); StartCoroutine(coroutine); PlayMidi(); }
private void FormBB7UDPMIDI_Load(object sender, EventArgs e) { var numDevs = midiOutGetNumDevs(); if (numDevs > 0) { for (int i = 0; i < numDevs; i++) { MidiOutCaps myCaps = new MidiOutCaps(); int result2 = midiOutGetDevCaps(i, ref myCaps, (UInt32)Marshal.SizeOf(myCaps)); comboBoxMidiDevice.Items.Add(string.Format("{0} - {1}", i, myCaps.szPname)); } if (numDevs > 0) { comboBoxMidiDevice.SelectedIndex = numDevs - 1; } UdpClient socket = new UdpClient(int.Parse(textBoxUDPPort.Text)); IPAddress multicastaddress = IPAddress.Parse("239.0.0.1"); socket.JoinMulticastGroup(multicastaddress); socket.BeginReceive(new AsyncCallback(OnUdpData), socket); } else { MessageBox.Show("ERROR : NO MIDI DEVICES FOUND"); } textBoxPacketsRec.ReadOnly = true; }
private void InitializeMidiDevices(SavedSettings settings) { int selectedindex = 0; MidiOutCaps caps = new MidiOutCaps(); for (int c = 0; c < midiOutGetNumDevs(); c++) { int result = midiOutGetDevCaps(c, ref caps, Marshal.SizeOf(caps)); cmbMidiDevices.Items.Add(caps.name); if (settings.midiDeviceName != null && caps.name == settings.midiDeviceName) { selectedindex = cmbMidiDevices.Items.Count - 1; } } if (settings.midiDeviceName != null) { if (selectedindex == 0) { MessageBox.Show("Midi device from file not available"); } else { cmbMidiDevices.SelectedIndex = selectedindex; } } }
/// <summary> /// Internal Constructor, only called by the getter for the InstalledDevices property. /// </summary> /// <param name="deviceId">Position of this device in the list of all devices.</param> /// <param name="caps">Win32 Struct with device metadata</param> internal OutputDevice(UIntPtr deviceId, MidiOutCaps caps) : base(caps.szPname) { _deviceId = deviceId; _caps = caps; _isOpen = false; }
static MidiPlayer() { MidiOutCaps capabilities = new MidiOutCaps(); CheckError(midiOutGetDevCaps(0, ref capabilities, MidiOutCaps.Size)); CheckError(midiOutOpen(ref Handle, 0, null, 0, 0)); }
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; }
/// <inheritdoc /> public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false) { IsInitialized = false; try { UpdateTrigger?.Stop(); IList <IRGBDevice> devices = new List <IRGBDevice>(); if (loadFilter.HasFlag(RGBDeviceType.LedMatrix)) { for (int index = 0; index < OutputDeviceBase.DeviceCount; index++) { try { MidiOutCaps outCaps = OutputDeviceBase.GetDeviceCapabilities(index); if (outCaps.name == null) { continue; } NovationDevices?deviceId = (NovationDevices?)Enum.GetValues(typeof(NovationDevices)) .Cast <Enum>() .FirstOrDefault(x => string.Equals(x.GetDeviceId(), outCaps.name, StringComparison.OrdinalIgnoreCase)); if (deviceId == null) { continue; } INovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability())); device.Initialize(UpdateTrigger); devices.Add(device); } catch { if (throwExceptions) { throw; } } } } UpdateTrigger?.Start(); Devices = new ReadOnlyCollection <IRGBDevice>(devices); IsInitialized = true; } catch { if (throwExceptions) { throw; } return(false); } return(true); }
/// <summary> Populate the form's controls with default settings. </summary> private void InitializeControlValues() { // Midi Setup if (midiOutGetNumDevs() == 0) { MessageBox.Show(this, "No MIDI output ports detected.", "No MIDI ports", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } MidiOutCaps caps = new MidiOutCaps(); for (int c = 0; c < midiOutGetNumDevs(); c++) { int result = midiOutGetDevCaps(c, ref caps, Marshal.SizeOf(caps)); midiPortBox.Items.Add(caps.name); } if (midiPortBox.Items.Contains(Settings.Default.midiPort)) { midiPortBox.Text = Settings.Default.midiPort; } else { midiPortBox.SelectedIndex = 0; } // Serial Setup cmbParity.Items.Clear(); cmbParity.Items.AddRange(Enum.GetNames(typeof(Parity))); cmbStopBits.Items.Clear(); cmbStopBits.Items.AddRange(Enum.GetNames(typeof(StopBits))); cmbParity.Text = Settings.Default.Parity.ToString(); cmbStopBits.Text = Settings.Default.StopBits.ToString(); cmbDataBits.Text = Settings.Default.DataBits.ToString(); cmbParity.Text = Settings.Default.Parity.ToString(); cmbBaudRate.Text = Settings.Default.BaudRate.ToString(); CurrentDataMode = Settings.Default.DataMode; cmbPortName.Items.Clear(); foreach (string s in SerialPort.GetPortNames()) { cmbPortName.Items.Add(s); } if (cmbPortName.Items.Contains(Settings.Default.PortName)) { cmbPortName.Text = Settings.Default.PortName; } else if (cmbPortName.Items.Count > 0) { cmbPortName.SelectedIndex = 0; } else { MessageBox.Show(this, "No COM ports detected.", "No COM ports", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
/// <summary> /// Create new instance of MidiOutputDeviceInfo /// </summary> /// <param name="caps"></param> public MidiOutputDeviceInfo(MidiOutCaps caps) { ChannelMask = caps.channelMask; DriverVersion = caps.driverVersion; Mid = caps.mid; Name = caps.name; Notes = caps.notes; Pid = caps.pid; Support = caps.support; Technology = caps.technology; Voices = caps.voices; }
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); } }
public string GetDetail() { MidiOutCaps midioutcap = OutputDevice.GetDeviceCapabilities(DeviceID); string res = ""; res = res + "ControllerName: " + midioutcap.name + "\r\n"; res = res + "DriverVersion: " + midioutcap.driverVersion.ToString() + "\r\n"; res = res + "ManufacturerID: " + midioutcap.mid.ToString() + "\r\n"; res = res + "ProductID: " + midioutcap.pid.ToString() + "\r\n"; res = res + "SupportID: " + midioutcap.support.ToString() + "\r\n"; return(res); }
// Get device capabilities. public static MidiOutCaps GetDeviceCapabilities(int deviceID) { int result; MidiOutCaps caps = new MidiOutCaps(); result = midiOutGetDevCaps(deviceID, ref caps, Marshal.SizeOf(caps)); if (result != MIDIExceptions.MMSYSERR_NOERROR) { throw new OutputDeviceException(result); } return(caps); }
private int GetMidiDeviceIndex(string name) { MidiOutCaps caps = new MidiOutCaps(); for (int c = 0; c < midiOutGetNumDevs(); c++) { int result = midiOutGetDevCaps(c, ref caps, Marshal.SizeOf(caps)); if (caps.name == name) { return(c); } } return(-1); }
public static string ListAll() { string res = "MidiOut Devices:\r\n\r\n"; for (int i = 0; i < OutputDevice.DeviceCount; i++) { MidiOutCaps midioutcap = OutputDevice.GetDeviceCapabilities(i); res = res + "ControllerName: " + midioutcap.name + "\r\n"; res = res + "DriverVersion: " + midioutcap.driverVersion.ToString() + "\r\n"; res = res + "ManufacturerID: " + midioutcap.mid.ToString() + "\r\n"; res = res + "ProductID: " + midioutcap.pid.ToString() + "\r\n"; res = res + "SupportID: " + midioutcap.support.ToString() + "\r\n"; res = res + "\r\n"; } return(res); }
public static MIDI Get(string productname) { foreach (var Device in LoadDevices) { if (Device.GetProductName().StartsWith(productname)) { return(Device); } } for (int i = 0; i < OutputDevice.DeviceCount; i++) { MidiOutCaps midioutcap = OutputDevice.GetDeviceCapabilities(i); if (midioutcap.name.StartsWith(productname)) { MIDI newdevice = new MIDI(i); LoadDevices.Add(newdevice); return(newdevice); } } return(null); }
public void initialize() { int outDeviceCount = midiOutGetNumDevs(); for (int i = 0; i < outDeviceCount; i++) { MidiOutCaps moc = new MidiOutCaps(); midiOutGetDevCaps(i, ref moc, (int)Marshal.SizeOf(typeof(MidiOutCaps))); MidiOutDevice outDev = new MidiOutDevice(i, moc); outDeviceList.Add(outDev); } int inDeviceCount = midiInGetNumDevs(); for (int i = 0; i < inDeviceCount; i++) { MidiInCaps mic = new MidiInCaps(); midiInGetDevCaps(i, ref mic, (int)Marshal.SizeOf(typeof(MidiInCaps))); MidiInDevice inDev = new MidiInDevice(i, mic); inDeviceList.Add(inDev); } }
public void AddRoute(int inport, int outport) { if (!outMidiList.Contains(outport)) { outMidiList.Add(outport); om[outport].InitOutputDevice(); } if (inport > MINMIDIPORT) { MidiOutCaps caps = OutputDevice.GetDeviceCapabilities(outport); umpl.Add(inport, om[outport]); } else { if (!inMidiList.Contains(inport)) { inMidiList.Add(inport); im[inport].InitInputDevice(); //if (MidiRoutes[i].AllRoutes) { im[inport].inMIDI.SysCommonMessageReceived += HandleSysCommonMessageReceived; im[inport].inMIDI.ChannelMessageReceived += HandleChannelMessageReceived; im[inport].inMIDI.SysExMessageReceived += HandleSysExMessageReceived; im[inport].inMIDI.SysRealtimeMessageReceived += HandleSysRealtimeMessageReceived; im[inport].inMIDI.Error += new EventHandler <Sanford.Multimedia.ErrorEventArgs>(inDevice_Error); } } if (MidiRoutes[inport] == null) { MidiRoutes[inport] = new Route(); } MidiRoutes[inport].AddRoute(outport, true); } dirty = true; }
public void RefreshDevices() { int Count = 0, i = 0, j = 0; List <Device> devList = new List <Device>(); Count = InputDevice.DeviceCount; for (i = 0; i < Count; i++) { devList.Add(new Device(i)); } Count = OutputDevice.DeviceCount; for (i = 0; i < Count; i++) { MidiOutCaps cap = OutputDevice.GetDeviceCapabilities(i); for (j = 0; j < devList.Count; j++) { if (devList[j].Name == cap.name) { devList[j].SetOutputDevice(i); } } } /*foreach (Device dev in devList) * { * bool found = true; * * for(int i =0; i<mDeviceList.Count; i++) * if (mDeviceList[i].Name == dev.Name) * { * found = true; * break; * } * if(!found) * }*/ mDeviceList = devList; }
public bool Open(int devIndex) { //var numDevs = midiOutGetNumDevs(); if (devIndex <= cntMIDIDev) { SelectedDevice = devIndex; MidiOutCaps myCaps = new MidiOutCaps(); int moCaps = midiOutGetDevCaps(devIndex, ref myCaps, (UInt32)Marshal.SizeOf(myCaps)); int moOpen = midiOutOpen(ref hndMIDI, devIndex, null, 0, 0); Console.WriteLine("MIDI -> Open() -> Device:{0}, Caps:{1}, Open:{2}, Name:{3} - v{4}", devIndex, moCaps == 0?"OK":"ER", moOpen == 0?"OK":"ER", myCaps.szPname, myCaps.vDriverVersion); IsOpen = true; SetInstrument(MIDI_Instruments.AcousticGrandPiano); return(IsOpen); } else { IsOpen = false; return(IsOpen); } }
public Boolean InitializeMIDI(String device) { connected = false; int devices = OutputDevice.DeviceCount; if (devices == 0) { MessageBox.Show("No MIDI output devices available.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } else { try { context = SynchronizationContext.Current; for (int i = 0; i < devices; i++) { MidiOutCaps caps = OutputDevice.GetDeviceCapabilities(i); if (caps.name == device) { ConnectMIDI(i); return(true); } } MessageBox.Show(device + " device not found!", "MIDI Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } catch (Exception ex) { MessageBox.Show(ex.Message, "MIDI Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } } }
public static extern int midiOutGetDevCaps(uint uDeviceID, out MidiOutCaps lpMidiOutCaps, int cbMidiOutCaps);
protected static extern int midiOutGetDevCaps(int deviceID, ref MidiOutCaps caps, int sizeOfMidiOutCaps);
/// <summary> /// Constructs a new instance based on the unmanaged structure. /// </summary> /// <param name="caps">Reference to the unmanaged structure.</param> internal MidiOutPortCaps(ref MidiOutCaps caps) : this(caps.Mid, caps.Pid, caps.DriverVersion, caps.Name, caps.Technology, caps.Voices, caps.Notes, caps.ChannelMask, caps.Support) { }
/// <summary> Populate the form's controls with default settings. </summary> private void InitializeControlValues() { // Midi Setup if (midiOutGetNumDevs() == 0) { MessageBox.Show(this, "No MIDI output ports detected.", "No MIDI ports", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } MidiOutCaps caps = new MidiOutCaps(); for (int c = 0; c < midiOutGetNumDevs(); c++) { int result = midiOutGetDevCaps(c, ref caps, Marshal.SizeOf(caps)); midiPortBox.Items.Add(caps.name); } if (midiPortBox.Items.Contains(Settings.Default.midiPort)) midiPortBox.Text = Settings.Default.midiPort; else midiPortBox.SelectedIndex = 0; // Serial Setup cmbParity.Items.Clear(); cmbParity.Items.AddRange(Enum.GetNames(typeof(Parity))); cmbStopBits.Items.Clear(); cmbStopBits.Items.AddRange(Enum.GetNames(typeof(StopBits))); cmbParity.Text = Settings.Default.Parity.ToString(); cmbStopBits.Text = Settings.Default.StopBits.ToString(); cmbDataBits.Text = Settings.Default.DataBits.ToString(); cmbParity.Text = Settings.Default.Parity.ToString(); cmbBaudRate.Text = Settings.Default.BaudRate.ToString(); CurrentDataMode = Settings.Default.DataMode; cmbPortName.Items.Clear(); foreach (string s in SerialPort.GetPortNames()) cmbPortName.Items.Add(s); if (cmbPortName.Items.Contains(Settings.Default.PortName)) cmbPortName.Text = Settings.Default.PortName; else if (cmbPortName.Items.Count > 0) cmbPortName.SelectedIndex = 0; else { MessageBox.Show(this, "No COM ports detected.", "No COM ports", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private static extern int midiOutGetDevCaps(int deviceID, ref MidiOutCaps caps, int sizeOfMidiInCaps);
static extern int midiOutGetDevCaps(int deviceIndex, ref MidiOutCaps caps, int sizeOfMidiOutCaps);
private static extern int midiOutGetDevCaps(System.Int32 uDeviceID, ref MidiOutCaps lpMidiOutCaps, System.UInt32 cbMidiOutCaps);
public MidiOutDevice(int index_, MidiOutCaps moc) { name = moc.szPname; index = index_; }
protected override void OnLoad(EventArgs e) { if (OutputDevice.DeviceCount == 0) { MessageBox.Show("No MIDI output devices available.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); Close(); } else { try { int foo = InputDevice.DeviceCount; int i = 0; int APCfound = 0; for (i = 0; i < foo; i++) { MidiInCaps mdevices = InputDevice.GetDeviceCapabilities(i); int ii = i + 1; listBox1.Items.Add((string)"PORT " + ii.ToString() + '\t' + '\t' + mdevices.name.ToString() + '\t'); if (mdevices.name.ToString() == "APC control") { listBox1.SelectedIndex = listBox1.Items.Count - 1; } listBox3.Items.Add((string)"PORT " + ii.ToString() + '\t' + '\t' + mdevices.name.ToString() + '\t'); if (mdevices.name.ToString() == "APC MINI") { APCfound = 1; listBox3.SelectedIndex = listBox3.Items.Count - 1; } listBox5.Items.Add((string)"PORT " + ii.ToString() + '\t' + '\t' + mdevices.name.ToString() + '\t'); if (mdevices.name.ToString() == "Mixer") { listBox5.SelectedIndex = listBox5.Items.Count - 1; } } if (APCfound == 0) { MessageBox.Show("No APC MINI device available.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); Close(); } int bar = OutputDevice.DeviceCount; i = 0; for (i = 0; i < bar; i++) { MidiOutCaps odevices = OutputDevice.GetDeviceCapabilities(i); int ii = i + 1; listBox2.Items.Add((string)"PORT " + ii.ToString() + '\t' + '\t' + odevices.name.ToString() + '\t'); if (odevices.name.ToString() == "Lights") { listBox2.SelectedIndex = listBox2.Items.Count - 1; } listBox4.Items.Add((string)"PORT " + ii.ToString() + '\t' + '\t' + odevices.name.ToString() + '\t'); if (odevices.name.ToString() == "APC MINI") { listBox4.SelectedIndex = listBox4.Items.Count - 1; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop); Close(); } } base.OnLoad(e); }
public static extern int midiOutGetDevCaps(int deviceID, ref MidiOutCaps caps, int capsSize);