1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
fcount con 1
timevar var word
scaledval var byte
tempval var word
channel var byte
fdata var byte(fcount)
lastnote var byte(fcount)
midioutpin con 15
midirate con 60
gosub initialize
top:
for channel = 0 to fcount - 1
gosub readFsrSensor
gosub processSensorValue
pause 100
next
goto top
readFsrSensor:
high channel
pause 1
rctime channel, 1, timevar
return
processSensorValue:
gosub scaleTiming
if (scaledval = fdata(channel)) then endProcessTiming
fdata(channel) = scaledval
gosub sendMidiData
endProcessTiming:
return
scaleTiming:
tempval = (65535 - timevar + 1) / 256
if (tempval > 128) then nextline2
tempval = 0;
goto nextline3
nextline2:
tempval = tempval - 128
nextline3:
if (tempval < 128) then nextline
tempval = 127
nextline:
scaledval = tempval
return
initialize:
for channel = 0 to fcount - 1
gosub readFsrSensor
gosub scaleTiming
fdata(channel) = scaledval
lastnote(channel) = 0
next
return
sendMidiData:
if (fdata(channel) = 0) then sendMidiDataEnd
serout midioutpin, midirate, [$90, lastnote(channel), 0]
serout midioutpin, midirate, [$90, fdata(channel), 64]
lastnote(channel) = fdata(channel)
sendMidiDataEnd:
return
|