using System; using System.Runtime.InteropServices; namespace DMX2 { public static partial 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_QUERY_SUBS_WRITE = 1; 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_client_type_t : int { SND_SEQ_USER_CLIENT = 1, SND_SEQ_KERNEL_CLIENT = 2 } 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; [FieldOffset(16)] public snd_seq_addr_t data_addr; } static int _clientInfoSize; static int _portInfoSize; static int _subscriberInfoSize; static int _query_subscribeInfoSize; 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; } static int GetQuerySubscribeInfoSize () { if (_query_subscribeInfoSize == 0) { _query_subscribeInfoSize = Invoke.snd_seq_query_subscribe_sizeof (); } return _query_subscribeInfoSize; } } }