public static void SendMidiMessage(MidiDeviceHandle handle, int message) { if (handle == null) { throw new ArgumentNullException("handle", "The handle does not exist. Make sure the MIDI device has been opened."); } int rv = NativeMethods.MidiOutShortMessage(handle.Handle, message); if (rv != 0) { ThrowMCIError(rv, "Could not execute message '" + message + "'."); } }
/// <summary>Sends the message to as a short MIDI message to the MIDI output device.</summary> /// <param name="handle">Handle to the MIDI output device.</param> /// <param name="message">The message to be sent.</param> public static void SendMidiMessage(MidiDeviceHandle handle, int message) { if (handle == null) { throw new ArgumentNullException("handle", "The handle does not exist. Make sure the MIDI device has been opened."); } int rv = NativeMethods.MidiOutShortMessage(handle.Handle, message); if (rv != 0) { ThrowMCIError(rv, "Could not execute message '" + message + "'."); } }
/// <summary> /// Sends a long MIDI message to the specified <see cref="MidiOutputDevice"/>. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> referencing the MIDI output device to send the short MIDI message to.</param> /// <param name="midiHeader">A <see cref="IntPtr"/> referencing the <see cref="MidiHeader"/> structure containing the data to send.</param> /// <param name="midiHeaderSize">An <see cref="int"/> specifying the size in bytes of the <see cref="MidiHeader"/> structure.</param> /// <returns>A <see cref="Result"/> value containing the result of the API call.</returns> internal static Result SendLongMessage(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize) { return(midiOutLongMsg(deviceHandle, midiHeader, midiHeaderSize)); }
/// <summary> /// Sends a short MIDI message to the specified <see cref="MidiOutputDevice"/>. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> referencing the MIDI output device to send the short MIDI message to.</param> /// <param name="message">An <see cref="int"/> containting the MIDI message to send.</param> /// <returns>A <see cref="Result"/> value containing the result of the API call.</returns> internal static Result SendShortMessage(MidiDeviceHandle deviceHandle, int message) { return(midiOutShortMsg(deviceHandle, message)); }
/// <summary> /// Disconnects a MIDI input device from a MIDI thru or output device or disconnects a MIDI thru device from a MIDI output device. /// </summary> /// <param name="inputMidiDeviceHandle">An <see cref="MidiDeviceHandle"/> referencing the MIDI input or thru device to disconnect.</param> /// <param name="outputMidiDeviceHandle">An <see cref="MidiDeviceHandle"/> referencing the MIDI output or thru device to disconnect.</param> /// <returns>A <see cref="MultiMediaResult"/> value containing the result of the API call.</returns> public static Result DisconnectMidiDevices(MidiDeviceHandle inputMidiDeviceHandle, MidiDeviceHandle outputMidiDeviceHandle) { return(midiDisconnect(inputMidiDeviceHandle, outputMidiDeviceHandle, IntPtr.Zero)); }
/// <summary> /// Method to stop receiving MIDI data on a MIDI input device. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> referencing the MIDI input device to stop receiving.</param> /// <returns>A <see cref="Result"/> value containing the result of the API call.</returns> internal static Result StopMidiInputDevice(MidiDeviceHandle deviceHandle) { return(midiInStop(deviceHandle)); }
/// <summary> /// Resets the specified MIDI input device, stopping input on all MIDI channels. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> referencing the MIDI input device to reset.</param> /// <returns>A <see cref="Result"/> value containing the result of the API call.</returns> internal static Result ResetMidiInputDevice(MidiDeviceHandle deviceHandle) { return(midiInReset(deviceHandle)); }
/// <summary> /// Cleans the preparation performed by the <see cref="PrepareMidiInputHeader"/> method. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> referencing the MIDI input device to unprepare the buffer for.</param> /// <param name="midiHeader">A <see cref="IntPtr"/> referencing the <see cref="MidiHeader"/> structure that identifies the buffer to be unprepared.</param> /// <param name="midiHeaderSize">An <see cref="int"/> specifying the size in bytes of the <see cref="MidiHeader"/> structure.</param> /// <returns>A <see cref="Result"/> value containing the result of the API call.</returns> internal static Result UnprepareMidiInputHeader(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize) { return(midiInUnprepareHeader(deviceHandle, midiHeader, midiHeaderSize)); }
/// <summary> /// Opens the specified MIDI input device for receiving MIDI data. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> to store the obtained device handle.</param> /// <param name="deviceID">An <see cref="int"/> representing the MIDI input device's ID.</param> /// <param name="callback">A <see cref="MidiInputDelegate"/> specifying the callback function to process MIDI messages.</param> /// <param name="callbackInstance">An <see cref="IntPtr"/> specifying user instance data passed to the callback function.</param> /// <returns>A <see cref="Result"/> value containing the result of the API call.</returns> internal static Result OpenMidiInputDevice(ref MidiDeviceHandle deviceHandle, int deviceID, MidiInputDelegate callback, IntPtr callbackInstance) { return(midiInOpen(ref deviceHandle, deviceID, callback, callbackInstance, callback == null ? MidiOpenFlags.CALLBACK_NULL : MidiOpenFlags.CALLBACK_FUNCTION | MidiOpenFlags.CALLBACK_IO_STATUS)); }
private static extern Result midiOutShortMsg(MidiDeviceHandle deviceHandle, int message);
private static extern Result midiOutReset(MidiDeviceHandle deviceHandle);
private static extern Result midiOutClose(MidiDeviceHandle deviceHandle);
private static extern Result midiDisconnect(MidiDeviceHandle handleA, MidiDeviceHandle handleB, IntPtr reserved);
private static extern Result midiInAddBuffer(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize);
private static extern Result midiInStop(MidiDeviceHandle deviceHandle);
private static extern Result midiOutUnprepareHeader(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize);
/// <summary> /// Adds a buffer to the MIDI input device in order to receive long MIDI messages. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> referencing the MIDI input device to add the buffer to.</param> /// <param name="midiHeader">A <see cref="IntPtr"/> referencing the <see cref="MidiHeader"/> structure that identifies the buffer to add.</param> /// <param name="midiHeaderSize">An <see cref="int"/> specifying the size in bytes of the <see cref="MidiHeader"/> structure.</param> /// <returns>A <see cref="Result"/> value containing the result of the API call.</returns> internal static Result AddMidiInputBuffer(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize) { return(midiInAddBuffer(deviceHandle, midiHeader, midiHeaderSize)); }
/// <summary> /// Closes the specified MIDI input device. /// </summary> /// <param name="deviceHandle">A <see cref="MidiDeviceHandle"/> referencing the MIDI input device to close.</param> /// <returns>A <see cref="MultiMediaResult"/> value containing the result of the API call.</returns> internal static Result CloseMidiInputDevice(MidiDeviceHandle deviceHandle) { return(midiInClose(deviceHandle)); }
private static extern Result midiInOpen(ref MidiDeviceHandle deviceHandle, int deviceID, MidiInputDelegate callback, IntPtr callbackInstance, MidiOpenFlags flags);
private static extern Result midiOutLongMsg(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize);