Tuesday, March 07, 2006

w_7_midi_code from Michael

'****************************************************************
'* Name : midi.BAS *
'* Author : Michael Luck Schneider *
'* Notice : Copyright (c) 2006 Michael Luck Schneider *
'* : All Rights Reserved *
'* Date : 2/28/2006 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
define OSC 20 'midi needs a 20 mhz clock

txPin var portc.6
LED var portd.0
Sw1 var portb.7

output led
output txpin
input sw1

x var byte
lastSw1 var byte


for x = 0 to 6
high led
pause 100
low led
pause 200
next

lastsw1 = sw1

main:
if sw1 != lastsw1 then 'if there has been a change of state
pause 10 'debounce
if sw1 = 1 then 'see if the button has been pushed
serout2 txpin, 12, [144, 80, 127] 'noteon channel 1, note 80, full volume
else 'or released
serout2 txpin, 12, [144, 80, 0] 'noeton channel 1, note 80, 0 velocity (same as note off)
endif
lastsw1 = sw1 'for change of state
endif

goto main

0 Comments:

Post a Comment

<< Home