Alsa e Gambas: Client e porte in Ricezione
Da Gambas-it.org - Wikipedia.
Versione del 30 ago 2011 alle 08:32 di Vuott (Discussione | contributi)
Per la creazione del nostro Client e delle sue porte e per consentirne il collegamento ad ALSA, nella classe secondaria CAlsa.class richiameremo e porremo sostanzialmente tutte le funzioni, la libreria e le necessarie dichiarazioni di variabili che abbiamo conosciuto nel precedente progetto per l'invio dei dati Midi:
' Gambas class file Export Public handle As Pointer Private id As Integer Private outport As Integer Private inport As Integer Private outq As Integer Public dclient As Byte Public dport As Byte Library "libasound:2" Const SND_SEQ_OPEN_DUPLEX As Integer = 3 ' #define SND_SEQ_PORT_CAP_WRITE (1<<1) Const SND_SEQ_PORT_CAP_WRITE As Integer = 2 ' #define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) Const SND_SEQ_PORT_TYPE_MIDI_GENERIC As Integer = 2 Const SND_SEQ_PORT_TYPE_APPLICATION As Integer = 1048576 ' (1<<20) ' int snd_seq_open(snd_seq_t **seqp, const char * name, Int streams, Int mode); Private Extern snd_seq_open(Pseq As Pointer, name As String, streams As Integer, mode As Integer) As Integer ' int snd_seq_set_client_name(snd_seq_t* seq, const char* name) Private Extern snd_seq_set_client_name(seq As Pointer, name As String) As Integer ' int snd_seq_create_simple_port(snd_seq_t* seq, const char* name, unsigned int caps, unsigned int type) Private Extern snd_seq_create_simple_port(seq As Pointer, name As String, caps As Integer, type As Integer) As Integer ' int snd_seq_client_id(snd_seq_t * seq) Private Extern snd_seq_client_id(seq As Pointer) As Integer ' int snd_seq_alloc_named_queue(snd_seq_t * seq, CONST char * name) Private Extern snd_seq_alloc_named_queue(seq As Pointer, name As String) As Integer Public Sub alsa_open(myname As String) Dim err As Integer err = snd_seq_open(VarPtr(handle), "default", SND_SEQ_OPEN_DUPLEX, 0) printerr("Apertura di Alsa regolare !", err) If err < 0 Then error.RAISE("Errore nell'apertura di ALSA !") snd_seq_set_client_name(handle, myname) id = snd_seq_client_id(handle) Print "Alsa Client-ID ="; id ' per poter leggere la propria porta viene posta con capacità Write, ossia "scrivibile" da parte di ALSA err = snd_seq_create_simple_port(handle, "Seq-Out", SND_SEQ_PORT_CAP_WRITE, SND_SEQ_PORT_TYPE_MIDI_GENERIC + SND_SEQ_PORT_TYPE_APPLICATION) Print "Numero della porta input dell'applicazione-Client ="; err If err < 0 Then error.Raise("Errore nella creazione della porta di Alsa !") inport = err err = snd_seq_alloc_named_queue(handle, "outqueue") printerr("Creating queue", err) If err < 0 Then error.Raise("Error creating out queue") outq = err End
<< Pagina in costruzione >>