nettoyage ...
preparation d'une libalsa pour simplifier le dev de la suite midi
This commit is contained in:
parent
86bb4c46a0
commit
1381590f28
4 changed files with 442 additions and 267 deletions
413
DMX-2.0/AlsaSeqLib.cs
Normal file
413
DMX-2.0/AlsaSeqLib.cs
Normal file
|
|
@ -0,0 +1,413 @@
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace DMX2
|
||||||
|
{
|
||||||
|
public static class AlsaSeqLib
|
||||||
|
{
|
||||||
|
|
||||||
|
public const int SND_SEQ_NONBLOCK = 1;
|
||||||
|
public const int SND_SEQ_OPEN_INPUT = 1;
|
||||||
|
public const int SND_SEQ_OPEN_OUTPUT = 2;
|
||||||
|
public const int SND_SEQ_OPEN_DUPLEX = 3;
|
||||||
|
public const int SND_SEQ_PORT_CAP_NO_EXPORT = (1 << 7);
|
||||||
|
public const int SND_SEQ_PORT_CAP_READ = (1 << 0);
|
||||||
|
public const int SND_SEQ_PORT_CAP_WRITE = (1 << 1);
|
||||||
|
public const int SND_SEQ_PORT_CAP_DUPLEX = (1 << 4);
|
||||||
|
public const int SND_SEQ_PORT_CAP_SUBS_READ = (1 << 5);
|
||||||
|
public const int SND_SEQ_PORT_CAP_SUBS_WRITE = (1 << 6);
|
||||||
|
public const int SND_SEQ_USER_CLIENT = 1;
|
||||||
|
public const int SND_SEQ_PORT_SYSTEM_TIMER = 0;
|
||||||
|
public const int SND_SEQ_PORT_SYSTEM_ANNOUNCE = 1;
|
||||||
|
public const int SND_SEQ_QUERY_SUBS_READ = 0;
|
||||||
|
public const int SND_SEQ_PORT_TYPE_APPLICATION = (1 << 20);
|
||||||
|
public const byte SND_SEQ_CLIENT_SYSTEM = 0;
|
||||||
|
public const byte SND_SEQ_ADDRESS_UNKNOWN = 253;
|
||||||
|
public const byte SND_SEQ_ADDRESS_SUBSCRIBERS = 254;
|
||||||
|
public const byte SND_SEQ_ADDRESS_BROADCAST = 255;
|
||||||
|
public const byte SND_SEQ_QUEUE_DIRECT = 253;
|
||||||
|
|
||||||
|
public enum snd_seq_event_type_t : byte
|
||||||
|
{
|
||||||
|
SND_SEQ_EVENT_SYSTEM = 0,
|
||||||
|
/** returned result status; event data type = #snd_seq_result_t */
|
||||||
|
SND_SEQ_EVENT_RESULT,
|
||||||
|
|
||||||
|
/** note on and off with duration; event data type = #snd_seq_ev_note_t */
|
||||||
|
SND_SEQ_EVENT_NOTE = 5,
|
||||||
|
/** note on; event data type = #snd_seq_ev_note_t */
|
||||||
|
SND_SEQ_EVENT_NOTEON,
|
||||||
|
/** note off; event data type = #snd_seq_ev_note_t */
|
||||||
|
SND_SEQ_EVENT_NOTEOFF,
|
||||||
|
/** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
|
||||||
|
SND_SEQ_EVENT_KEYPRESS,
|
||||||
|
|
||||||
|
/** controller; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_CONTROLLER = 10,
|
||||||
|
/** program change; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_PGMCHANGE,
|
||||||
|
/** channel pressure; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_CHANPRESS,
|
||||||
|
/** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */
|
||||||
|
SND_SEQ_EVENT_PITCHBEND,
|
||||||
|
/** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_CONTROL14,
|
||||||
|
/** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_NONREGPARAM,
|
||||||
|
/** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_REGPARAM,
|
||||||
|
|
||||||
|
/** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_SONGPOS = 20,
|
||||||
|
/** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_SONGSEL,
|
||||||
|
/** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_QFRAME,
|
||||||
|
/** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_TIMESIGN,
|
||||||
|
/** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
|
||||||
|
SND_SEQ_EVENT_KEYSIGN,
|
||||||
|
/** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_START = 30,
|
||||||
|
/** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_CONTINUE,
|
||||||
|
/** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_STOP,
|
||||||
|
/** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_SETPOS_TICK,
|
||||||
|
/** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_SETPOS_TIME,
|
||||||
|
/** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_TEMPO,
|
||||||
|
/** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_CLOCK,
|
||||||
|
/** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_TICK,
|
||||||
|
/** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_QUEUE_SKEW,
|
||||||
|
/** Sync position changed; event data type = #snd_seq_ev_queue_control_t */
|
||||||
|
SND_SEQ_EVENT_SYNC_POS,
|
||||||
|
|
||||||
|
/** Tune request; event data type = none */
|
||||||
|
SND_SEQ_EVENT_TUNE_REQUEST = 40,
|
||||||
|
/** Reset to power-on state; event data type = none */
|
||||||
|
SND_SEQ_EVENT_RESET,
|
||||||
|
/** Active sensing event; event data type = none */
|
||||||
|
SND_SEQ_EVENT_SENSING,
|
||||||
|
|
||||||
|
/** Echo-back event; event data type = any type */
|
||||||
|
SND_SEQ_EVENT_ECHO = 50,
|
||||||
|
/** OSS emulation raw event; event data type = any type */
|
||||||
|
SND_SEQ_EVENT_OSS,
|
||||||
|
|
||||||
|
/** New client has connected; event data type = #snd_seq_addr_t */
|
||||||
|
SND_SEQ_EVENT_CLIENT_START = 60,
|
||||||
|
/** Client has left the system; event data type = #snd_seq_addr_t */
|
||||||
|
SND_SEQ_EVENT_CLIENT_EXIT,
|
||||||
|
/** Client status/info has changed; event data type = #snd_seq_addr_t */
|
||||||
|
SND_SEQ_EVENT_CLIENT_CHANGE,
|
||||||
|
/** New port was created; event data type = #snd_seq_addr_t */
|
||||||
|
SND_SEQ_EVENT_PORT_START,
|
||||||
|
/** Port was deleted from system; event data type = #snd_seq_addr_t */
|
||||||
|
SND_SEQ_EVENT_PORT_EXIT,
|
||||||
|
/** Port status/info has changed; event data type = #snd_seq_addr_t */
|
||||||
|
SND_SEQ_EVENT_PORT_CHANGE,
|
||||||
|
|
||||||
|
/** Ports connected; event data type = #snd_seq_connect_t */
|
||||||
|
SND_SEQ_EVENT_PORT_SUBSCRIBED,
|
||||||
|
/** Ports disconnected; event data type = #snd_seq_connect_t */
|
||||||
|
SND_SEQ_EVENT_PORT_UNSUBSCRIBED,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR0 = 90,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR1,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR2,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR3,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR4,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR5,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR6,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR7,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR8,
|
||||||
|
/** user-defined event; event data type = any (fixed size) */
|
||||||
|
SND_SEQ_EVENT_USR9,
|
||||||
|
|
||||||
|
/** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */
|
||||||
|
SND_SEQ_EVENT_SYSEX = 130,
|
||||||
|
/** error event; event data type = #snd_seq_ev_ext_t */
|
||||||
|
SND_SEQ_EVENT_BOUNCE,
|
||||||
|
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
||||||
|
SND_SEQ_EVENT_USR_VAR0 = 135,
|
||||||
|
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
||||||
|
SND_SEQ_EVENT_USR_VAR1,
|
||||||
|
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
||||||
|
SND_SEQ_EVENT_USR_VAR2,
|
||||||
|
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
||||||
|
SND_SEQ_EVENT_USR_VAR3,
|
||||||
|
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
||||||
|
SND_SEQ_EVENT_USR_VAR4,
|
||||||
|
|
||||||
|
/** NOP; ignored in any case */
|
||||||
|
SND_SEQ_EVENT_NONE = 255
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct snd_seq_addr_t
|
||||||
|
{
|
||||||
|
public byte client;
|
||||||
|
public byte port;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct snd_seq_ev_ctrl_t
|
||||||
|
{
|
||||||
|
public byte channel;
|
||||||
|
public byte unused1;
|
||||||
|
public byte unused2;
|
||||||
|
public byte unused3;
|
||||||
|
public uint param;
|
||||||
|
public int value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct snd_seq_ev_note_t
|
||||||
|
{
|
||||||
|
public byte channel;
|
||||||
|
public byte note;
|
||||||
|
public byte velocity;
|
||||||
|
public byte off_velocity;
|
||||||
|
public uint duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct snd_seq_connect_t
|
||||||
|
{
|
||||||
|
public snd_seq_addr_t sender;
|
||||||
|
public snd_seq_addr_t dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct snd_seq_result_t
|
||||||
|
{
|
||||||
|
public int eventt;
|
||||||
|
public int result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public const int sizeof_snd_seq_event_t = 24;
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
public struct snd_seq_event_t
|
||||||
|
{
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public snd_seq_event_type_t
|
||||||
|
type;
|
||||||
|
[FieldOffset(1)]
|
||||||
|
public byte
|
||||||
|
flags;
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public byte
|
||||||
|
tag;
|
||||||
|
[FieldOffset(3)]
|
||||||
|
public byte
|
||||||
|
queue;
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public uint
|
||||||
|
time;
|
||||||
|
[FieldOffset(12)]
|
||||||
|
public snd_seq_addr_t
|
||||||
|
source;
|
||||||
|
[FieldOffset(14)]
|
||||||
|
public snd_seq_addr_t
|
||||||
|
dest;
|
||||||
|
[FieldOffset(16)]
|
||||||
|
public snd_seq_ev_ctrl_t
|
||||||
|
data_ev_ctrl;
|
||||||
|
[FieldOffset(16)]
|
||||||
|
public snd_seq_ev_note_t
|
||||||
|
data_ev_note;
|
||||||
|
[FieldOffset(16)]
|
||||||
|
public snd_seq_connect_t
|
||||||
|
data_connect;
|
||||||
|
[FieldOffset(16)]
|
||||||
|
public snd_seq_result_t
|
||||||
|
data_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Invoke
|
||||||
|
{
|
||||||
|
|
||||||
|
const string ASOUND_LIB_NAME = "libasound.so.2";
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_open (out IntPtr handle, string name, int streams, int mode);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_close (IntPtr seq);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_client_id (IntPtr seq);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_set_client_name (IntPtr seq, string name);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_create_simple_port (IntPtr seq, string name, uint caps, uint type);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_event_input (IntPtr seq, out IntPtr ev);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_event_input_pending (IntPtr seq, int fetch_sequencer);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_free_event (IntPtr ev);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_event_output (IntPtr seq, IntPtr ev);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_drain_output (IntPtr seq);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_info_get_client (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_query_next_client (IntPtr seq, IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_client_info_get_client (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_client_info_set_client (IntPtr info, int client);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_port_info_set_client (IntPtr info, int client);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_port_info_set_port (IntPtr info, int val);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_query_next_port (IntPtr seq, IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr snd_seq_client_info_get_name (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_client_info_get_type (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr snd_seq_port_info_get_name (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr snd_seq_get_any_client_info (IntPtr seq, int client, IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr snd_seq_get_any_port_info (IntPtr seq, int client, int port, IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr snd_seq_port_info_get_addr (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_client_info_sizeof ();
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_port_info_sizeof ();
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_port_subscribe_sizeof ();
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_port_info_get_capability (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_port_info_get_type (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_query_subscribe_set_root (IntPtr info, IntPtr addr);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_query_subscribe_set_type (IntPtr info, int type);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_query_subscribe_set_index (IntPtr info, int index);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_query_subscribe_get_index (IntPtr info);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_query_port_subscribers (IntPtr seq, IntPtr subs);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr snd_seq_query_subscribe_get_addr (IntPtr subs);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_port_subscribe_set_sender (IntPtr info, IntPtr addr);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_port_subscribe_set_dest (IntPtr info, IntPtr addr);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_port_subscribe_set_exclusive (IntPtr info, int val);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_port_subscribe_set_time_update (IntPtr info, int val);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snd_seq_port_subscribe_set_time_real (IntPtr info, int val);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_subscribe_port (IntPtr handle, IntPtr sub);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int snd_seq_unsubscribe_port (IntPtr handle, IntPtr sub);
|
||||||
|
|
||||||
|
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr snd_strerror (int errno);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Client
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Port
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _clientInfoSize;
|
||||||
|
static int _portInfoSize;
|
||||||
|
static int _subscriberInfoSize;
|
||||||
|
|
||||||
|
static int GetClientInfoSize ()
|
||||||
|
{
|
||||||
|
if (_clientInfoSize == 0) {
|
||||||
|
_clientInfoSize = Invoke.snd_seq_client_info_sizeof ();
|
||||||
|
}
|
||||||
|
return _clientInfoSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int GetPortInfoSize ()
|
||||||
|
{
|
||||||
|
if (_portInfoSize == 0) {
|
||||||
|
_portInfoSize = Invoke.snd_seq_port_info_sizeof ();
|
||||||
|
}
|
||||||
|
return _portInfoSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int GetSubscriberInfoSize ()
|
||||||
|
{
|
||||||
|
if (_subscriberInfoSize == 0) {
|
||||||
|
_subscriberInfoSize = Invoke.snd_seq_port_subscribe_sizeof ();
|
||||||
|
}
|
||||||
|
return _subscriberInfoSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -158,6 +158,7 @@
|
||||||
<Compile Include="DriverBoitierV3.cs" />
|
<Compile Include="DriverBoitierV3.cs" />
|
||||||
<Compile Include="DriverBoitierV3UI.cs" />
|
<Compile Include="DriverBoitierV3UI.cs" />
|
||||||
<Compile Include="gtk-gui\DMX2.DriverBoitierV3UI.cs" />
|
<Compile Include="gtk-gui\DMX2.DriverBoitierV3UI.cs" />
|
||||||
|
<Compile Include="AlsaSeqLib.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
|
|
|
||||||
|
|
@ -17,252 +17,13 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace DMX2
|
namespace DMX2
|
||||||
{
|
{
|
||||||
public partial class MidiEventProvider
|
public partial class MidiEventProvider
|
||||||
{
|
{
|
||||||
const string ASOUND_LIB_NAME = "libasound.so.2";
|
|
||||||
const int SND_SEQ_NONBLOCK = 1;
|
|
||||||
const int SND_SEQ_OPEN_INPUT = 1;
|
|
||||||
const int SND_SEQ_OPEN_OUTPUT = 2;
|
|
||||||
const int SND_SEQ_OPEN_DUPLEX = 3;
|
|
||||||
const int SND_SEQ_PORT_CAP_NO_EXPORT = (1 << 7);
|
|
||||||
const int SND_SEQ_PORT_CAP_READ = (1 << 0);
|
|
||||||
const int SND_SEQ_PORT_CAP_WRITE = (1 << 1);
|
|
||||||
const int SND_SEQ_PORT_CAP_DUPLEX = (1 << 4);
|
|
||||||
const int SND_SEQ_PORT_CAP_SUBS_READ=(1<<5);
|
|
||||||
const int SND_SEQ_PORT_CAP_SUBS_WRITE = (1<<6);
|
|
||||||
const int SND_SEQ_USER_CLIENT = 1;
|
|
||||||
const int SND_SEQ_PORT_SYSTEM_TIMER = 0;
|
|
||||||
const int SND_SEQ_PORT_SYSTEM_ANNOUNCE = 1;
|
|
||||||
const int SND_SEQ_QUERY_SUBS_READ = 0;
|
|
||||||
const int SND_SEQ_PORT_TYPE_APPLICATION = (1<<20);
|
|
||||||
|
|
||||||
|
|
||||||
enum snd_seq_event_type_t : byte {
|
|
||||||
SND_SEQ_EVENT_SYSTEM = 0,
|
|
||||||
/** returned result status; event data type = #snd_seq_result_t */
|
|
||||||
SND_SEQ_EVENT_RESULT,
|
|
||||||
|
|
||||||
/** note on and off with duration; event data type = #snd_seq_ev_note_t */
|
|
||||||
SND_SEQ_EVENT_NOTE = 5,
|
|
||||||
/** note on; event data type = #snd_seq_ev_note_t */
|
|
||||||
SND_SEQ_EVENT_NOTEON,
|
|
||||||
/** note off; event data type = #snd_seq_ev_note_t */
|
|
||||||
SND_SEQ_EVENT_NOTEOFF,
|
|
||||||
/** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
|
|
||||||
SND_SEQ_EVENT_KEYPRESS,
|
|
||||||
|
|
||||||
/** controller; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_CONTROLLER = 10,
|
|
||||||
/** program change; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_PGMCHANGE,
|
|
||||||
/** channel pressure; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_CHANPRESS,
|
|
||||||
/** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */
|
|
||||||
SND_SEQ_EVENT_PITCHBEND,
|
|
||||||
/** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_CONTROL14,
|
|
||||||
/** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_NONREGPARAM,
|
|
||||||
/** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_REGPARAM,
|
|
||||||
|
|
||||||
/** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_SONGPOS = 20,
|
|
||||||
/** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_SONGSEL,
|
|
||||||
/** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_QFRAME,
|
|
||||||
/** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_TIMESIGN,
|
|
||||||
/** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
|
|
||||||
SND_SEQ_EVENT_KEYSIGN,
|
|
||||||
/** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_START = 30,
|
|
||||||
/** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_CONTINUE,
|
|
||||||
/** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_STOP,
|
|
||||||
/** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_SETPOS_TICK,
|
|
||||||
/** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_SETPOS_TIME,
|
|
||||||
/** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_TEMPO,
|
|
||||||
/** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_CLOCK,
|
|
||||||
/** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_TICK,
|
|
||||||
/** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_QUEUE_SKEW,
|
|
||||||
/** Sync position changed; event data type = #snd_seq_ev_queue_control_t */
|
|
||||||
SND_SEQ_EVENT_SYNC_POS,
|
|
||||||
|
|
||||||
/** Tune request; event data type = none */
|
|
||||||
SND_SEQ_EVENT_TUNE_REQUEST = 40,
|
|
||||||
/** Reset to power-on state; event data type = none */
|
|
||||||
SND_SEQ_EVENT_RESET,
|
|
||||||
/** Active sensing event; event data type = none */
|
|
||||||
SND_SEQ_EVENT_SENSING,
|
|
||||||
|
|
||||||
/** Echo-back event; event data type = any type */
|
|
||||||
SND_SEQ_EVENT_ECHO = 50,
|
|
||||||
/** OSS emulation raw event; event data type = any type */
|
|
||||||
SND_SEQ_EVENT_OSS,
|
|
||||||
|
|
||||||
/** New client has connected; event data type = #snd_seq_addr_t */
|
|
||||||
SND_SEQ_EVENT_CLIENT_START = 60,
|
|
||||||
/** Client has left the system; event data type = #snd_seq_addr_t */
|
|
||||||
SND_SEQ_EVENT_CLIENT_EXIT,
|
|
||||||
/** Client status/info has changed; event data type = #snd_seq_addr_t */
|
|
||||||
SND_SEQ_EVENT_CLIENT_CHANGE,
|
|
||||||
/** New port was created; event data type = #snd_seq_addr_t */
|
|
||||||
SND_SEQ_EVENT_PORT_START,
|
|
||||||
/** Port was deleted from system; event data type = #snd_seq_addr_t */
|
|
||||||
SND_SEQ_EVENT_PORT_EXIT,
|
|
||||||
/** Port status/info has changed; event data type = #snd_seq_addr_t */
|
|
||||||
SND_SEQ_EVENT_PORT_CHANGE,
|
|
||||||
|
|
||||||
/** Ports connected; event data type = #snd_seq_connect_t */
|
|
||||||
SND_SEQ_EVENT_PORT_SUBSCRIBED,
|
|
||||||
/** Ports disconnected; event data type = #snd_seq_connect_t */
|
|
||||||
SND_SEQ_EVENT_PORT_UNSUBSCRIBED,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR0 = 90,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR1,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR2,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR3,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR4,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR5,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR6,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR7,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR8,
|
|
||||||
/** user-defined event; event data type = any (fixed size) */
|
|
||||||
SND_SEQ_EVENT_USR9,
|
|
||||||
|
|
||||||
/** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */
|
|
||||||
SND_SEQ_EVENT_SYSEX = 130,
|
|
||||||
/** error event; event data type = #snd_seq_ev_ext_t */
|
|
||||||
SND_SEQ_EVENT_BOUNCE,
|
|
||||||
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
|
||||||
SND_SEQ_EVENT_USR_VAR0 = 135,
|
|
||||||
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
|
||||||
SND_SEQ_EVENT_USR_VAR1,
|
|
||||||
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
|
||||||
SND_SEQ_EVENT_USR_VAR2,
|
|
||||||
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
|
||||||
SND_SEQ_EVENT_USR_VAR3,
|
|
||||||
/** reserved for user apps; event data type = #snd_seq_ev_ext_t */
|
|
||||||
SND_SEQ_EVENT_USR_VAR4,
|
|
||||||
|
|
||||||
/** NOP; ignored in any case */
|
|
||||||
SND_SEQ_EVENT_NONE = 255
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
struct snd_seq_addr_t {
|
|
||||||
public byte client;
|
|
||||||
public byte port;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
struct snd_seq_ev_ctrl_t {
|
|
||||||
public byte channel;
|
|
||||||
public byte unused1;
|
|
||||||
public byte unused2;
|
|
||||||
public byte unused3;
|
|
||||||
public uint param;
|
|
||||||
public int value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
struct snd_seq_ev_note_t {
|
|
||||||
public byte channel;
|
|
||||||
public byte note;
|
|
||||||
public byte velocity;
|
|
||||||
public byte off_velocity;
|
|
||||||
public uint duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
struct snd_seq_connect_t {
|
|
||||||
public snd_seq_addr_t sender;
|
|
||||||
public snd_seq_addr_t dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
struct snd_seq_result_t {
|
|
||||||
public int eventt;
|
|
||||||
public int result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int sizeof_snd_seq_event_t = 24;
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
|
||||||
struct snd_seq_event_t {
|
|
||||||
[FieldOffset(0)]
|
|
||||||
public snd_seq_event_type_t type;
|
|
||||||
[FieldOffset(1)]
|
|
||||||
public byte flags;
|
|
||||||
[FieldOffset(2)]
|
|
||||||
public byte tag;
|
|
||||||
[FieldOffset(3)]
|
|
||||||
public byte queue;
|
|
||||||
[FieldOffset(4)]
|
|
||||||
public uint time;
|
|
||||||
[FieldOffset(12)]
|
|
||||||
public snd_seq_addr_t source;
|
|
||||||
[FieldOffset(14)]
|
|
||||||
public snd_seq_addr_t dest;
|
|
||||||
[FieldOffset(16)]
|
|
||||||
public snd_seq_ev_ctrl_t data_ev_ctrl;
|
|
||||||
[FieldOffset(16)]
|
|
||||||
public snd_seq_ev_note_t data_ev_note;
|
|
||||||
[FieldOffset(16)]
|
|
||||||
public snd_seq_connect_t data_connect;
|
|
||||||
[FieldOffset(16)]
|
|
||||||
public snd_seq_result_t data_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_open (out IntPtr handle, string name, int streams, int mode);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_close (IntPtr seq);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_set_client_name (IntPtr seq, string name);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_create_simple_port (IntPtr seq, string name, uint caps, uint type);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_event_input (IntPtr seq, out IntPtr ev);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_event_input_pending (IntPtr seq, int fetch_sequencer);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_free_event(IntPtr ev);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_event_output (IntPtr seq, IntPtr ev);
|
|
||||||
|
|
||||||
[DllImport(ASOUND_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern int snd_seq_drain_output (IntPtr seq);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,21 +54,21 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MidiSeqHandle(){
|
MidiSeqHandle(){
|
||||||
snd_seq_open(out midi_seq_handle, "default",SND_SEQ_OPEN_DUPLEX,0);
|
AlsaSeqLib.Invoke.snd_seq_open(out midi_seq_handle, "default",AlsaSeqLib.SND_SEQ_OPEN_DUPLEX,0);
|
||||||
snd_seq_set_client_name(midi_seq_handle,"DMX2");
|
AlsaSeqLib.Invoke.snd_seq_set_client_name(midi_seq_handle,"DMX2");
|
||||||
inport= snd_seq_create_simple_port(midi_seq_handle,"dmx_ctrl_in",
|
inport= AlsaSeqLib.Invoke.snd_seq_create_simple_port(midi_seq_handle,"dmx_ctrl_in",
|
||||||
SND_SEQ_PORT_CAP_WRITE + SND_SEQ_PORT_CAP_SUBS_WRITE,
|
AlsaSeqLib.SND_SEQ_PORT_CAP_WRITE + AlsaSeqLib.SND_SEQ_PORT_CAP_SUBS_WRITE,
|
||||||
SND_SEQ_PORT_TYPE_APPLICATION);
|
AlsaSeqLib.SND_SEQ_PORT_TYPE_APPLICATION);
|
||||||
outport= snd_seq_create_simple_port(midi_seq_handle,"dmx_ctrl_out",
|
outport= AlsaSeqLib.Invoke.snd_seq_create_simple_port(midi_seq_handle,"dmx_ctrl_out",
|
||||||
SND_SEQ_PORT_CAP_READ + SND_SEQ_PORT_CAP_SUBS_READ,
|
AlsaSeqLib.SND_SEQ_PORT_CAP_READ + AlsaSeqLib.SND_SEQ_PORT_CAP_SUBS_READ,
|
||||||
SND_SEQ_PORT_TYPE_APPLICATION);
|
AlsaSeqLib.SND_SEQ_PORT_TYPE_APPLICATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IDisposable implementation
|
#region IDisposable implementation
|
||||||
void IDisposable.Dispose ()
|
void IDisposable.Dispose ()
|
||||||
{
|
{
|
||||||
if(midi_seq_handle != IntPtr.Zero)
|
if(midi_seq_handle != IntPtr.Zero)
|
||||||
snd_seq_close(midi_seq_handle);
|
AlsaSeqLib.Invoke.snd_seq_close(midi_seq_handle);
|
||||||
midi_seq_handle = IntPtr.Zero;
|
midi_seq_handle = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -92,13 +92,13 @@ namespace DMX2
|
||||||
class feedbackinfo : IFeedbackInfo {
|
class feedbackinfo : IFeedbackInfo {
|
||||||
|
|
||||||
MidiEventProvider prov;
|
MidiEventProvider prov;
|
||||||
snd_seq_event_t ev;
|
AlsaSeqLib.snd_seq_event_t ev;
|
||||||
|
|
||||||
public feedbackinfo(MidiEventProvider _prov, byte channel,uint param){
|
public feedbackinfo(MidiEventProvider _prov, byte channel,uint param){
|
||||||
ev = new snd_seq_event_t(); prov=_prov;
|
ev = new AlsaSeqLib.snd_seq_event_t(); prov=_prov;
|
||||||
ev.data_ev_ctrl.channel = channel;
|
ev.data_ev_ctrl.channel = channel;
|
||||||
ev.data_ev_ctrl.param= param;
|
ev.data_ev_ctrl.param= param;
|
||||||
ev.type = snd_seq_event_type_t.SND_SEQ_EVENT_CONTROLLER;
|
ev.type = AlsaSeqLib.snd_seq_event_type_t.SND_SEQ_EVENT_CONTROLLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IFeedbackInfo implementation
|
#region IFeedbackInfo implementation
|
||||||
|
|
@ -146,15 +146,15 @@ namespace DMX2
|
||||||
|
|
||||||
PointerWrapper evPtr = new PointerWrapper(32);
|
PointerWrapper evPtr = new PointerWrapper(32);
|
||||||
|
|
||||||
void SendEvent (snd_seq_event_t ev)
|
void SendEvent (AlsaSeqLib.snd_seq_event_t ev)
|
||||||
{
|
{
|
||||||
ev.queue = 253;
|
ev.queue = AlsaSeqLib.SND_SEQ_QUEUE_DIRECT;
|
||||||
ev.source.port = (byte) MidiSeqHandle.OutPort;
|
ev.source.port = (byte) MidiSeqHandle.OutPort;
|
||||||
ev.dest.client=254;
|
ev.dest.client=AlsaSeqLib.SND_SEQ_ADDRESS_SUBSCRIBERS;
|
||||||
ev.dest.port= 0;
|
ev.dest.port= AlsaSeqLib.SND_SEQ_ADDRESS_UNKNOWN;
|
||||||
Marshal.StructureToPtr(ev,evPtr.Pointer,false);
|
Marshal.StructureToPtr(ev,evPtr.Pointer,false);
|
||||||
snd_seq_event_output(MidiSeqHandle.Handle,evPtr.Pointer);
|
AlsaSeqLib.Invoke.snd_seq_event_output(MidiSeqHandle.Handle,evPtr.Pointer);
|
||||||
snd_seq_drain_output(MidiSeqHandle.Handle);
|
AlsaSeqLib.Invoke.snd_seq_drain_output(MidiSeqHandle.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string,internalEvent> eventlist = new Dictionary<string, internalEvent>();
|
Dictionary<string,internalEvent> eventlist = new Dictionary<string, internalEvent>();
|
||||||
|
|
@ -223,34 +223,34 @@ namespace DMX2
|
||||||
IntPtr evPtr; // Pointeur vers la structure non managée alsa-seq
|
IntPtr evPtr; // Pointeur vers la structure non managée alsa-seq
|
||||||
|
|
||||||
// Tant qu'il y des evenements midi en attente
|
// Tant qu'il y des evenements midi en attente
|
||||||
while ((snd_seq_event_input_pending(MidiSeqHandle.Handle,1))>0) {
|
while ((AlsaSeqLib.Invoke.snd_seq_event_input_pending(MidiSeqHandle.Handle,1))>0) {
|
||||||
snd_seq_event_input(MidiSeqHandle.Handle, out evPtr); // Recup du pointeur vers l'ev
|
AlsaSeqLib.Invoke.snd_seq_event_input(MidiSeqHandle.Handle, out evPtr); // Recup du pointeur vers l'ev
|
||||||
snd_seq_event_t evS =(snd_seq_event_t) Marshal.PtrToStructure(evPtr,typeof(snd_seq_event_t)); // Copie de la zone mémoire dans une structure managee
|
AlsaSeqLib.snd_seq_event_t evS =(AlsaSeqLib.snd_seq_event_t) Marshal.PtrToStructure(evPtr,typeof(AlsaSeqLib.snd_seq_event_t)); // Copie de la zone mémoire dans une structure managee
|
||||||
snd_seq_free_event(evPtr); // liberation du pointeur
|
AlsaSeqLib.Invoke.snd_seq_free_event(evPtr); // liberation du pointeur
|
||||||
|
|
||||||
string id=null, description=null; int value=0;
|
string id=null, description=null; int value=0;
|
||||||
|
|
||||||
switch (evS.type) {
|
switch (evS.type) {
|
||||||
case snd_seq_event_type_t.SND_SEQ_EVENT_PORT_SUBSCRIBED: // Connection d'un périph midi
|
case AlsaSeqLib.snd_seq_event_type_t.SND_SEQ_EVENT_PORT_SUBSCRIBED: // Connection d'un périph midi
|
||||||
connected = true;
|
connected = true;
|
||||||
continue;
|
continue;
|
||||||
case snd_seq_event_type_t.SND_SEQ_EVENT_CONTROLLER:
|
case AlsaSeqLib.snd_seq_event_type_t.SND_SEQ_EVENT_CONTROLLER:
|
||||||
id= string.Format("MIDI-CTRL-C{0}P{1}",evS.data_ev_ctrl.channel,evS.data_ev_ctrl.param);
|
id= string.Format("MIDI-CTRL-C{0}P{1}",evS.data_ev_ctrl.channel,evS.data_ev_ctrl.param);
|
||||||
description = string.Format("Controller Ch {0} Param {1}",evS.data_ev_ctrl.channel,evS.data_ev_ctrl.param);
|
description = string.Format("Controller Ch {0} Param {1}",evS.data_ev_ctrl.channel,evS.data_ev_ctrl.param);
|
||||||
value = 255 * evS.data_ev_ctrl.value / 127; // Conversion {0,127} => {0,255}
|
value = 255 * evS.data_ev_ctrl.value / 127; // Conversion {0,127} => {0,255}
|
||||||
break;
|
break;
|
||||||
case snd_seq_event_type_t.SND_SEQ_EVENT_NOTEON:
|
case AlsaSeqLib.snd_seq_event_type_t.SND_SEQ_EVENT_NOTEON:
|
||||||
id= string.Format("MIDI-NOTE-C{0}N{1}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
id= string.Format("MIDI-NOTE-C{0}N{1}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
||||||
description = string.Format("Note {1} Ch {0}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
description = string.Format("Note {1} Ch {0}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
||||||
value = 255 ;
|
value = 255 ;
|
||||||
break;
|
break;
|
||||||
case snd_seq_event_type_t.SND_SEQ_EVENT_NOTEOFF:
|
case AlsaSeqLib.snd_seq_event_type_t.SND_SEQ_EVENT_NOTEOFF:
|
||||||
id= string.Format("MIDI-NOTE-C{0}N{1}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
id= string.Format("MIDI-NOTE-C{0}N{1}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
||||||
description = string.Format("Note {1} Ch {0}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
description = string.Format("Note {1} Ch {0}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
||||||
value = 0;
|
value = 0;
|
||||||
break;
|
break;
|
||||||
case snd_seq_event_type_t.SND_SEQ_EVENT_CLOCK:
|
case AlsaSeqLib.snd_seq_event_type_t.SND_SEQ_EVENT_CLOCK:
|
||||||
case snd_seq_event_type_t.SND_SEQ_EVENT_SENSING:
|
case AlsaSeqLib.snd_seq_event_type_t.SND_SEQ_EVENT_SENSING:
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//TODO : Regarder si d'autres controles interessants.
|
//TODO : Regarder si d'autres controles interessants.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue