dim
inputBuffer(1 To 13) As Byte
dim outputBuffer(1 To 10) As Byte
dim midiCmd as byte
dim velocity as byte Sub
main()
call delay(0.5) ' start program with a half-second delay
dim noteVar as byte
' set up serial buffers:
call openQueue(inputBuffer, 13)
call openQueue(outputBuffer, 10)
' open serial port on COM1:
call openCom(1, 9600, inputBuffer,
outputBuffer)
' set baud rate to 30,270:
' this syntax makes the bx fix the UART baud rate to
30,270 from 9600
' so number 14 is specific number for changing number
register.ubrr = 14
' instead of this syntax I can use the syntax that
' call openCom(1, 30270, inputBuffer,
outputBuffer)
do
' get a note range from 36 to 96
' using a 10K variable resistor as input on pin 13:
noteVar = cByte((getADC(13) mod 60) + 36)
debug.print "noteVar = " ; cstr(noteVar)
' when I want to see noteVar on the midi, I should delete
this line,
'because midi also use a same port, COM1, like basic
x
' sent a noteon message, channel 1, velocity 64:
midiCmd = 144
velocity = 64
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, noteVar, 1)
call putQueue(OutputBuffer, velocity, 1)
call delay(0.5)
' noteon to the same note, velocity 0
' (essentially noteoff):
midiCmd = 144
velocity = 0
call putQueue(OutputBuffer, midiCmd, 1)
call putQueue(OutputBuffer, noteVar, 1)
call putQueue(OutputBuffer, velocity, 1)
call delay(0.5)
loop
end
sub
|