Ich habe ein einfaches Programm geschrieben um eine Note per MIDI zu senden. Das klappt auch wunderbar. Der MIDI Kanal ist hier in meinem Beispiel fix auf 1 gestellt. Wie kann ich den hinteren Teil des Binärcodes durch eine Variable ersetzen (die letzten 4 Stellen sind für den MIDI Kanal verantwortlich)?

&B10010000 (Note on auf MIDI Kanal 1)

&B1001xxxx (xxxx= MIDI Kanal)

Meine zweite Frage wäre dann noch wie ich eine Dezimalzahl in eine Binäre konvertieren kann.

Hoffe es kann mir jemand mit einem kurze Beispiel helfen. Habe das jetzt Stunden probiert hinzubekommen.

Hier mein Code:


Noteon = &B10010000
Noteoff = &B10000000
Velo127 = &B01111111
Note = &B00111100

Cls
Cursor Off

Do
Warteaufnote:
Locate 1 , 1
Lcd "Warte auf Note "
Debounce Pind.2 , 0 , Spielenote
Loop

Spielenote:
If Pind.2 = 0 Then
Goto Noteon
Else
Goto Noteoff
End If

Noteon:
Locate 1 , 1
Lcd "Noten Nummer: " ; Note ; " "
Printbin Noteon
Printbin Note
Printbin Velo127
If Pind.2 = 1 Then
Goto Noteoff
End If
Goto Noteon

Noteoff:
Printbin Noteoff
Printbin Note
Printbin Velo127
Goto Warteaufnote

End