The following is a very simple midi code example for the Bx24.
'It uses a switch wired to pin 13, and a pot wired to pin 15
'A midi
out circuit is needed (see
toms notes).. the midi out pin is
'wired directly from the TX (pin 1).
'-Jen Lewin
dim outputBuffer(1 To 13)
as byte
dim inputBuffer(1 To 10) as byte
dim Note as byte
dim pitch as byte
dim velocity as byte
dim pot as integer
sub main()
' open the input and output buffers:
call openQueue(outputBuffer, 13)
call openQueue(inputBuffer, 10)
'create a loop that stalls
the program untill
'I switch pin 13 on- this helps me deal with problems
'caused by both programming the bx and sending midi
'from the same pin
do while getpin(13) = 0
call flashme(1)
loop
call openCom(1, 9600, inputBuffer, outputBuffer)
register.ubrr = 14
do
pot = getadc(15) \ 8
'yield a value of 0 to 1023 / 8
note = 144 'midi value
for 'play note'
pitch = cByte(pot) 'get pitch from pot value
velocity = 64 'this can be described a the sustain time for the note
call putQueue(outputBuffer, note, 1)
call putQueue(outputBuffer, pitch, 1)
call putQueue(outputBuffer, velocity, 1)
delay(1.0)
note = 144 'midi value for 'play note'
pitch = cByte(pot) 'get pitch from pot value
velocity = 0 'by playin the SAME note with a 0 velocity, the note is cancelled.
call putQueue(outputBuffer, note, 1)
call putQueue(outputBuffer, pitch, 1)
call putQueue(outputBuffer, velocity, 1)
loop
|