vamos de nuevo con la... MIDI-mania
Este código intercepta sin funciones externas de Alsa los datos Midi crudos enviados de un dispositivo Midi externo (por ejemplo un teclado Midi) a través del apropiado file-device generado de Alsa.
Private fl As File
Public Sub Main()
Dim disp As String = "/dev/snd"
If Dir(disp, "midi*", gb.Device).Count = 0 Then Error.Raise("Ningún dispositivo MIDI externo encontrado !")
disp &/= Dir(disp, "midi*", gb.Device)[0]
fl = Open disp For Read Watch
End
Public Sub File_Read()
Dim b As Byte
Read #fl, b
Select Case b
Case 128 To 143
b = b And 15
Print "\nCanal", "Nota", "Velocidad", " = NoteOFF"
Case 144 To 159
b = b And 15
Print "\nCanal", "Nota", "Velocidad", " = NoteON"
Case 160 To 175
b = b And 15
Print "\nCanal", "Nota", "Velocidad", " = Aftertouch Polyphonic"
Case 176 To 191
b = b And 15
Print "\nCanal", "Parámetro", "Valor", " = Control Change"
Case 192 To 207
b = b And 15
Print "\nCanal", "parámetro", Null, " = Program Change"
Case 208 To 223
b = b And 15
Print "\nCanal", "Parámetro", Null, " = Channel Aftertouch"
Case 224 To 239
b = b And 15
Print "\nCanal", "Parámetro", "Valor", " = Pitch Wheel"
Case 240 To 255
Return
End Select
Print b,
End
Public Sub Main()
Dim disp As String = "/dev/snd"
If Dir(disp, "midi*", gb.Device).Count = 0 Then Error.Raise("Ningún dispositivo MIDI externo encontrado !")
disp &/= Dir(disp, "midi*", gb.Device)[0]
fl = Open disp For Read Watch
End
Public Sub File_Read()
Dim b As Byte
Read #fl, b
Select Case b
Case 128 To 143
b = b And 15
Print "\nCanal", "Nota", "Velocidad", " = NoteOFF"
Case 144 To 159
b = b And 15
Print "\nCanal", "Nota", "Velocidad", " = NoteON"
Case 160 To 175
b = b And 15
Print "\nCanal", "Nota", "Velocidad", " = Aftertouch Polyphonic"
Case 176 To 191
b = b And 15
Print "\nCanal", "Parámetro", "Valor", " = Control Change"
Case 192 To 207
b = b And 15
Print "\nCanal", "parámetro", Null, " = Program Change"
Case 208 To 223
b = b And 15
Print "\nCanal", "Parámetro", Null, " = Channel Aftertouch"
Case 224 To 239
b = b And 15
Print "\nCanal", "Parámetro", "Valor", " = Pitch Wheel"
Case 240 To 255
Return
End Select
Print b,
End