-
Notifications
You must be signed in to change notification settings - Fork 0
/
fluid-ampgate.lua
97 lines (83 loc) · 3.79 KB
/
fluid-ampgate.lua
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
local info = debug.getinfo(1,'S');
local script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]
loadfile(script_path .. "lib/reacoma.lua")()
if reacoma.settings.fatal then return end
local exe = reacoma.utils.wrap_quotes(
reacoma.settings.path .. "/fluid-ampgate"
)
local num_selected_items = reaper.CountSelectedMediaItems(0)
if num_selected_items > 0 then
local processor = reacoma.params.archetype.ampgate
reacoma.params.check_params(processor)
local param_names = "rampup,rampdown,onthreshold,offthreshold,minslicelength,minsilencelength,minlengthabove,minlengthbelow,lookback,lookahead,highpassfreq,mute,onsetsonly"
param_values = reacoma.params.parse_params(param_names, processor)
local confirm, user_inputs = reaper.GetUserInputs("Ampgate Parameters", 13, param_names, param_values)
if confirm then
reacoma.params.store_params(processor, param_names, user_inputs)
local params = reacoma.utils.split_comma(user_inputs)
local rampup = params[1]
local rampdown = params[2]
local onthreshold = params[3]
local offthreshold = params[4]
local minslicelength = params[5]
local minsilencelength = params[6]
local minlengthabove = params[7]
local minlengthbelow = params[8]
local lookback = params[9]
local lookahead = params[10]
local highpassfreq = params[11]
local mute = tonumber(params[12])
local onsetsonly = tonumber(params[13])
local data = reacoma.slicing.container
for i=1, num_selected_items do
reacoma.slicing.get_data(i, data)
local cmd = exe ..
" -source " .. reacoma.utils.wrap_quotes(data.full_path[i]) ..
" -indices " .. reacoma.utils.wrap_quotes(data.tmp[i]) ..
" -maxsize " .. math.max(tonumber(minlengthabove) + tonumber(lookback), math.max(tonumber(minlengthbelow),tonumber(lookahead))) ..
" -rampup " .. rampup ..
" -rampdown " .. rampdown ..
" -onthreshold " .. onthreshold ..
" -offthreshold " .. offthreshold ..
" -minslicelength " .. minslicelength ..
" -minsilencelength " .. minsilencelength ..
" -minlengthabove " .. minlengthabove ..
" -minlengthbelow " .. minlengthbelow ..
" -lookback " .. lookback ..
" -lookahead " .. lookahead ..
" -highpassfreq " .. highpassfreq ..
" -numframes " .. data.item_len_samples[i] ..
" -startframe " .. data.take_ofs_samples[i]
table.insert(data.cmd, cmd)
end
for i=1, num_selected_items do
reacoma.utils.cmdline(data.cmd[i])
local raw_data = reacoma.utils.readfile(data.tmp[i])
local channel_split = reacoma.utils.split_line(raw_data)
local onsets = reacoma.utils.split_comma(channel_split[1])
local offsets = reacoma.utils.split_comma(channel_split[2])
local laced = nil
if onsetsonly == 1 then
laced = onsets
mute = 0
else
laced = reacoma.utils.lace_tables(onsets, offsets)
end
-- We reform a string which is comma-separated values
local comma_separated_points = ''
for j=1, #laced do
comma_separated_points = (
comma_separated_points .. laced[j] .. ","
)
end
table.insert(data.slice_points_string, comma_separated_points)
if mute == 1 then
reacoma.slicing.process(i, data, 1)
else
reacoma.slicing.process(i, data)
end
end
reacoma.utils.arrange("reacoma-ampgate")
reacoma.utils.cleanup(data.tmp)
end
end