def dump_sfz(self, w, channel): attribs = cbox.GetThings("%s/status" % self.path, ['%patch', 'polyphony', 'active_voices'], []) prog_no, patch_name = attribs.patch[channel] pname, uuid, in_use_cnt = cbox.GetThings("%s/patches" % self.path, ['%patch'], []).patch[prog_no] print ("UUID=%s" % uuid) patch = cbox.Document.map_uuid(uuid) groups = patch.get_groups() for r in groups[0].get_children(): print ("<region> %s" % (r.as_string())) for grp in patch.get_groups()[1:]: print ("<group> %s" % (grp.as_string())) for r in grp.get_children(): print ("<region> %s" % (r.as_string()))
def __init__(self, location, main_window, path): Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL) self.set_type_hint(Gdk.WindowTypeHint.UTILITY) self.set_transient_for(main_window) self.main_window = main_window self.path = path self.vpath = cbox.VarPath(path) self.set_title("%s - %s" % (self.effect_name, location)) self.vbox = Gtk.VBox() menu_bar = Gtk.MenuBar() menu_bar.append( create_menu("_Effect", [ ("_Save as...", self.on_effect_save_as if self.engine_name is not None else None), ("_Close", lambda w: self.destroy()), ])) self.vbox.pack_start(menu_bar, False, False, 0) if hasattr(self, 'params'): values = cbox.GetThings(self.path + "/status", [p.name for p in self.params], []) self.refreshers = [] t = Gtk.Table(2, len(self.params)) for i in range(len(self.params)): p = self.params[i] t.attach(p.create_label(), 0, 1, i, i + 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL, Gtk.AttachOptions.SHRINK) widget, refresher = p.create_widget(self.vpath) refresher(values) t.attach(widget, 1, 2, i, i + 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.SHRINK) self.refreshers.append(refresher) self.vbox.pack_start(t, True, True, 5) self.add(self.vbox)
def __init__(self, instrument, iobj): Gtk.VBox.__init__(self) self.engine = iobj.engine self.path = self.engine.path print (iobj.path) attribs = iobj.status() panel = Gtk.VBox(spacing=5) table = Gtk.Table(2, 1) IntSliderRow("Polyphony", "polyphony", 2, 256).add_row(table, 0, cbox.VarPath(self.path), attribs) WithPatchTable.__init__(self, attribs) panel.pack_start(standard_vscroll_window(-1, 160, self.table), True, True, 5) hpanel = Gtk.HBox(spacing = 5) self.filebutton = Gtk.FileChooserButton("Soundfont") self.filebutton.set_action(Gtk.FileChooserAction.OPEN) self.filebutton.set_local_only(True) self.filebutton.set_filename(cbox.GetThings("%s/status" % self.path, ['soundfont'], []).soundfont) self.filebutton.add_filter(standard_filter(["*.sf2", "*.SF2"], "SF2 Soundfonts")) self.filebutton.add_filter(standard_filter(["*"], "All files")) hpanel.pack_start(Gtk.Label.new_with_mnemonic("_Load SF2:"), False, False, 5) hpanel.pack_start(self.filebutton, True, True, 5) unload = Gtk.Button.new_with_mnemonic("_Unload") hpanel.pack_start(unload, False, False, 5) unload.connect('clicked', self.unload) panel.pack_start(hpanel, False, False, 5) self.filebutton.connect('file-set', self.file_set) self.add(panel)
def get_save_params(self): if hasattr(self, 'params'): values = cbox.GetThings(self.path + "/status", [p.name for p in self.params], []) result = {'engine': self.engine_name} for p in self.params: result[p.name] = str(getattr(values, p.name)) return result return None
def update(self): values = cbox.GetThings(self.path + "/status", ["finished", "refresh"], []) if values.refresh: self.refresh_table() if values.finished > 0: self.ready_label.set_text("Ready") else: self.ready_label.set_text("Not Ready") return True
def get_save_params(self): values = cbox.GetThings(self.path + "/status", ["%active", "%center", "%q", "%gain"], []) result = {'engine': self.engine_name} for row in range(self.bands): row2 = 1 + row result['band%s_active' % row2] = values.active[row] result['band%s_center' % row2] = values.center[row] result['band%s_q' % row2] = values.q[row] result['band%s_gain' % row2] = values.gain[row] return result
def update(self): attribs = cbox.GetThings("%s/status" % self.path, ['filename', 'pos', 'length', 'playing'], []) self.progress.set_sensitive(attribs.length is not None) if attribs.length is not None: try: self.adjustment.handler_block(self.adjustment_handler) self.adjustment.set_properties(value = attribs.pos, lower = 0, upper = attribs.length) #self.adjustment.set_all(attribs.pos, 0, attribs.length, 44100, 44100 * 10, 0) finally: self.adjustment.handler_unblock(self.adjustment_handler) return True
def edit_effect_clicked(self, button): if self.popup is not None: self.popup.present() return engine = cbox.GetThings(self.opath + "/status", ['insert_engine'], []).insert_engine wclass = effect_window_map[engine] popup = wclass(self.location, self.main_window, "%s/engine" % self.opath) popup.show_all() popup.present() popup.connect('delete_event', self.on_popup_closed) self.popup = popup
def update(self): scene = cbox.Document.get_scene() cmds = nocturn.NocturnCommands() master = cbox.GetThings("/master/status", ['playing'], []) for i in range(7): cmds.setModeButtonLight(i, self.cur_pattern == i) gain = scene.status().instruments[instr_name][1].get_things( '/output/1/status', ['gain']).gain cmds.setEncoderMode(0, 0) cmds.setEncoderValue(0, clamp(int(gain * 2 + 64), 0, 127)) cmds.setModeButtonLight(7, self.cur_pattern is None) self.nocturn.execute(cmds)
def refresh_table(self): res = cbox.GetThings(self.path + "/status", ["*module", "%bypass"], []) values = res.module bypass = res.bypass fx_count = len(values) t = Gtk.Table(fx_count + 2, 9) for c in self.choosers: c.close_popup() self.choosers = [] for i in range(1, fx_count + 1): engine, preset = values[i - 1] chooser = InsertEffectChooser( "%s/module/%s" % (self.path, i), "%s: slot %s" % (self.get_title(), i), engine, preset, bypass[i], self.main_window) t.attach(chooser.fx_engine, 0, 1, i, i + 1, 0, Gtk.AttachOptions.SHRINK) t.attach(chooser.fx_preset, 1, 2, i, i + 1, 0, Gtk.AttachOptions.SHRINK) t.attach(chooser.fx_edit, 2, 3, i, i + 1, 0, Gtk.AttachOptions.SHRINK) t.attach(chooser.fx_bypass, 3, 4, i, i + 1, 0, Gtk.AttachOptions.SHRINK) buttons = [("+", self.on_add_clicked, lambda pos: True), ("-", self.on_delete_clicked, lambda pos: True), ("Up", self.on_up_clicked, lambda pos: pos > 1), ("Down", self.on_down_clicked, lambda pos: pos < fx_count)] for j in range(len(buttons)): label, method, cond = buttons[j] if not cond(i): continue button = Gtk.Button(label) button.connect('clicked', lambda button, method, pos: method(pos), method, i) t.attach(button, 4 + j, 5 + j, i, i + 1, 0, Gtk.AttachOptions.SHRINK) self.choosers.append(chooser) button = Gtk.Button("+") button.connect('clicked', lambda button, pos: self.on_add_clicked(pos), fx_count + 1) t.attach(button, 3, 4, fx_count + 1, fx_count + 2, 0, Gtk.AttachOptions.SHRINK) if self.fx_table is not None: self.vbox.remove(self.fx_table) self.vbox.pack_start(t, True, True, 5) t.show_all() self.fx_table = t
def __init__(self, instrument, main_window, path): EffectWindow.__init__(self, instrument, main_window, path) values = cbox.GetThings(self.path + "/status", ["%active", "%center", "%q", "%gain"], []) t = self.create_param_table(self.columns, 16, values, 1) self.vbox.add(t) self.ready_label = Gtk.Label("-") t.attach(self.ready_label, 0, 2, 17, 18) set_timer(self, 100, self.update) sbutton = Gtk.Button.new_with_mnemonic("_Start") sbutton.connect( "clicked", lambda button, path: cbox.do_cmd(path + "/start", None, []), self.path) t.attach(sbutton, 2, 4, 17, 18)
def refresh(self): if hasattr(self, 'params'): values = cbox.GetThings(self.path + "/status", [p.name for p in self.params], []) for refresher in self.refreshers: refresher(values)
def refresh_table(self): values = cbox.GetThings(self.path + "/status", ["%active", "%center", "%q", "%gain"], []) for refresher in self.table_refreshers: refresher(values)
def __init__(self, instrument, main_window, path): EffectWindow.__init__(self, instrument, main_window, path) values = cbox.GetThings(self.path + "/status", ["%active", "%center", "%q", "%gain"], []) self.vbox.add(self.create_param_table(self.columns, 4, values))
def on_knob2_change(self, cmd, val): tempo = cbox.GetThings("/master/status", ['tempo'], []).tempo if val > 63: val = -128 + val tempo = clamp(tempo + val * 0.5, 30, 300) cbox.do_cmd('/master/set_tempo', None, [tempo])