Differenze tra le versioni di "Conoscere con le funzioni esterne di PortMidi le porte Midi disponibili nel sistema"
Da Gambas-it.org - Wikipedia.
Riga 59: | Riga 59: | ||
If info.outputI Then | If info.outputI Then | ||
d = Pm_GetDefaultOutputDeviceID() | d = Pm_GetDefaultOutputDeviceID() | ||
− | If d = i Then predef = " ( | + | If d = i Then predef = "(predefinita)" |
− | Print i; ": "; String@(info.interf); " "; String@(info.name); predef | + | Print i; ": "; String@(info.interf); " "; String@(info.name); " Uscita "; predef <FONT color=gray>' ''Porta in "scrittura" verso di essa !''</font> |
Endif | Endif | ||
Riga 68: | Riga 68: | ||
If info.inputI Then | If info.inputI Then | ||
d = Pm_GetDefaultInputDeviceID() | d = Pm_GetDefaultInputDeviceID() | ||
− | If d = i Then predef = " ( | + | If d = i Then predef = "(predefinita)" |
− | Print i; ": "; String@(info.interf); " "; String@(info.name); predef | + | Print i; ": "; String@(info.interf); " "; String@(info.name); " Entrata "; predef <FONT color=gray>' ''Porta in "lettura" da essa !''</font> |
Endif | Endif | ||
Versione delle 10:54, 24 giu 2014
La libreria PortMidi è una libreria per la gestione in tempo reale dei dati Midi in entrata ed in uscita. Essa fa parte di un assortimento di API e librerie create per la musica e per altri media.
E' possibile con alcune funzioni esterne della libreria PortMidi conoscere i dispositivi e le porte presenti ed attivi in quel momento. Per poter ottenere ciò, è necessario aver installato nel proprio sistema la libreria condivisa: libportmidi.so.0.0.0
Di seguito viene mostrato un esempio per conoscere con le funzioni esterne della libreria PortMidi le porte Midi disponibili nel sistema:
Public Struct PmDeviceInfo structVersion As Integer interf As Pointer name As Pointer inputI As Integer outputI As Integer opened As Integer End Struct Library "libportmidi:0.0.0" ' int Pm_CountDevices (void) ' Get devices count, ids range from 0 to Pm_CountDevices()-1. Private Extern Pm_CountDevices() As Integer ' const PmDeviceInfo* Pm_GetDeviceInfo( PmDeviceID id ) ' Returns a pointer to a PmDeviceInfo structure referring to the device specified by id. Private Extern Pm_GetDeviceInfo(id As Integer) As PmDeviceInfo ' PmDeviceID Pm_GetDefaultOutputDeviceID( void ) ' Return the default device ID or pmNoDevice if there are no devices. Private Extern Pm_GetDefaultOutputDeviceID() As Integer ' PmDeviceID Pm_GetDefaultInputDeviceID( void ) ' Return the default device ID or pmNoDevice if there are no devices. Private Extern Pm_GetDefaultInputDeviceID() As Integer Public Sub Main() Dim num_disp, i, d As Integer Dim info As PmDeviceInfo Dim predef As String num_disp = Pm_CountDevices() If num_disp = 0 Then Print "Nessuna porta Midi presente MIDI !" Return Else Print "\nNum. "; num_disp; " Porte MIDI rilevate:\n" Endif For i = 0 To num_disp - 1 info = Pm_GetDeviceInfo(i) If IsNull(info) Then Error.Raise("Errore alla funzione 'Pm_GetDeviceInfo()' !") predef = Null If info.outputI Then d = Pm_GetDefaultOutputDeviceID() If d = i Then predef = "(predefinita)" Print i; ": "; String@(info.interf); " "; String@(info.name); " Uscita "; predef ' Porta in "scrittura" verso di essa ! Endif info = Pm_GetDeviceInfo(i) If IsNull(info) Then Error.Raise("Errore alla funzione 'Pm_GetDeviceInfo()' !") If info.inputI Then d = Pm_GetDefaultInputDeviceID() If d = i Then predef = "(predefinita)" Print i; ": "; String@(info.interf); " "; String@(info.name); " Entrata "; predef ' Porta in "lettura" da essa ! Endif Next End