Skip to content

Commit

Permalink
Implemented custom parameters option
Browse files Browse the repository at this point in the history
  • Loading branch information
DilanBoskan committed Jan 14, 2021
1 parent aa5bd68 commit 12deede
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions VocalRemover.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
'modelStackedLabel': '',
'aiModel': 'v4',
'resType': 'Kaiser Fast',
'manType': False,

'useModel': 'instrumental',
'lastDir': None,
Expand Down Expand Up @@ -247,7 +248,7 @@ class MainWindow(TkinterDnD.Tk):
PROGRESS_HEIGHT = 26
PADDING = 10

COL1_ROWS = 9
COL1_ROWS = 9.5
COL2_ROWS = 8.1
COL3_ROWS = 5.5

Expand Down Expand Up @@ -306,6 +307,7 @@ def __init__(self):
self.hopValue_var = tk.StringVar(value=data['hop_length'])
self.winSize_var = tk.StringVar(value=data['window_size'])
self.nfft_var = tk.StringVar(value=data['n_fft'])
self.manType_var = tk.BooleanVar(value=data['manType'])
# AI model
self.aiModel_var = tk.StringVar(value=data['aiModel'])
self.resType_var = tk.StringVar(value=data['resType'])
Expand Down Expand Up @@ -468,6 +470,11 @@ def fill_options_Frame(self):
text='Model Test Mode',
variable=self.modelFolder_var,
)
# Manual Constants
self.options_manType_Checkbutton = ttk.Checkbutton(master=self.options_Frame,
text='Custom parameters',
variable=self.manType_var,
)
# -Column 2-
# SR
self.options_sr_Entry = ttk.Entry(master=self.options_Frame,
Expand Down Expand Up @@ -550,6 +557,9 @@ def fill_options_Frame(self):
# Model Folder
self.options_modelFolder_Checkbutton.place(x=0, y=0, width=0, height=0,
relx=0, rely=7/self.COL1_ROWS, relwidth=1/3, relheight=1/self.COL1_ROWS)
# Manual Constants
self.options_manType_Checkbutton.place(x=0, y=0, width=0, height=0,
relx=0, rely=8/self.COL1_ROWS, relwidth=1/3, relheight=1/self.COL1_ROWS)
# -Column 2-
# SR
self.options_sr_Label.place(x=5, y=4, width=5, height=-8,
Expand Down Expand Up @@ -605,6 +615,8 @@ def fill_options_Frame(self):
lambda *args: self.decode_modelNames())
self.stackedModel_var.trace_add('write',
lambda *args: self.decode_modelNames())
self.manType_var.trace_add('write',
lambda *args: self.decode_modelNames())
# Model deselect
self.aiModel_var.trace_add('write',
lambda *args: self.deselect_models())
Expand Down Expand Up @@ -776,27 +788,30 @@ def decode_modelNames(self):

# Loop through each constant (key) and its widgets
for key, (widget, var) in widgetsVars.items():
if stacked_selectable:
if self.manType_var.get():
if str(widget.cget('state')) != 'normal':
# Manual typing and widget not enabled
widget.configure(state=tk.NORMAL)
continue
elif stacked_selectable:
if instrumental_selectable:
if (key in instrumental.keys() and
key in stacked.keys()):
# Both models have set constants
widget.configure(state=tk.DISABLED)
var.set('%d/%d' % (instrumental[key], stacked[key]))
continue
else:
if key in stacked.keys():
# Only stacked selectable
widget.configure(state=tk.DISABLED)
var.set(stacked[key])
continue
else:
# Stacked model can not be selected
if (key in instrumental.keys() and
instrumental_selectable):
elif key in stacked.keys():
# Only stacked selectable
widget.configure(state=tk.DISABLED)
var.set(instrumental[key])
var.set(stacked[key])
continue
elif (key in instrumental.keys() and
instrumental_selectable):
# Stacked model can not be selected
widget.configure(state=tk.DISABLED)
var.set(instrumental[key])
continue

# If widget is already enabled, no need to reset the value
if str(widget.cget('state')) != 'normal':
Expand Down Expand Up @@ -993,6 +1008,7 @@ def save_values(self):
'modelStackedLabel': self.stackedModel_var.get(),
'aiModel': self.aiModel_var.get(),
'resType': self.resType_var.get(),
'manType': self.manType_var.get(),
})

self.destroy()
Expand Down

0 comments on commit 12deede

Please sign in to comment.