public static RtMidiApi [] GetAvailableApis() { int enumSize = RtMidi.rtmidi_sizeof_rtmidi_api(); IntPtr ptr = IntPtr.Zero; int size = RtMidi.rtmidi_get_compiled_api(ref ptr); ptr = Marshal.AllocHGlobal(size * enumSize); RtMidi.rtmidi_get_compiled_api(ref ptr); RtMidiApi [] ret = new RtMidiApi [size]; switch (enumSize) { case 1: byte [] bytes = new byte [size]; Marshal.Copy(ptr, bytes, 0, bytes.Length); for (int i = 0; i < bytes.Length; i++) { ret [i] = (RtMidiApi)bytes [i]; } break; case 2: short [] shorts = new short [size]; Marshal.Copy(ptr, shorts, 0, shorts.Length); for (int i = 0; i < shorts.Length; i++) { ret [i] = (RtMidiApi)shorts [i]; } break; case 4: int [] ints = new int [size]; Marshal.Copy(ptr, ints, 0, ints.Length); for (int i = 0; i < ints.Length; i++) { ret [i] = (RtMidiApi)ints [i]; } break; case 8: long [] longs = new long [size]; Marshal.Copy(ptr, longs, 0, longs.Length); for (int i = 0; i < longs.Length; i++) { ret [i] = (RtMidiApi)longs [i]; } break; default: throw new NotSupportedException("sizeof RtMidiApi is unexpected: " + enumSize); } return(ret); }
/// <summary> /// Create a RtMidiOutPtr value, with given and clientName. /// </summary> /// <param name="api">An optional API id can be specified.</param> /// <param name="clientName">An optional client name can be specified. This /// will be used to group the ports that are created by the application.</param> internal static RtMidiOutPtr Create(RtMidiApi api, string clientName) => Is64Bit ? RtMidiC64.Output.Create(api, clientName) : RtMidiC32.Output.Create(api, clientName);
/// <summary> /// Create a RtMidiInPtr value, with given api, clientName and queueSizeLimit. /// </summary> /// <param name="api">An optional API id can be specified.</param> /// <param name="clientName"> /// An optional client name can be specified. This will be used to group the ports that /// are created by the application. /// </param> /// <param name="queueSizeLimit">An optional size of the MIDI input queue can be specified.</param> internal static RtMidiInPtr Create(RtMidiApi api, string clientName, uint queueSizeLimit) => Is64Bit ? RtMidiC64.Input.Create(api, clientName, queueSizeLimit) : RtMidiC32.Input.Create(api, clientName, queueSizeLimit);
static extern internal RtMidiInPtr rtmidi_in_create(RtMidiApi api, string clientName, uint queueSizeLimit);
public RtMidiOutputDevice(RtMidiApi api, string clientName) : base(RtMidi.rtmidi_out_create(api, clientName)) { }
public RtMidiInputDevice(RtMidiApi api, string clientName, int queueSizeLimit = 100) : base(RtMidi.rtmidi_in_create(api, clientName, (uint)queueSizeLimit)) { }
internal static extern IntPtr Create(RtMidiApi api, string clientName);
static extern internal RtMidiOutPtr rtmidi_out_create(RtMidiApi api, string clientName);
public static extern IntPtr rtmidi_in_create(RtMidiApi api, string clientName, uint queueSizeLimit);
internal static extern IntPtr Create(RtMidiApi api, string clientName, uint queueSizeLimit);
public RtMidiOutputDevice(RtMidiApi api, string clientName) : base(RtMidi.rtmidi_out_create (api, clientName)) { }
public RtMidiInputDevice(RtMidiApi api, string clientName, int queueSizeLimit = 100) : base(RtMidi.rtmidi_in_create (api, clientName, (uint) queueSizeLimit)) { }
public static RtMidiApi[] GetAvailableApis() { int enumSize = RtMidi.rtmidi_sizeof_rtmidi_api (); IntPtr ptr = IntPtr.Zero; int size = RtMidi.rtmidi_get_compiled_api (ref ptr); ptr = Marshal.AllocHGlobal (size * enumSize); RtMidi.rtmidi_get_compiled_api (ref ptr); RtMidiApi [] ret = new RtMidiApi [size]; switch (enumSize) { case 1: byte [] bytes = new byte [size]; Marshal.Copy (ptr, bytes, 0, bytes.Length); for (int i = 0; i < bytes.Length; i++) ret [i] = (RtMidiApi) bytes [i]; break; case 2: short [] shorts = new short [size]; Marshal.Copy (ptr, shorts, 0, shorts.Length); for (int i = 0; i < shorts.Length; i++) ret [i] = (RtMidiApi) shorts [i]; break; case 4: int [] ints = new int [size]; Marshal.Copy (ptr, ints, 0, ints.Length); for (int i = 0; i < ints.Length; i++) ret [i] = (RtMidiApi) ints [i]; break; case 8: long [] longs = new long [size]; Marshal.Copy (ptr, longs, 0, longs.Length); for (int i = 0; i < longs.Length; i++) ret [i] = (RtMidiApi) longs [i]; break; default: throw new NotSupportedException ("sizeof RtMidiApi is unexpected: " + enumSize); } return ret; }
internal static extern RtMidiOutPtr rtmidi_out_create(RtMidiApi api, string clientName);
internal static extern RtMidiInPtr rtmidi_in_create(RtMidiApi api, string clientName, uint queueSizeLimit);