def create_editor(self): gui = self.parser.config.gui().upper() if gui == "NONE": return if gui == "TK": sy = self.get_synth() if sy.synth_editor: # print("Synth %s already has an editor" % sy.sid) return else: from llia.gui.tk.tk_synthwindow import TkSynthWindow import llia.gui.tk.tk_factory as factory mw = self.parser.app.main_window() icon_filename = "resources/%s/logo_32.png" % sy.specs["format"] icon = factory.image(icon_filename) group_index = len(mw.group_windows) - 1 notebook = mw.group_windows[-1].notebook swin = TkSynthWindow(notebook, sy) swin.group_index = group_index sy.synth_editor = swin mw[sy.sid] = swin sy.create_subeditors() notebook.add(swin, text=sy.sid, image=icon, compound="top") sy.use_program(0) sy.synth_editor.sync()
def create_editor(self): """ Creates editor for current synth. Editors are not automatically created when the synth is. Does nothing if the synth already has an editor or if GUI is not enabled. """ gui = self.parser.config.gui().upper() if gui == "NONE": return if gui == "TK": sy = self.get_synth() if sy.synth_editor: # print("Synth %s already has an editor" % sy.sid) return else: from llia.gui.tk.tk_synthwindow import TkSynthWindow import llia.gui.tk.tk_factory as factory mw = self.parser.app.main_window() icon_filename = "resources/%s/logo_32.png" % sy.specs["format"] icon = factory.image(icon_filename) group_index = len(mw.group_windows)-1 notebook = mw.group_windows[-1].notebook swin = TkSynthWindow(notebook, sy) swin.group_index = group_index sy.synth_editor = swin mw[sy.sid] = swin sy.create_subeditors() notebook.add(swin, text=sy.sid, image=icon, compound="top") sy.use_program(0) sy.synth_editor.sync()
def _create_compund_tab(self,text,image_filename): try: icon = factory.image(image_filename) f = factory.frame(self.notebook) self.notebook.add(f,text=text,image=icon,compound="top") return f except IOError: msg = "IOError while loaidng image file '%s'" % image_filename print(msg) return self._create_basic_tab(text)
def _create_compund_tab(self,text,image_filename): try: icon = factory.image(image_filename) f = factory.frame(self.notebook) self.notebook.add(f,text=text,image=icon,compound="top") return f except IOError: msg = "IOError while loading image file '%s'" % image_filename print(msg) return self._create_basic_tab(text)
def _init_info_tab(self, master): img = factory.image("resources/Tabs/info.png") frame = factory.frame(master) inner_frame = factory.frame(frame) master.add(frame, text="Info", image=img,compound="top") text_widget = factory.text_widget(inner_frame) text_widget.config(width=120, height=40) vsb = factory.scrollbar(inner_frame, orientation='vertical') vsb.config(command=text_widget.yview) text_widget.config(yscrollcommand=vsb.set, wrap='word',) text_widget.grid(row=0, column=0,sticky="ewns") vsb.grid(row=0, column=1, sticky='ns') inner_frame.grid(row=0, column=0, rowspan=8, columnspan=8, sticky="ewns") self._info_text_widget = text_widget
def accept(self): shelper = self.app.ls_parser.synthhelper if self.is_efx: sy = shelper.add_efx(self.stype) elif self.is_controller: sy = shelper.add_control_synth(self.stype) else: km = self.var_keymode.get() vc = int(self.var_voice_count.get()) sy = shelper.add_synth(self.stype, km, vc) if sy: for param,combo in self._combo_audio_in.items(): busname = combo.get() shelper.assign_audio_input_bus(param,busname,sy.sid) for param,combo in self._combo_audio_out.items(): busname = combo.get() shelper.assign_audio_output_bus(param,busname,sy.sid) for param,combo in self._combo_control_in.items(): busname = combo.get() shelper.assign_control_input_bus(param,busname,sy.sid) for param,combo in self._combo_control_out.items(): busname = combo.get() shelper.assign_control_output_bus(param,busname,sy.sid) for p,bname in self._buffername_map.items(): shelper.assign_buffer(p, bname) mw = self.app.main_window() group = mw.group_windows[-1] swin = TkSynthWindow(group.notebook, sy) grp_index = len(mw.group_windows)-1 icon_filename = "resources/%s/logo_32.png" % sy.specs["format"] icon = factory.image(icon_filename) group.notebook.add(swin, text=sy.sid, image=icon, compound="top") group.deiconify() mw[sy.sid] = swin factory.set_pallet(sy.specs["pallet"]) sy.create_subeditors() swin.group_index = grp_index self.app.main_window().status("Added %s" % sy.sid) sy.use_program(0) else: self.app.main_widnow().warning("Synth could not be added") factory.restore_pallet() self.destroy()
def accept(self): shelper = self.app.ls_parser.synthhelper if self.is_efx: sy = shelper.add_efx(self.stype) elif self.is_controller: sy = shelper.add_control_synth(self.stype) else: km = self.var_keymode.get() vc = int(self.var_voice_count.get()) sy = shelper.add_synth(self.stype, km, vc) if sy: for param, combo in self._combo_audio_in.items(): busname = combo.get() shelper.assign_audio_input_bus(param, busname, sy.sid) for param, combo in self._combo_audio_out.items(): busname = combo.get() shelper.assign_audio_output_bus(param, busname, sy.sid) for param, combo in self._combo_control_in.items(): busname = combo.get() shelper.assign_control_input_bus(param, busname, sy.sid) for param, combo in self._combo_control_out.items(): busname = combo.get() shelper.assign_control_output_bus(param, busname, sy.sid) for p, bname in self._buffername_map.items(): shelper.assign_buffer(p, bname) mw = self.app.main_window() group = mw.group_windows[-1] swin = TkSynthWindow(group.notebook, sy) grp_index = len(mw.group_windows) - 1 icon_filename = "resources/%s/logo_32.png" % sy.specs["format"] icon = factory.image(icon_filename) group.notebook.add(swin, text=sy.sid, image=icon, compound="top") group.deiconify() mw[sy.sid] = swin factory.set_pallet(sy.specs["pallet"]) sy.create_subeditors() swin.group_index = grp_index self.app.main_window().status("Added %s" % sy.sid) sy.use_program(0) else: self.app.main_widnow().warning("Synth could not be added") factory.restore_pallet() self.destroy()
def _init_info_tab(self, master): img = factory.image("resources/Tabs/info.png") frame = factory.frame(master) inner_frame = factory.frame(frame) master.add(frame, text="Info", image=img,compound="top") text_widget = factory.text_widget(inner_frame) text_widget.config(width=90, height=40) vsb = factory.scrollbar(inner_frame, orientation='vertical') vsb.config(command=text_widget.yview) hsb = factory.scrollbar(inner_frame, orientation='horizontal') hsb.config(command=text_widget.xview) text_widget.config(yscrollcommand=vsb.set, xscrollcommand=hsb.set, wrap='word',) text_widget.grid(row=0, column=0, rowspan=8, columnspan=8) vsb.grid(row=0, column=9, rowspan=8, columnspan=1, sticky='ns') hsb.grid(row=9, column=0, rowspan=1, columnspan=8, stick='we') inner_frame.grid(row=0, column=0, rowspan=8, columnspan=8) b_update = factory.button(frame, "Update", command=self.sync_program_tab) b_update.grid(row=9, column=0, sticky='ew', pady=8) b_remove = factory.button(frame, "Remove Synth", command=self.remove_synth) b_remove.grid(row=9, column=1, sticky='ew', pady=8) self._info_text_widget = text_widget
def _init_map2_tab(self, master): img = factory.image("resources/Tabs/map.png") HELP_TOPIC = "parameter-maps" HEIGHT = 8 frame = factory.frame(master) master.add(frame, text="Map2",image=img,compound="top") north = factory.label_frame(frame, "Velocity Maps") center = factory.label_frame(frame, "Aftertouch Maps") south = factory.label_frame(frame, "Keynumber Maps") north.grid(row=0, column=0, sticky="ew", padx=8, pady=8) center.grid(row=1, column=0, sticky="ew", padx=8) south.grid(row=2, column=0, sticky="ew", padx=8, pady=8) def help_callback(): self.app.main_window().display_help(HELP_TOPIC) list_vel_maps = factory.listbox(north, ttip="Active velocity maps") list_vel_maps.config(width=80, height=HEIGHT) self.list_vel_maps = list_vel_maps sb = factory.scrollbar(north, orientation="vertical") sb.config(command=list_vel_maps.yview) list_vel_maps.config(yscrollcommand=sb.set) b_add_vel = factory.add_button(north, ttip="Add velocity map") b_delete_vel = factory.delete_button(north, ttip="Delete velocity map") list_vel_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_vel.grid(row=1, column=0, sticky="ew") b_delete_vel.grid(row=1, column=1, sticky="ew") list_atouch_maps = factory.listbox(center, ttip="Active after touch maps") list_atouch_maps.config(width=80, height=HEIGHT) self.list_atouch_maps = list_atouch_maps sb = factory.scrollbar(center, orientation="vertical") sb.config(command=list_atouch_maps.yview) list_atouch_maps.config(yscrollcommand=sb.set) b_add_atouch = factory.add_button(center, ttip="Add after touch map") b_delete_atouch = factory.delete_button(center, ttip="Delete after touch map") list_atouch_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_atouch.grid(row=1, column=0, sticky="ew") b_delete_atouch.grid(row=1, column=1, sticky="ew") list_keynum_maps = factory.listbox(south, ttip="Active key number maps") list_keynum_maps.config(width=80, height=HEIGHT) self.list_keynum_maps = list_keynum_maps sb = factory.scrollbar(south, orientation="vertical") sb.config(command=list_keynum_maps.yview) list_keynum_maps.config(yscrollcommand=sb.set) b_add_keynum = factory.add_button(south, ttip="Add key number map") b_delete_keynum = factory.delete_button(south, ttip="Delete key number map") b_help = factory.help_button(south, command=help_callback) list_keynum_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_keynum.grid(row=1, column=0, sticky="ew") b_delete_keynum.grid(row=1, column=1, sticky="ew") b_help.grid(row=1, column=7, sticky="ew") def add_map_callback(event): widget = event.widget if widget is b_add_vel: dialog = add_map_dialog(self.synth, "velocity", self.app) elif widget is b_add_atouch: dialog = add_map_dialog(self.synth, "aftertouch", self.app) elif widget is b_add_keynum: dialog = add_map_dialog(self.synth, "keynumber", self.app) else: msg = "Invald widget - Should never see this" raise ValueError(msg) def delete_map_callback(event): widget = event.widget if widget is b_delete_vel: dialog = delete_map_dialog(self, self.synth, "velocity", self.app) elif widget is b_delete_atouch: dialog = delete_map_dialog(self, self.synth, "aftertouch", self.app) elif widget is b_delete_keynum: dialog = delete_map_dialog(self, self.synth, "keynumber", self.app) else: msg = "Invald widget - Should never see this" raise ValueError(msg) b_add_vel.bind("<Button-1>", add_map_callback) b_add_atouch.bind("<Button-1>", add_map_callback) b_add_keynum.bind("<Button-1>", add_map_callback) b_delete_vel.bind("<Button-1>", delete_map_callback) b_delete_atouch.bind("<Button-1>", delete_map_callback) b_delete_keynum.bind("<Button-1>", delete_map_callback)
def _init_map1_tab(self, master): img = factory.image("resources/Tabs/map.png") HELP_TOPIC = "parameter-maps" frame = factory.frame(master) master.add(frame, text="Map1", image=img, compound="top") north = factory.label_frame(frame, "MIDI Controller Maps") south = factory.label_frame(frame, "Pitch Wheel Maps") north.grid(row=0, column=0, sticky="ew", padx=8, pady=8) south.grid(row=1, column=0, sticky="ew", padx=8, pady=8) def help_callback(): self.app.main_window().display_help(HELP_TOPIC) list_cc_maps = factory.listbox(north, ttip="Active MIDI controller maps") list_cc_maps.config(width=80, height=16) self.list_cc_maps = list_cc_maps sb = factory.scrollbar(north, orientation="vertical") sb.config(command=list_cc_maps.yview) list_cc_maps.config(yscrollcommand=sb.set) b_add_cc = factory.add_button(north, ttip="Add new controller map") b_delete_cc = factory.delete_button(north, ttip="Delete controller map") list_cc_maps.grid(row=0, column=0, rowspan=4, columnspan=8, sticky="ew") sb.grid(row=0, column=8, rowspan=4, sticky="ns") b_add_cc.grid(row=4, column=0, sticky="ew") b_delete_cc.grid(row=4, column=1, sticky="ew") list_pwheel_maps = factory.listbox(south, ttip="Active pitch wheel maps") list_pwheel_maps.config(width=80, height=8) self.list_pwheel_maps = list_pwheel_maps sb = factory.scrollbar(south, orientation="vertical") sb.config(command=list_pwheel_maps.yview) list_pwheel_maps.config(yscrollcommand=sb.set) b_add_pw = factory.add_button(south, ttip="Add pitchwheel map") b_delete_pw = factory.delete_button(south, ttip="Delete pitchwheel map") b_help = factory.help_button(south, command=help_callback) list_pwheel_maps.grid(row=0, column=0, rowspan=4, columnspan=8, sticky="ew") sb.grid(row=0, column=8, rowspan=4, sticky="ns") b_add_pw.grid(row=4, column=0, sticky="ew") b_delete_pw.grid(row=4, column=1, sticky="ew") b_help.grid(row=4, column=7, sticky="ew") def add_cc_callback(): dialog = add_map_dialog(self.synth, "cc", self.app) def delete_cc_callback(): dialog = delete_map_dialog(self, self.synth, "cc", self.app) def add_pw_callback(): dialog = add_map_dialog(self.synth, "PitchWheel", self.app) def delete_pw_callback(): dialog = delete_map_dialog(self, self.synth, "PitchWheel", self.app) b_add_cc.config(command=add_cc_callback) b_delete_cc.config(command=delete_cc_callback) b_add_pw.config(command=add_pw_callback) b_delete_pw.config(command=delete_pw_callback)
def _init_performance_tab(self, master): img = factory.image("resources/Tabs/performance.png") frame = factory.frame(master) master.add(frame, text = "Performance", image=img, compound="top") frame_channel = factory.label_frame(frame, "MIDI Channel") frame_keytab = factory.label_frame(frame, "Key Table") lab_transpose = factory.label(frame, "Transpose") lab_keyrange = factory.label(frame, "Key Range") lab_bend = factory.label(frame, "Bend Range") self.list_channel = factory.listbox(frame_channel) sb_channel = factory.scrollbar(frame_channel) sb_channel.config(command=self.list_channel.yview) self.list_channel.config(yscrollcommand=sb_channel.set) self.list_keytab = factory.listbox(frame_keytab) sb_keytab = factory.scrollbar(frame_keytab) sb_keytab.config(command=self.list_keytab.yview) self.list_keytab.config(yscrollcommand=sb_keytab.set) spin_transpose = factory.int_spinbox(frame, self.var_transpose, -36, 36) spin_keylow = factory.int_spinbox(frame, self.var_keyrange_low, 0, 127) spin_keyhigh = factory.int_spinbox(frame, self.var_keyrange_high, 0, 127) spin_bendrange = factory.int_spinbox(frame, self.var_bendrange, 0, 2400) factory.padding_label(frame).grid(row=0) frame_channel.grid(row=1, column=0, rowspan=4, columnspan=2) self.list_channel.pack(side="left", expand=True, fill="both") sb_channel.pack(after=self.list_channel, side="right", expand=True, fill="y") frame_keytab.grid(row=1, column=2, rowspan=4, columnspan=2) self.list_keytab.pack(side="left", expand=True, fill="both") sb_keytab.pack(after=self.list_keytab, side="right", expand=True, fill="y") factory.padding_label(frame).grid(row=6) lab_transpose.grid(row=7, column=0, sticky="w", padx=4, pady=4) spin_transpose.grid(row=7, column=1, padx=4) lab_keyrange.grid(row=8, column=0, sticky="w", padx=4, pady=4) spin_keylow.grid(row=8, column=1, padx=4) spin_keyhigh.grid(row=8, column=2, padx=4) lab_bend.grid(row=9, column=0, sticky="w", padx=4, pady=4) spin_bendrange.grid(row=9, column=1, padx=4) def channel_callback(_): i = self.list_channel.curselection()[0] c = i+1 self.synth.midi_input_channel(c) self.status("MIDI Input Channel = %s" % c) def keytab_callback(_): i = self.list_keytab.curselection()[0] kt = self.list_keytab.get(i) self.synth.keytable(kt) self.status("Using keytable: %s" % kt) def transpose_callback(*_): try: x = int(self.var_transpose.get()) self.synth.transpose(x) self.status("Transpose = %s" % x) except ValueError: self.warning("Invalid transpose") def keyrange_callback(*_): try: a = int(self.var_keyrange_low.get()) b = int(self.var_keyrange_high.get()) a, b = min(a,b), max(a,b) self.synth.key_range((a,b)) self.status("Key range = [%3d, %3d]" % (a, b)) except ValueError: self.warning("Invalid keyrange") def bend_callback(*_): try: b = int(self.var_bendrange.get()) self.synth.bend_range(b) self.status("Bend range = %s" % b) except ValueError: self.warning("Invalid Bendrange") self.list_channel.bind("<<ListboxSelect>>", channel_callback) self.list_keytab.bind("<<ListboxSelect>>", keytab_callback) spin_transpose.config(command=transpose_callback) spin_transpose.bind("<Return>", transpose_callback) spin_keylow.config(command=keyrange_callback) spin_keylow.bind("<Return>", keyrange_callback) spin_keyhigh.config(command=keyrange_callback) spin_keyhigh.bind("<Return>", keyrange_callback) spin_bendrange.config(command=bend_callback) spin_bendrange.bind("<Return>", bend_callback)
def _init_busconnection_tab(self, master): img = factory.image("resources/Tabs/bus.png") bct = TkBusConnectionEditor(master, self, self.synth) master.add(bct, text = "Buses", image=img,compound="top") self.bus_connection_editor = bct
def _init_map2_tab(self, master): img = factory.image("resources/Tabs/map.png") HELP_TOPIC = "parameter-maps" HEIGHT = 8 frame = factory.frame(master) master.add(frame, text="Map2",image=img,compound="top") north = factory.label_frame(frame, "Velocity Maps") center = factory.label_frame(frame, "Aftertouch Maps") south = factory.label_frame(frame, "Keynumber Maps") north.grid(row=0, column=0, sticky="ew", padx=8, pady=8) center.grid(row=1, column=0, sticky="ew", padx=8) south.grid(row=2, column=0, sticky="ew", padx=8, pady=8) def help_callback(): self.app.main_window().display_help(HELP_TOPIC) list_vel_maps = factory.listbox(north, ttip="Active velocity maps") list_vel_maps.config(width=80, height=HEIGHT) self.list_vel_maps = list_vel_maps sb = factory.scrollbar(north, orientation="vertical") sb.config(command=list_vel_maps.yview) list_vel_maps.config(yscrollcommand=sb.set) b_add_vel = factory.add_button(north, ttip="Add velocity map") b_delete_vel = factory.delete_button(north, ttip="Delete velocity map") list_vel_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_vel.grid(row=1, column=0, sticky="ew") b_delete_vel.grid(row=1, column=1, sticky="ew") list_atouch_maps = factory.listbox(center, ttip="Active after touch maps") list_atouch_maps.config(width=80, height=HEIGHT) self.list_atouch_maps = list_atouch_maps sb = factory.scrollbar(center, orientation="vertical") sb.config(command=list_atouch_maps.yview) list_atouch_maps.config(yscrollcommand=sb.set) b_add_atouch = factory.add_button(center, ttip="Add after touch map") b_delete_atouch = factory.delete_button(center, ttip="Delete after touch map") list_atouch_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_atouch.grid(row=1, column=0, sticky="ew") b_delete_atouch.grid(row=1, column=1, sticky="ew") list_keynum_maps = factory.listbox(south, ttip="Active key number maps") list_keynum_maps.config(width=80, height=HEIGHT) self.list_keynum_maps = list_keynum_maps sb = factory.scrollbar(south, orientation="vertical") sb.config(command=list_keynum_maps.yview) list_keynum_maps.config(yscrollcommand=sb.set) b_add_keynum = factory.add_button(south, ttip="Add key number map") b_delete_keynum = factory.delete_button(south, ttip="Delete key number map") b_help = factory.help_button(south, command=help_callback) list_keynum_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_keynum.grid(row=1, column=0, sticky="ew") b_delete_keynum.grid(row=1, column=1, sticky="ew") b_help.grid(row=1, column=7, sticky="ew") def add_map_callback(event): widget = event.widget if widget is b_add_vel: dialog = add_map_dialog(self.synth, "velocity", self.app) elif widget is b_add_atouch: dialog = add_map_dialog(self.synth, "aftertouch", self.app) elif widget is b_add_keynum: dialog = add_map_dialog(self.synth, "keynumber", self.app) else: msg = "Invalid widget - Should never see this" raise ValueError(msg) def delete_map_callback(event): widget = event.widget if widget is b_delete_vel: dialog = delete_map_dialog(self, self.synth, "velocity", self.app) elif widget is b_delete_atouch: dialog = delete_map_dialog(self, self.synth, "aftertouch", self.app) elif widget is b_delete_keynum: dialog = delete_map_dialog(self, self.synth, "keynumber", self.app) else: msg = "Invalid widget - Should never see this" raise ValueError(msg) b_add_vel.bind("<Button-1>", add_map_callback) b_add_atouch.bind("<Button-1>", add_map_callback) b_add_keynum.bind("<Button-1>", add_map_callback) b_delete_vel.bind("<Button-1>", delete_map_callback) b_delete_atouch.bind("<Button-1>", delete_map_callback) b_delete_keynum.bind("<Button-1>", delete_map_callback)
def _init_map1_tab(self, master): img = factory.image("resources/Tabs/map.png") HELP_TOPIC = "parameter-maps" frame = factory.frame(master) master.add(frame, text="Map1", image=img, compound="top") north = factory.label_frame(frame, "MIDI Controller Maps") south = factory.label_frame(frame, "Pitch Wheel Maps") north.grid(row=0, column=0, sticky="ew", padx=8, pady=8) south.grid(row=1, column=0, sticky="ew", padx=8, pady=8) def help_callback(): self.app.main_window().display_help(HELP_TOPIC) list_cc_maps = factory.listbox(north, ttip="Active MIDI controller maps") list_cc_maps.config(width=80, height=16) self.list_cc_maps = list_cc_maps sb = factory.scrollbar(north, orientation="vertical") sb.config(command=list_cc_maps.yview) list_cc_maps.config(yscrollcommand=sb.set) b_add_cc = factory.add_button(north, ttip="Add new controller map") b_delete_cc = factory.delete_button(north, ttip="Delete controller map") list_cc_maps.grid(row=0, column=0, rowspan=4, columnspan=8, sticky="ew") sb.grid(row=0, column=8, rowspan=4, sticky="ns") b_add_cc.grid(row=4, column=0, sticky="ew") b_delete_cc.grid(row=4, column=1, sticky="ew") list_pwheel_maps = factory.listbox(south, ttip="Active pitch wheel maps") list_pwheel_maps.config(width=80, height=8) self.list_pwheel_maps = list_pwheel_maps sb = factory.scrollbar(south, orientation="vertical") sb.config(command=list_pwheel_maps.yview) list_pwheel_maps.config(yscrollcommand=sb.set) b_add_pw = factory.add_button(south, ttip="Add pitchwheel map") b_delete_pw = factory.delete_button(south, ttip="Delete pitchwheel map") b_help = factory.help_button(south, command=help_callback) list_pwheel_maps.grid(row=0, column=0, rowspan=4, columnspan=8, sticky="ew") sb.grid(row=0, column=8, rowspan=4, sticky="ns") b_add_pw.grid(row=4, column=0, sticky="ew") b_delete_pw.grid(row=4, column=1, sticky="ew") b_help.grid(row=4, column=7, sticky="ew") def add_cc_callback(): dialog = add_map_dialog(self.synth, "cc", self.app) def delete_cc_callback(): dialog = delete_map_dialog(self, self.synth, "cc", self.app) def add_pw_callback(): dialog = add_map_dialog(self.synth, "PitchWheel", self.app) def delete_pw_callback(): dialog = delete_map_dialog(self, self.synth, "PitchWheel", self.app) b_add_cc.config(command=add_cc_callback) b_delete_cc.config(command=delete_cc_callback) b_add_pw.config(command=add_pw_callback) b_delete_pw.config(command=delete_pw_callback)
def _init_midi_tab(self, master): img = factory.image("resources/Tabs/midi.png") frame = factory.frame(master) master.add(frame, text = "Performance", image=img, compound="top") frame_channel = factory.frame(frame) frame_keytab = factory.frame(frame) lab_transpose = factory.label(frame, "Transpose") lab_keyrange = factory.label(frame, "Key Range") lab_bend = factory.label(frame, "Bend Range") self.list_channel = factory.listbox(frame_channel) sb_channel = factory.scrollbar(frame_channel) sb_channel.config(command=self.list_channel.yview) self.list_channel.config(yscrollcommand=sb_channel.set) self.list_keytab = factory.listbox(frame_keytab) sb_keytab = factory.scrollbar(frame_keytab) sb_keytab.config(command=self.list_keytab.yview) self.list_keytab.config(yscrollcommand=sb_keytab.set) spin_transpose = factory.int_spinbox(frame,self.var_transpose,-36,36) spin_keylow = factory.int_spinbox(frame,self.var_keyrange_low,0,127) spin_keyhigh = factory.int_spinbox(frame,self.var_keyrange_high,0,127) spin_bendrange = factory.int_spinbox(frame,self.var_bendrange, 0, 2400) factory.padding_label(frame).grid(row=0) lab_channel = factory.label(frame,"MIDI Input Channel") lab_channel.grid(row=0,column=0,columnspan=2, pady=8) frame_channel.grid(row=1, column=0, rowspan=4, columnspan=2,padx=8,pady=8) self.list_channel.pack(side="left", expand=True, fill="both") sb_channel.pack(after=self.list_channel, side="right", expand=True, fill="y") lab_ktab = factory.label(frame, "Key Table") lab_ktab.grid(row=0,column=2,columnspan=2,pady=8) frame_keytab.grid(row=1, column=2, rowspan=4, columnspan=2,padx=8,pady=8) self.list_keytab.pack(side="left", expand=True, fill="both") sb_keytab.pack(after=self.list_keytab, side="right", expand=True, fill="y") factory.padding_label(frame).grid(row=6) lab_transpose.grid(row=7, column=0, sticky="w", padx=4, pady=4) lab_keyrange.grid(row=8, column=0, sticky="w", padx=4, pady=4) lab_bend.grid(row=9, column=0, sticky="w", padx=4, pady=4) spin_transpose.grid(row=7, column=1, padx=4) spin_keylow.grid(row=8, column=1, padx=4) spin_keyhigh.grid(row=8, column=2, padx=4) spin_bendrange.grid(row=9, column=1, padx=4) def channel_callback(_): i = self.list_channel.curselection()[0] c = i+1 self.synth.midi_input_channel(c) self.status("MIDI Input Channel = %s" % c) def keytab_callback(_): i = self.list_keytab.curselection()[0] kt = self.list_keytab.get(i) self.synth.keytable(kt) self.status("Using keytable: %s" % kt) def transpose_callback(*_): try: x = int(self.var_transpose.get()) self.synth.transpose(x) self.status("Transpose = %s" % x) except ValueError: self.warning("Invalid transpose") def keyrange_callback(*_): try: a = int(self.var_keyrange_low.get()) b = int(self.var_keyrange_high.get()) a, b = min(a,b), max(a,b) self.synth.key_range((a,b)) self.status("Key range = [%3d, %3d]" % (a, b)) except ValueError: self.warning("Invalid keyrange") def bend_callback(*_): try: b = int(self.var_bendrange.get()) self.synth.bend_range(b) self.status("Bend range = %s" % b) except ValueError: self.warning("Invalid Bendrange") self.list_channel.bind("<<ListboxSelect>>", channel_callback) self.list_keytab.bind("<<ListboxSelect>>", keytab_callback) spin_transpose.config(command=transpose_callback) spin_transpose.bind("<Return>", transpose_callback) spin_keylow.config(command=keyrange_callback) spin_keylow.bind("<Return>", keyrange_callback) spin_keyhigh.config(command=keyrange_callback) spin_keyhigh.bind("<Return>", keyrange_callback) spin_bendrange.config(command=bend_callback) spin_bendrange.bind("<Return>", bend_callback)