예제 #1
0
    def __init__(self, master):
        self.current = None
        self.frame = Frame(master)
        self.frame.pack()

        self.midi_controller = MidiController()

        # Voice stack info
        self.chosen_bank = None
        self.chosen_voice = None
        self.voice_list = LoadSave.load()
        self.current_index = -1

        # Voice Display Info
        self.display_holder = LabelFrame(self.frame, padx=5, pady=5)
        self.display_holder.pack(side=RIGHT)
        self.display_voice_stringvar = StringVar()
        self.display_voice_label = Label(self.display_holder, textvariable=self.display_voice_stringvar)
        self.display_voice_label.pack(side=LEFT)

        self.button = Button(self.frame, text="QUIT", fg="red", command=self._exit)
        self.button.pack(side=LEFT)

        self.main_bank_select = Listbox(self.frame, exportselection=0, width=8)
        self.main_bank_select.pack(side=LEFT)

        self.voice_select = Listbox(self.frame, exportselection=0, width=12, height=10)
        self.voice_select.pack(side=LEFT)

        button_frame = Frame(self.frame)
        button_frame.pack(side=LEFT)

        self.name_entry = Entry(button_frame)
        self.name_entry.pack(side=TOP)
        chose_append_button = Button(button_frame, text="At End", bg="black", fg="blue",
                                     command=lambda: self._pick_voice(append=True))
        chose_append_button.pack(side=TOP)
        chose_before_button = Button(button_frame, text="Before",
                                     command=lambda: self._pick_voice(after=False))
        chose_before_button.pack(side=TOP)
        chose_before_button = Button(button_frame, text="After",
                                     command=lambda: self._pick_voice(after=True))
        chose_before_button.pack(side=TOP)
        spacer = Frame(button_frame, height=2)
        spacer.pack(side=TOP, pady=5)
        set_cursor_button = Button(button_frame, text="Set At",
                                   command=lambda: self._set_current_index(int(self.order_listbox.curselection()[0])))
        set_cursor_button.pack()

        self.order_listbox = Listbox(self.frame, exportselection=0, width=30)
        self.order_listbox.pack(side=LEFT)
        self.integrated_tones = IntegratedTones()
        self._update_listbox(self.main_bank_select, self.integrated_tones.groups)

        self.main_bank_select.bind("<<ListboxSelect>>", self._update_voice_listbox)
        self.voice_select.bind("<<ListboxSelect>>", self._choose_voice)
        self._update_order_listbox()
예제 #2
0
    def _pick_voice(self, append=False, after=False):
        if self.chosen_voice:
            name = self.name_entry.get()
            patch_entry = PatchEntry(self.chosen_bank, self.chosen_voice)
            patch_change = PatchChange(name, patch_entry)
            current_index_selection = map(int, self.order_listbox.curselection())

            if append or len(current_index_selection) == 0:
                self.voice_list.append(patch_change)
            else:
                index = current_index_selection[0]
                if after:
                    index += 1
                self.voice_list.insert(index, patch_change)

            self._update_order_listbox()

            print patch_change.serialise()
            LoadSave.write(self.voice_list)