1
1
--[[
2
2
Description: Adjust ReaSamplomatic 5000 pitch offset
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
Author: Lokasenna
5
5
Donation: https://paypal.me/Lokasenna
6
6
Changelog:
7
- Add: Actions for the last-touched RS5K (track FX only)
7
+ Fix: Script not reading the MIDI value correctly
8
8
Links:
9
9
Lokasenna's Website http://forum.cockos.com/member.php?u=10417
10
10
About:
50
50
[main] . > Lokasenna_Adjust ReaSamplomatic 5000 pitch offset/Lokasenna_Adjust pitch offset of last-touched ReaSamplomatic 5000 - Up 0.1 semitones.lua
51
51
[main] . > Lokasenna_Adjust ReaSamplomatic 5000 pitch offset/Lokasenna_Adjust pitch offset of last-touched ReaSamplomatic 5000 - Up 0.05 semitones.lua
52
52
[main] . > Lokasenna_Adjust ReaSamplomatic 5000 pitch offset/Lokasenna_Adjust pitch offset of last-touched ReaSamplomatic 5000 - Up 0.5 semitones.lua
53
- [main] . > Lokasenna_Adjust ReaSamplomatic 5000 pitch offset/Lokasenna_Adjust pitch offset of last-touched ReaSamplomatic 5000 - Up 1 semitone.lua
53
+ [main] . > Lokasenna_Adjust ReaSamplomatic 5000 pitch offset/Lokasenna_Adjust pitch offset of last-touched ReaSamplomatic 5000 - Up 1 semitone.lua
54
54
55
55
Donation: https://www.paypal.me/Lokasenna
56
56
]] --
@@ -62,12 +62,17 @@ local MODE_LASTTOUCHED = 2
62
62
local PARAM_NUMBER = 15 -- RS5K's Pitch Offset parameter
63
63
local PARAM_MULTIPLIER = 0.0000625002384186 -- RS5K's internal value == 0.01 semitones
64
64
65
- dm = false
65
+ local dm = false
66
66
67
67
local function dMsg (str )
68
68
if dm then reaper .ShowConsoleMsg (tostring (str ) .. " \n " ) end
69
69
end
70
70
71
+ local action_context = (function ()
72
+ local c = ({reaper .get_action_context ()})
73
+
74
+ return { is_new = c [1 ], fn = c [2 ], sId = c [3 ], cId = c [4 ], mode = c [5 ], res = c [6 ], val = c [7 ] }
75
+ end )()
71
76
72
77
73
78
---- --------------------------------
76
81
77
82
78
83
local function parse_script_name ()
79
-
80
- local script_name = ({reaper .get_action_context ()})[2 ]:match (" ([^/\\ _]+).lua$" )
81
-
82
- dMsg (script_name )
84
+ local script_name = action_context .fn :match (" ([^/\\ _]+).lua$" )
83
85
84
86
local script_mode
85
87
if string.match (script_name , " focused ReaSamplomatic" ) then
@@ -92,7 +94,7 @@ local function parse_script_name()
92
94
dMsg (" no script mode found" )
93
95
return
94
96
end
95
-
97
+
96
98
local dir
97
99
if string.match (script_name , " %- Up" ) then
98
100
dir = 1
@@ -117,10 +119,13 @@ end
117
119
118
120
119
121
local function convert_adjust_amt (adjust_amt )
122
+ local multiplier = adjust_amt * 100 * PARAM_MULTIPLIER
120
123
121
- local new_val , fn , sID , cID , mode , res , val = reaper .get_action_context ()
122
- return adjust_amt * 100 * PARAM_MULTIPLIER * ((mode > 0 and val ~= 0 ) and (math.abs (val ) / val ) or 1 )
123
-
124
+ return multiplier * (
125
+ (action_context .mode > 0 and action_context .val ~= 0 )
126
+ and (math.abs (action_context .val ) / action_context .val )
127
+ or 1
128
+ )
124
129
end
125
130
126
131
143
148
local function is_RS5K (name )
144
149
145
150
name = string.lower (name )
146
- if string.match (name , " reasamplomatic" )
151
+ if string.match (name , " reasamplomatic" )
147
152
or string.match (name , " rs5k" ) then
148
153
return true
149
154
end
@@ -197,9 +202,9 @@ local function adjust_focused(adjust_amt)
197
202
198
203
199
204
if not retval or retval == 0 then
200
-
205
+
201
206
return
202
-
207
+
203
208
-- Track FX
204
209
elseif retval == 1 then
205
210
@@ -239,9 +244,9 @@ local function adjust_lasttouched(adjust_amt)
239
244
local track = reaper .GetTrack ( 0 , tracknumberOut - 1 )
240
245
241
246
if not retval then
242
-
247
+
243
248
return
244
-
249
+
245
250
-- Track FX
246
251
else
247
252
273
278
274
279
local function adjust_selected_tracks (adjust_amt )
275
280
276
- for idx , track in SelectedTracks () do
281
+ for _ , track in SelectedTracks () do
277
282
278
283
for i = 0 , reaper .TrackFX_GetCount (track ) - 1 do
279
284
@@ -300,10 +305,6 @@ local function Main()
300
305
local script_mode , adjust_amt = parse_script_name ()
301
306
if not (script_mode and adjust_amt ) then return end
302
307
303
- -- script_mode, adjust_amt = MODE_ALLSELECTED, 0.01
304
- dMsg (" got mode: " .. tostring (script_mode ))
305
- dMsg (" got amt: " .. tostring (adjust_amt ))
306
-
307
308
adjust_amt = convert_adjust_amt (adjust_amt )
308
309
309
310
if script_mode == MODE_FOCUSED then
@@ -318,4 +319,4 @@ local function Main()
318
319
319
320
end
320
321
321
- Main ()
322
+ Main ()
0 commit comments