Skip to content

Commit ba5ae3c

Browse files
committed
add velocity sensitivity
1 parent 5c2d5a1 commit ba5ae3c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

lib/mx.samples.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ velocities[2]={0,2,3,4,6,7,8,10,11,13,14,15,17,18,19,21,22,23,25,26,27,29,30,31,
1616
velocities[3]={1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,8,8,8,9,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,18,18,19,20,20,21,22,23,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,42,43,44,45,47,48,49,51,52,54,55,57,58,60,62,63,65,66,68,70,72,73,75,77,79,80,82,84,86,88,90,92,94,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127}
1717
velocities[4]={}
1818
for i=1,128 do
19-
table.insert(l.velocities[4],64)
19+
table.insert(velocities[4],64)
2020
end
2121

2222
local function current_time()
@@ -302,10 +302,13 @@ function MxSamples:on(d)
302302
d.is_release=false
303303
end
304304
if d.velocity==nil then
305-
d.velocity=64
305+
d.velocity=72
306+
end
307+
308+
if params:get("mxsamples_scale_velocity")<4 then
309+
-- scale velocity depending on sensitivity
310+
d.velocity=velocities[params:get("mxsamples_scale_velocity")][math.floor(d.velocity+1)]
306311
end
307-
-- scale velocity depending on sensitivity
308-
d.velocity=velocities[params:get("mxsamples_scale_velocity")][math.floor(d.velocity+1)]
309312

310313
d.dynamic=1
311314
if self.instrument[d.name][1].dynamics>1 then
@@ -387,7 +390,9 @@ function MxSamples:on(d)
387390
-- compute amp
388391
-- multiply amp by velocity curve
389392
local amp=params:get("mxsamples_amp")
390-
amp=amp*d.velocity/127
393+
if params:get("mxsamples_scale_velocity")<4 then
394+
amp=amp*d.velocity/127
395+
end
391396

392397
-- update the delay if needed
393398
if clock.get_beat_sec()~=delay_last_clock then

0 commit comments

Comments
 (0)