MCI stubs

P

Phone Box

Hi,
I'm trying to get C# to talk MIDI to a drum machine. As soon as I can
get the MCI functions to compile I'm home and dry. Please can someone point
me in the right direction on how to do this? All I really want is to use the
calls in the DLL via C#. I have found code like this...

[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand,StringBuilder
strReturn,int iReturnLength, IntPtr hwndCallback);
[DllImport("Winmm.dll")]

This sounds like a fairly common operation. I intend to add a series of
these definitions for the following functions...

midiConnect
midiDisconnect
midiInAddBuffer
midiInClose
midiInGetDevCaps
midiInGetErrorText
midiInGetID
midiInGetNumDevs
midiInMessage
midiInOpen
midiInPrepareHeader
MidiInProc
midiInReset
midiInStart
midiInStop
midiInUnprepareHeader
midiOutCacheDrumPatches
midiOutCachePatches
midiOutClose
midiOutGetDevCaps
midiOutGetErrorText
midiOutGetID
midiOutGetNumDevs
midiOutGetVolume
midiOutLongMsg
midiOutMessage
midiOutOpen
midiOutPrepareHeader
MidiOutProc
midiOutReset
midiOutSetVolume
midiOutShortMsg
midiOutUnprepareHeader
midiStreamClose
midiStreamOpen
midiStreamOut
midiStreamPause
midiStreamPosition
midiStreamProperty
midiStreamRestart
midiStreamStop

Many thanks

Peter.
 
N

Nicholas Paldino [.NET/C# MVP]

Peter,

You are going to have to code these by hand, or find someone that
already did them. You might want to try http://www.pinvoke.net and see if
someone already created the definitions. If not, then I would suggest
contributing your method definitions once you create them.
 
P

Phone Box

Phone Box said:
Hi,
I'm trying to get C# to talk MIDI to a drum machine. As soon as I can
get the MCI functions to compile I'm home and dry. Please can someone
point me in the right direction on how to do this? All I really want is to
use the calls in the DLL via C#. I have found code like this...

[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand,StringBuilder
strReturn,int iReturnLength, IntPtr hwndCallback);
[DllImport("Winmm.dll")]

This sounds like a fairly common operation. I intend to add a series of
these definitions for the following functions...

midiConnect
midiDisconnect
midiInAddBuffer
midiInClose
midiInGetDevCaps
midiInGetErrorText
midiInGetID
midiInGetNumDevs
midiInMessage
midiInOpen
midiInPrepareHeader
MidiInProc
midiInReset
midiInStart
midiInStop
midiInUnprepareHeader
midiOutCacheDrumPatches
midiOutCachePatches
midiOutClose
midiOutGetDevCaps
midiOutGetErrorText
midiOutGetID
midiOutGetNumDevs
midiOutGetVolume
midiOutLongMsg
midiOutMessage
midiOutOpen
midiOutPrepareHeader
MidiOutProc
midiOutReset
midiOutSetVolume
midiOutShortMsg
midiOutUnprepareHeader
midiStreamClose
midiStreamOpen
midiStreamOut
midiStreamPause
midiStreamPosition
midiStreamProperty
midiStreamRestart
midiStreamStop

Many thanks

Peter.

Hi,
So far the following works...

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices; // DLL Needs this

namespace AlesisSR16
{
public class MciClass
{
[DllImport("Winmm.dll")]
static extern uint midiInGetNumDevs();

public static uint MCI_midiInGetNumDevs()
{
return midiInGetNumDevs();
}
}
}

// Activated in an aboutbox handler
private void AboutBoxSR16_Activated(object sender, EventArgs e)
{
uint a = MciClass.MCI_midiInGetNumDevs();
this.textBoxDescription.Text = a.ToString();
}

Cheers

Peter.
 
Top