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 + "'.");
     }
 }
예제 #2
0
        /// <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 + "'.");
            }
        }
예제 #3
0
 /// <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));
 }
예제 #4
0
 /// <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));
 }
예제 #5
0
 /// <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));
 }
예제 #6
0
 /// <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));
 }
예제 #7
0
 /// <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));
 }
예제 #8
0
 /// <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));
 }
예제 #9
0
 /// <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));
 }
예제 #10
0
 private static extern Result midiOutShortMsg(MidiDeviceHandle deviceHandle, int message);
예제 #11
0
 private static extern Result midiOutReset(MidiDeviceHandle deviceHandle);
예제 #12
0
 private static extern Result midiOutClose(MidiDeviceHandle deviceHandle);
예제 #13
0
 private static extern Result midiDisconnect(MidiDeviceHandle handleA, MidiDeviceHandle handleB, IntPtr reserved);
예제 #14
0
 private static extern Result midiInAddBuffer(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize);
예제 #15
0
 private static extern Result midiInStop(MidiDeviceHandle deviceHandle);
예제 #16
0
 private static extern Result midiOutUnprepareHeader(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize);
예제 #17
0
 /// <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));
 }
예제 #18
0
 /// <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));
 }
예제 #19
0
 private static extern Result midiInOpen(ref MidiDeviceHandle deviceHandle, int deviceID, MidiInputDelegate callback, IntPtr callbackInstance, MidiOpenFlags flags);
예제 #20
0
 private static extern Result midiOutLongMsg(MidiDeviceHandle deviceHandle, IntPtr midiHeader, int midiHeaderSize);