Differenze tra le versioni di "Conoscere con le funzioni esterne di PortMidi le porte Midi disponibili nel sistema"
Da Gambas-it.org - Wikipedia.
Riga 16: | Riga 16: | ||
Library "libportmidi:0.0.0" | Library "libportmidi:0.0.0" | ||
+ | |||
+ | <FONT color=gray>' ''PmError Pm_Initialize( void )'' | ||
+ | ' ''Library initialisation function.''</font> | ||
+ | Private Extern Pm_Initialize() As Integer | ||
+ | |||
+ | <FONT color=gray>' ''const char *Pm_GetErrorText( PmError errnum )'' | ||
+ | ' ''Translate portmidi error number into human readable message.''</font> | ||
+ | Private Extern Pm_GetErrorText(errnum As Integer) As String | ||
<FONT color=gray>' ''int Pm_CountDevices (void)'' | <FONT color=gray>' ''int Pm_CountDevices (void)'' | ||
Riga 32: | Riga 40: | ||
' ''Return the default device ID or pmNoDevice if there are no devices.''</font> | ' ''Return the default device ID or pmNoDevice if there are no devices.''</font> | ||
Private Extern Pm_GetDefaultInputDeviceID() As Integer | Private Extern Pm_GetDefaultInputDeviceID() As Integer | ||
+ | |||
+ | <FONT color=gray>' ''PmError Pm_Terminate( void )'' | ||
+ | ' ''Library termination function.''</font> | ||
+ | Private Extern Pm_Terminate() As Integer | ||
Riga 73: | Riga 85: | ||
Next | Next | ||
+ | |||
+ | Pm_Terminate() | ||
'''End''' | '''End''' | ||
Riga 80: | Riga 94: | ||
=Riferimenti= | =Riferimenti= | ||
− | + | * http://portmedia.sourceforge.net/ | |
− | + | * http://sourcecodebrowser.com/portmidi/200/index.html | |
− |
Versione delle 18:29, 31 mag 2016
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" ' PmError Pm_Initialize( void ) ' Library initialisation function. Private Extern Pm_Initialize() As Integer ' const char *Pm_GetErrorText( PmError errnum ) ' Translate portmidi error number into human readable message. Private Extern Pm_GetErrorText(errnum As Integer) As String ' 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 ' PmError Pm_Terminate( void ) ' Library termination function. Private Extern Pm_Terminate() 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 Pm_Terminate() End