Example #1
0
        /// <summary>  
        /// 5バイト以上のMIDIメッセージ(Long Message)を送信します。  
        /// </summary>  
        void SendLongMessage( byte [] data )
        {
            if ( data.Length > maxBufferSize )
            {
                throw new InvalidOperationException ();
            }

            MidiHdr hdr = new MidiHdr ();
            hdr.dwReserved = new IntPtr [ 8 ];

            GCHandle dataHandle = GCHandle.Alloc ( data, GCHandleType.Pinned );

            try
            {
                hdr.lpData = dataHandle.AddrOfPinnedObject ();
                hdr.dwBufferLength = (uint)data.Length;
                hdr.dwFlags = 0;

                SendBuffer ( hdr );
            }
            finally
            {
                dataHandle.Free ();
            }
        }
Example #2
0
 internal static extern MMResult midiOutUnprepareHeader( [MarshalAs ( UnmanagedType.SysUInt )] IntPtr hMidiOut, ref MidiHdr lpMidiOutHdr, [MarshalAs ( UnmanagedType.U4 )] uint uSize );
Example #3
0
        void SendBuffer( MidiHdr hdr )
        {
            MidiOutApi.midiOutPrepareHeader ( hMidiOut, ref hdr, hdrSize ).Throw ();
            while ( ( hdr.dwFlags & MidiHdrFlag.Prepared ) != MidiHdrFlag.Prepared )
            {
                Thread.Sleep ( 1 );
            }

            MidiOutApi.midiOutLongMsg ( hMidiOut, ref hdr, hdrSize ).Throw ();

            while ( ( hdr.dwFlags & MidiHdrFlag.Done ) != MidiHdrFlag.Done )
            {
                Thread.Sleep ( 1 );
            }
            MidiOutApi.midiOutUnprepareHeader ( hMidiOut, ref hdr, hdrSize ).Throw ();
        }