Esempio n. 1
0
        public void MIDI_Play_newCode()
        {
            res = MIDI_WIN32_MSDN.midiOutGetDevCaps(0, ref formCap, (UInt32)Marshal.SizeOf(formCap));
            res = MIDI_WIN32_MSDN.midiOutOpen(ref ohandle, 0, null, 0, 0);

            //MIDI_Model.HMIDIOUT hOut = new MIDI_Model.HMIDIOUT();
            //MIDI_Model.MidiOutProc mOutProc = new MIDI_Model.MidiOutProc(hOut);

            for (int i = 0; i < view.noteDict.Count; i++)
            {
                byte[] data = new byte[4];
                data[0] = 0x90;
                data[1] = view.noteDict[i].noteLevel;
                data[2] = 127;  // Note Volume

                uint msg = BitConverter.ToUInt32(data, 0);
                res = MIDI_WIN32_MSDN.midiOutShortMsg(ohandle, (int)msg);
            }
            res = MIDI_WIN32_MSDN.midiOutClose(ohandle);
        }
Esempio n. 2
0
        public void MIDIOpenOutDevice()
        {
            hMIDIOUT = new MIDI_WIN32_MSDN.HMIDIOUT();

            /// Open the MIDI output device

            MMRESULT = MIDI_WIN32_MSDN.midiOutOpen(out hMIDIOUT, UIntPtr.Zero, null, UIntPtr.Zero);

            if (MMRESULT == MIDI_WIN32_MSDN.MMRESULT.MMSYSERR_ERROR)
            {
                Console.WriteLine("MIDI OUT OPEN ERR");
                return;
            }

            /// Before playing a MIDI file, you should use the midiOutGetDevCaps function
            /// to determine the capabilities of the MIDI output device that is present in the system.
            /// This function takes an address of a MIDIOUTCAPS structure,
            /// which it fills with information about the capabilities of the given device.

            MIDI_WIN32_MSDN.midiOutGetDevCaps(0, ref MidiOutCap, (uint)Marshal.SizeOf(typeof(MIDI_WIN32_MSDN.MidiOutCaps)));
        }