Exemple #1
0
    public void Disconnect(MIDIdevice m, bool input, midiComponentInterface _interface = null)
    {
        if (input)
        {
            if (!connectedInputDevices.Contains(m))
            {
                return;
            }

            if (_interface != null)
            {
                m.removeInterface(_interface);
                (m.getDevice() as InputDevice).NoteOn        -= new InputDevice.NoteOnHandler(_interface.InputNoteOn);
                (m.getDevice() as InputDevice).NoteOff       -= new InputDevice.NoteOffHandler(_interface.InputNoteOff);
                (m.getDevice() as InputDevice).ControlChange -= new InputDevice.ControlChangeHandler(_interface.InputControlChange);
            }
            else
            {
                for (int i = 0; i < m._interfaceList.Count; i++)
                {
                    (m.getDevice() as InputDevice).NoteOn        -= new InputDevice.NoteOnHandler(m._interfaceList[i].InputNoteOn);
                    (m.getDevice() as InputDevice).NoteOff       -= new InputDevice.NoteOffHandler(m._interfaceList[i].InputNoteOff);
                    (m.getDevice() as InputDevice).ControlChange -= new InputDevice.ControlChangeHandler(m._interfaceList[i].InputControlChange);
                }


                (m.getDevice() as InputDevice).StopReceiving();
                (m.getDevice() as InputDevice).Close();
                (m.getDevice() as InputDevice).RemoveAllEventHandlers();
                connectedInputDevices.Remove(m);
            }
        }
        else
        {
            if (!connectedOutputDevices.Contains(m))
            {
                return;
            }

            if (_interface == null)
            {
                (m.getDevice() as OutputDevice).Close();
                connectedOutputDevices.Remove(m);
            }
        }
    }
Exemple #2
0
    public void outputNote(MIDIdevice _dev, bool on, int ID, int channel)
    {
        if (_dev.input)
        {
            Debug.Log("problem");
            return;
        }

        if (on)
        {
            (_dev.getDevice() as OutputDevice).SendNoteOn((Channel)channel, (Pitch)ID, 127);
        }
        else
        {
            (_dev.getDevice() as OutputDevice).SendNoteOff((Channel)channel, (Pitch)ID, 127);
        }
    }
Exemple #3
0
    public void outputCC(MIDIdevice _dev, int val, int ID, int channel)
    {
        if (_dev.input)
        {
            Debug.Log("problem");
            return;
        }
        Channel c1 = (Channel)channel;
        Control c2 = (Control)ID;
        string  s  = c2.ToString();

        if (c2.IsValid())
        {
            (_dev.getDevice() as OutputDevice).SendControlChange(c1, c2, val);
        }
        else
        {
            Debug.Log("problem b");
        }
    }