def save_preset(self):
file = asksaveasfile(filetypes=[("Synth presets", "*.ini")])
cf = ConfigParser(dict_type=collections.OrderedDict)
# general settings
cf.add_section("settings")
cf["settings"]["samplerate"] = str(self.samplerate_choice.get())
cf["settings"]["rendering"] = self.rendering_choice.get()
cf["settings"]["to_speaker"] = ",".join(str(v+1) for v in self.to_speaker_lb.curselection())
cf["settings"]["a4tuning"] = str(self.a4_choice.get())
# oscillators
for num, osc in enumerate(self.oscillators, 1):
section = "oscillator_"+str(num)
cf.add_section(section)
for name, var in vars(osc).items():
if name.startswith("input_"):
cf[section][name] = str(var.get())
# adsr envelopes
for num, filter in enumerate(self.envelope_filters, 1):
section = "envelope_"+str(num)
cf.add_section(section)
for name, var in vars(filter).items():
if name.startswith("input_"):
cf[section][name] = str(var.get())
# echo
cf.add_section("echo")
for name, var in vars(self.echo_filter).items():
if name.startswith("input_"):
cf["echo"][name] = str(var.get())
# tremolo
cf.add_section("tremolo")
for name, var in vars(self.tremolo_filter).items():
if name.startswith("input_"):
cf["tremolo"][name] = str(var.get())
# arpeggio
cf.add_section("arpeggio")
for name, var in vars(self.arp_filter).items():
if name.startswith("input_"):
cf["arpeggio"][name] = str(var.get())
cf.write(file)
file.close()
评论列表
文章目录