-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstemsep.lua
More file actions
207 lines (141 loc) · 5.41 KB
/
stemsep.lua
File metadata and controls
207 lines (141 loc) · 5.41 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
local sel = Editor:get_selection()
local count = 0
local midi_region
for r in sel.regions:regionlist():iter() do
count = count + 1
if r:to_audioregion():isnil() then
local md = LuaDialog.Message("Stem Separation", "The selected region is not an audio region", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close)
print(md:run())
md = nil
collectgarbage()
return
else
audio_region = r
end
end
if count ~= 1 then
local md = LuaDialog.Message("Stem Separation", "Please select exactly 1 audio region", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close)
print(md:run())
md = nil
collectgarbage()
return
end
local dialog_options = {
{ type = "checkbox", key = "Drums", default = true, title = "Drums" },
{ type = "checkbox", key = "Vocals", default = true, title = "Vocals" },
{ type = "checkbox", key = "Bass", default = true, title = "Bass" },
{ type = "checkbox", key = "Other", default = true, title = "Other" },
}
-- Display the dialog
local od = LuaDialog.Dialog("Select Options", dialog_options)
local rv = od:run()
-- Cleanup the dialog
collectgarbage ()
local rn = audio_region:name()
local source = audio_region:source(0):to_filesource():path()
print(source)
local filepath = source
local quotedfilepath = '"' .. filepath .. '"'
-- Example usage:
local filename = quotedfilepath
rename = "cp "..quotedfilepath.." /home/justin/demucs/input/sep.wav"
command = 'xterm -e "/home/justin/demucs/run.sh sep.wav"'
-- Open the file "mscore.sh" for writing
local file = io.open("rename.sh", "w")
if not file then
-- Handle error if file couldn't be opened
print("Error: Failed to create file 'mscore.sh'")
else
-- Write the command content to the file
file:write(rename .. "\n") -- Write the command to the file
-- Close the file
file:close()
print("File 'mscore.sh' created successfully!")
-- Delete the file after printing the success message
end
local mv = "mv rename.sh /tmp/rename.sh"
os.execute(mv)
chmod = "chmod +x rename.sh"
os.execute(chmod)
os.forkexec("/bin/bash", "/tmp/rename.sh")
os.execute(command)
-- Check if the dialog was confirmed
if rv then
-- For each option, execute code if the checkbox is selected
if rv.Drums then
-- Code to execute if Drums is selected
local files = C.StringVector()
print("Drums selected")
files:push_back("/home/justin/demucs/output/htdemucs/sep/drums.wav")
local pos = Temporal.timepos_t(0)
-- Replace ARDOUR.MidiTrackNameSource.SMFFileAndTrackName and other constants with known integer values if they return nil
Editor:do_import(files,
Editing.ImportDistinctFiles, -- Mode
Editing.ImportAsTrack, -- Import as Track
ARDOUR.SrcQuality.SrcBest, -- Best source quality
0, -- Replace with actual integer if needed
0, -- Replace with actual integer if needed
pos,
ARDOUR.PluginInfo(),
ARDOUR.Track(),
false
)
end
if rv.Vocals then
-- Code to execute if Vocals is selected
print("Vocals selected")
local files = C.StringVector()
files:push_back("/home/justin/demucs/output/htdemucs/sep/vocals.wav")
local pos = Temporal.timepos_t(0)
-- Replace ARDOUR.MidiTrackNameSource.SMFFileAndTrackName and other constants with known integer values if they return nil
Editor:do_import(files,
Editing.ImportDistinctFiles, -- Mode
Editing.ImportAsTrack, -- Import as Track
ARDOUR.SrcQuality.SrcBest, -- Best source quality
0, -- Replace with actual integer if needed
0, -- Replace with actual integer if needed
pos,
ARDOUR.PluginInfo(),
ARDOUR.Track(),
false
)
end
if rv.Bass then
local files = C.StringVector()
-- Code to execute if Bass is selected
print("Bass selected")
files:push_back("/home/justin/demucs/output/htdemucs/sep/bass.wav")
local pos = Temporal.timepos_t(0)
-- Replace ARDOUR.MidiTrackNameSource.SMFFileAndTrackName and other constants with known integer values if they return nil
Editor:do_import(files,
Editing.ImportDistinctFiles, -- Mode
Editing.ImportAsTrack, -- Import as Track
ARDOUR.SrcQuality.SrcBest, -- Best source quality
0, -- Replace with actual integer if needed
0, -- Replace with actual integer if needed
pos,
ARDOUR.PluginInfo(),
ARDOUR.Track(),
false
)
end
if rv.Other then
-- Code to execute if Other is selected
local files = C.StringVector()
files:push_back("/home/justin/demucs/output/htdemucs/sep/other.wav")
local pos = Temporal.timepos_t(0)
-- Replace ARDOUR.MidiTrackNameSource.SMFFileAndTrackName and other constants with known integer values if they return nil
Editor:do_import(files,
Editing.ImportDistinctFiles, -- Mode
Editing.ImportAsTrack, -- Import as Track
ARDOUR.SrcQuality.SrcBest, -- Best source quality
0, -- Replace with actual integer if needed
0, -- Replace with actual integer if needed
pos,
ARDOUR.PluginInfo(),
ARDOUR.Track(),
false
)
end
end
collectgarbage()