void OnDisable() { var res = 0; midiInState = MIDI_STATE.END; res = midiInStop(iMidi); res = midiInClose(iMidi); res = midiOutClose(oMidi); }
void Update() { if (inMessge == MIDI_CLOSE && midiInState == MIDI_STATE.CLOSE) { reConnection = StartCoroutine(ReConnect()); midiInState = MIDI_STATE.RE_OPEN; } if (isReceived) { OnMidiInput(inMessge, inState, inPicth, inVelocity); isReceived = false; } }
void InCallBack(long handle, int msg, int instance, int param1, int param2) { inMessge = msg; inState = param1 & 0xff; inPicth = param1 >> 8 & 0xff; inVelocity = param1 >> 16 & 0xff; if (msg == MIDI_OPEN) { midiInState = MIDI_STATE.OPEN; } else if (msg == MIDI_CLOSE) { midiInState = MIDI_STATE.CLOSE; } else if (msg == MIDI_DATA) { isReceived = true; } }
public void MidiInOpen(uint deviceID) { inDviceID = deviceID; if (midiInState == MIDI_STATE.OPEN) { return; } var res = midiInOpen(ref iMidi, deviceID, InCallBack, 0, CALLBACK_FUNCTION); res = midiInStart(iMidi); if (res != MMSYSERR_NOERROR && midiInState != MIDI_STATE.RE_OPEN) { Debug.LogWarning("MIDI OPEN ERROR : code = " + res); midiInState = MIDI_STATE.RE_OPEN; reConnection = StartCoroutine(ReConnect()); return; } }
void Start() { midiInState = MIDI_STATE.WAIT; }