MCI stubs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phone Box

    #1

    MCI stubs

    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("winm m.dll")]
    private static extern long mciSendString(s tring strCommand,Stri ngBuilder
    strReturn,int iReturnLength, IntPtr hwndCallback);
    [DllImport("Winm m.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
    midiInGetDevCap s
    midiInGetErrorT ext
    midiInGetID
    midiInGetNumDev s
    midiInMessage
    midiInOpen
    midiInPrepareHe ader
    MidiInProc
    midiInReset
    midiInStart
    midiInStop
    midiInUnprepare Header
    midiOutCacheDru mPatches
    midiOutCachePat ches
    midiOutClose
    midiOutGetDevCa ps
    midiOutGetError Text
    midiOutGetID
    midiOutGetNumDe vs
    midiOutGetVolum e
    midiOutLongMsg
    midiOutMessage
    midiOutOpen
    midiOutPrepareH eader
    MidiOutProc
    midiOutReset
    midiOutSetVolum e
    midiOutShortMsg
    midiOutUnprepar eHeader
    midiStreamClose
    midiStreamOpen
    midiStreamOut
    midiStreamPause
    midiStreamPosit ion
    midiStreamPrope rty
    midiStreamResta rt
    midiStreamStop

    Many thanks

    Peter.


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: MCI stubs

    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.

    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Phone Box" <peter_goddard_ I_Dont_Like_Spa m@ntlworld.comw rote in message
    news:crGqi.9491 $h11.6749@newsf e7-gui.ntli.net...
    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("winm m.dll")]
    private static extern long mciSendString(s tring strCommand,Stri ngBuilder
    strReturn,int iReturnLength, IntPtr hwndCallback);
    [DllImport("Winm m.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
    midiInGetDevCap s
    midiInGetErrorT ext
    midiInGetID
    midiInGetNumDev s
    midiInMessage
    midiInOpen
    midiInPrepareHe ader
    MidiInProc
    midiInReset
    midiInStart
    midiInStop
    midiInUnprepare Header
    midiOutCacheDru mPatches
    midiOutCachePat ches
    midiOutClose
    midiOutGetDevCa ps
    midiOutGetError Text
    midiOutGetID
    midiOutGetNumDe vs
    midiOutGetVolum e
    midiOutLongMsg
    midiOutMessage
    midiOutOpen
    midiOutPrepareH eader
    MidiOutProc
    midiOutReset
    midiOutSetVolum e
    midiOutShortMsg
    midiOutUnprepar eHeader
    midiStreamClose
    midiStreamOpen
    midiStreamOut
    midiStreamPause
    midiStreamPosit ion
    midiStreamPrope rty
    midiStreamResta rt
    midiStreamStop
    >
    Many thanks
    >
    Peter.
    >

    Comment

    • Phone Box

      #3
      Re: MCI stubs


      "Phone Box" <peter_goddard_ I_Dont_Like_Spa m@ntlworld.comw rote in message
      news:crGqi.9491 $h11.6749@newsf e7-gui.ntli.net...
      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("winm m.dll")]
      private static extern long mciSendString(s tring strCommand,Stri ngBuilder
      strReturn,int iReturnLength, IntPtr hwndCallback);
      [DllImport("Winm m.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
      midiInGetDevCap s
      midiInGetErrorT ext
      midiInGetID
      midiInGetNumDev s
      midiInMessage
      midiInOpen
      midiInPrepareHe ader
      MidiInProc
      midiInReset
      midiInStart
      midiInStop
      midiInUnprepare Header
      midiOutCacheDru mPatches
      midiOutCachePat ches
      midiOutClose
      midiOutGetDevCa ps
      midiOutGetError Text
      midiOutGetID
      midiOutGetNumDe vs
      midiOutGetVolum e
      midiOutLongMsg
      midiOutMessage
      midiOutOpen
      midiOutPrepareH eader
      MidiOutProc
      midiOutReset
      midiOutSetVolum e
      midiOutShortMsg
      midiOutUnprepar eHeader
      midiStreamClose
      midiStreamOpen
      midiStreamOut
      midiStreamPause
      midiStreamPosit ion
      midiStreamPrope rty
      midiStreamResta rt
      midiStreamStop
      >
      Many thanks
      >
      Peter.
      >
      Hi,
      So far the following works...

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

      namespace AlesisSR16
      {
      public class MciClass
      {
      [DllImport("Winm m.dll")]
      static extern uint midiInGetNumDev s();

      public static uint MCI_midiInGetNu mDevs()
      {
      return midiInGetNumDev s();
      }
      }
      }

      // Activated in an aboutbox handler
      private void AboutBoxSR16_Ac tivated(object sender, EventArgs e)
      {
      uint a = MciClass.MCI_mi diInGetNumDevs( );
      this.textBoxDes cription.Text = a.ToString();
      }

      Cheers

      Peter.


      Comment

      Working...