[Req] Add a Touch cancel button?

M
MarioAR posted Dec 21 '15, 06:33:

Hello. Is it possible to put a hard button to turn on/off the touch sensitivity?
Thanks in advance.

M
MarioAR posted Jan 1 '16, 01:36:

Well, I've done it. The button acts like a switch: the first push disables the touch sensitivity and every note will be taken as a low-speed pulsation. The next push will make SamplerBox to take every note as a mid-speed pulsation, the next push for a high-speed, and the next will enable the touch sensitivity again (then the cycle can be repeated, again and again).
For everyone who also wants this button: edit samplerbox.py

Line 23 (below MAX_POLYPHONY):
TOUCH_CANCEL = [40, 80, 120] # Touch cancel slow, mid, fast speeds

Line 178:
touch_cancel = 0

Line 198 (below global preset)
global touch_cancel

Line 208, replace this:
if messagetype == 9: # Note on
midinote += globaltranspose
try:
playingnotes.setdefault(midinote, []).append(samples[midinote, velocity].play(midinote))
except:
pass
With this:
if messagetype == 9: # Note on
midinote += globaltranspose
if touch_cancel > 0:
velocity = TOUCH_CANCEL[touch_cancel-1]
try:
playingnotes.setdefault(midinote, []).append(samples[midinote, velocity].play(midinote))
except:
pass

Line 389 (below GPIO.setup(17, ....)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)

Line 392 (below global preset, lastbuttontime)
global touch_cancel

Line 408 (below LoadSamples(), leave a space below the line, and one below touch_cancel = 0)
elif not GPIO.input(27) and (now - lastbuttontime) > 0.2:
lastbuttontime = now
touch_cancel += 1
if touch_cancel > 3:
touch_cancel = 0

Conection:

M
MarioAR posted Jan 1 '16, 01:38:

...

  (not published)
  I want to post as guest
 

Post