def __init__(self): super().__init__() self._init_val = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._init_val.setMinimum(-99999) self._init_val.setMaximum(99999) self._osc_speed = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_speed.setMinimum(0) self._osc_speed.setMaximum(1000) self._osc_depth = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_depth.setMinimum(0) self._osc_depth.setMaximum(99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(10) h.addWidget(QLabel('Initial value:'), 0) h.addWidget(self._init_val, 1) h.addWidget(QLabel('Initial oscillation speed:'), 0) h.addWidget(self._osc_speed, 1) h.addWidget(QLabel('Initial oscillation depth:'), 0) h.addWidget(self._osc_depth, 1) self.setLayout(h)
def __init__(self): super().__init__() self._min_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._min_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) for editor in (self._min_editor, self._max_editor): editor.setMinimum(-99999) editor.setMaximum(99999) for editor in (self._min_var_editor, self._max_var_editor): editor.setMinimum(0) editor.setMaximum(99999) d = QHBoxLayout() d.setContentsMargins(0, 0, 0, 0) d.setSpacing(4) d.addWidget(QLabel('Minimum value:')) d.addWidget(self._min_editor) d.addWidget(QLabel('±')) d.addWidget(self._min_var_editor) d.addWidget(QLabel('Maximum value:')) d.addWidget(self._max_editor) self._disableables = d h = QHBoxLayout() h.setContentsMargins(10, 0, 10, 0) h.setSpacing(4) h.addLayout(self._disableables) h.addWidget(QLabel('±')) h.addWidget(self._max_var_editor) h.addStretch(1) self.setLayout(h)
def __init__(self): super().__init__() self._name = QLineEdit() self._length = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._length.setMinimum(1) self._length.setMaximum(32) self._spacing_style = LineStyle(is_major_enabled=True) self._spacing_value = VarPrecSpinBox(step_decimals=1, max_decimals=2) self._spacing_value.setMinimum(0.01) self._spacing_value.setMaximum(1.0) self._offset = VarPrecSpinBox(step_decimals=1, max_decimals=5) self._offset.setMinimum(0) self._offset.setMaximum(32) nl = QHBoxLayout() nl.setContentsMargins(0, 0, 0, 0) nl.setSpacing(2) nl.addWidget(QLabel('Name:'), 0) nl.addWidget(self._name, 1) ll = QHBoxLayout() ll.setContentsMargins(0, 0, 0, 0) ll.setSpacing(2) ll.addWidget(QLabel('Grid length:'), 0) ll.addWidget(self._length, 1) sl = QHBoxLayout() sl.setContentsMargins(0, 0, 0, 0) sl.setSpacing(2) sl.addWidget(QLabel('Show lines'), 0) sl.addWidget(self._spacing_style, 3) sl.addWidget(QLabel('when spacing is ≥:'), 0) sl.addWidget(self._spacing_value, 1) ol = QHBoxLayout() ol.setContentsMargins(0, 0, 0, 0) ol.setSpacing(2) ol.addWidget(QLabel('Grid offset:'), 0) ol.addWidget(self._offset, 1) v = QVBoxLayout() v.setContentsMargins(0, 0, 0, 0) v.setSpacing(2) v.addLayout(nl) v.addLayout(ll) v.addLayout(sl) v.addLayout(ol) self.setLayout(v)
def __init__(self, index): super().__init__() self._index = index self._spin = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._spin.setMinimum(0.000001) self._spin.setMaximum(1024.0) self._spin.setValue(1) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.addWidget(QLabel('Pitch factor:')) h.addWidget(self._spin) self.setLayout(h)
def __init__(self): super().__init__() self._is_latest_committed = True self._spinbox = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._spinbox.setMinimum(0) self._spinbox.setMaximum(1024) h = QHBoxLayout() h.setContentsMargins(5, 0, 5, 0) h.setSpacing(5) h.addWidget(QLabel('Pattern length')) h.addWidget(self._spinbox) self.setLayout(h)
def __init__(self): super().__init__() self._start_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._stop_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._start_value.setRange(-99999, 99999) self._stop_value.setRange(-99999, 99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(8) h.addWidget(QLabel('Start value:')) h.addWidget(self._start_value, 1) h.addWidget(QLabel('Stop value:')) h.addWidget(self._stop_value, 1) self.setLayout(h)
def __init__(self): super().__init__() self._start_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._stop_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._start_value.setRange(-99999, 99999) self._stop_value.setRange(-99999, 99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(8) h.addWidget(QLabel('Start value:')) h.addWidget(self._start_value, 1) h.addWidget(QLabel('Stop value:')) h.addWidget(self._stop_value, 1) self.setLayout(h)
def __init__(self): super().__init__() self._min_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._min_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) for editor in (self._min_editor, self._max_editor): editor.setMinimum(-99999) editor.setMaximum(99999) for editor in (self._min_var_editor, self._max_var_editor): editor.setMinimum(0) editor.setMaximum(99999) d = QHBoxLayout() d.setContentsMargins(0, 0, 0, 0) d.setSpacing(4) d.addWidget(QLabel('Minimum value:')) d.addWidget(self._min_editor) d.addWidget(QLabel('±')) d.addWidget(self._min_var_editor) d.addWidget(QLabel('Maximum value:')) d.addWidget(self._max_editor) self._disableables = d h = QHBoxLayout() h.setContentsMargins(10, 0, 10, 0) h.setSpacing(4) h.addLayout(self._disableables) h.addWidget(QLabel('±')) h.addWidget(self._max_var_editor) h.addStretch(1) self.setLayout(h)
def __init__(self): super().__init__() self._init_val = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._init_val.setMinimum(-99999) self._init_val.setMaximum(99999) self._osc_speed = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_speed.setMinimum(0) self._osc_speed.setMaximum(1000) self._osc_depth = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_depth.setMinimum(0) self._osc_depth.setMaximum(99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(10) h.addWidget(QLabel('Initial value:'), 0) h.addWidget(self._init_val, 1) h.addWidget(QLabel('Initial oscillation speed:'), 0) h.addWidget(self._osc_speed, 1) h.addWidget(QLabel('Initial oscillation depth:'), 0) h.addWidget(self._osc_depth, 1) self.setLayout(h)
def __init__(self, index): super().__init__() self._index = index self._pitch_factor = VarPrecSpinBox(step_decimals=0, max_decimals=4) self._pitch_factor.setRange(0.0001, 1024.0) self._pitch_factor.setValue(1) self._level = LevelEditor(index) self._remove_button = QPushButton() self._remove_button.setStyleSheet('padding: 0 -2px;') self._remove_button.setEnabled(self._index != 0) h = QHBoxLayout() h.setContentsMargins(4, 0, 4, 0) h.setSpacing(2) h.addWidget(QLabel('Pitch factor:')) h.addWidget(self._pitch_factor) h.addWidget(self._level) h.addWidget(self._remove_button) self.setLayout(h)
def __init__(self): super().__init__() self._is_latest_committed = True self._spinbox = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._spinbox.setMinimum(0) self._spinbox.setMaximum(1024) h = QHBoxLayout() h.setContentsMargins(5, 0, 5, 0) h.setSpacing(5) h.addWidget(QLabel('Pattern length:')) h.addWidget(self._spinbox) self.setLayout(h)
def __init__(self, index): super().__init__() self._index = index self._spin = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._spin.setMinimum(0.000001) self._spin.setMaximum(1024.0) self._spin.setValue(1) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.addWidget(QLabel('Pitch factor:')) h.addWidget(self._spin) self.setLayout(h)
def __init__(self): super().__init__() self._name = QLineEdit() self._length = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._length.setMinimum(1) self._length.setMaximum(32) self._spacing_style = LineStyle(is_major_enabled=True) self._spacing_value = VarPrecSpinBox(step_decimals=1, max_decimals=2) self._spacing_value.setMinimum(0.01) self._spacing_value.setMaximum(1.0) self._offset = VarPrecSpinBox(step_decimals=1, max_decimals=5) self._offset.setMinimum(0) self._offset.setMaximum(32) nl = QHBoxLayout() nl.setContentsMargins(0, 0, 0, 0) nl.setSpacing(2) nl.addWidget(QLabel('Name:'), 0) nl.addWidget(self._name, 1) ll = QHBoxLayout() ll.setContentsMargins(0, 0, 0, 0) ll.setSpacing(2) ll.addWidget(QLabel('Grid length:'), 0) ll.addWidget(self._length, 1) sl = QHBoxLayout() sl.setContentsMargins(0, 0, 0, 0) sl.setSpacing(2) sl.addWidget(QLabel('Show lines'), 0) sl.addWidget(self._spacing_style, 3) sl.addWidget(QLabel('when spacing is ≥:'), 0) sl.addWidget(self._spacing_value, 1) ol = QHBoxLayout() ol.setContentsMargins(0, 0, 0, 0) ol.setSpacing(2) ol.addWidget(QLabel('Grid offset:'), 0) ol.addWidget(self._offset, 1) v = QVBoxLayout() v.setContentsMargins(0, 0, 0, 0) v.setSpacing(2) v.addLayout(nl) v.addLayout(ll) v.addLayout(sl) v.addLayout(ol) self.setLayout(v)
class LengthEditor(QWidget, Updater): def __init__(self): super().__init__() self._is_latest_committed = True self._spinbox = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._spinbox.setMinimum(0) self._spinbox.setMaximum(1024) h = QHBoxLayout() h.setContentsMargins(5, 0, 5, 0) h.setSpacing(5) h.addWidget(QLabel('Pattern length:')) h.addWidget(self._spinbox) self.setLayout(h) def _on_setup(self): self.register_action('signal_module', self._update_value) self.register_action('signal_pattern_length', self._update_value) self.register_action('signal_selection', self._update_value) self.register_action('signal_order_list', self._update_value) self.register_action('signal_sheet_undo', self._update_value) self.register_action('signal_sheet_redo', self._update_value) self.register_action('signal_style_changed', self._update_style) self._update_style() self._update_value() self._spinbox.valueChanged.connect(self._change_length) self._spinbox.editingFinished.connect(self._change_length_final) def _update_style(self): style_mgr = self._ui_model.get_style_manager() self._spinbox.update_style(style_mgr) margin_x = style_mgr.get_scaled_size_param('medium_padding') self.layout().setContentsMargins(margin_x, 0, margin_x, 0) self.layout().setSpacing(style_mgr.get_scaled_size_param('medium_padding')) def _get_pattern(self): module = self._ui_model.get_module() album = module.get_album() if not album.get_existence(): return None selection = self._ui_model.get_selection() location = selection.get_location() song = album.get_song_by_track(location.get_track()) pinst = song.get_pattern_instance(location.get_system()) pattern = pinst.get_pattern() return pattern def _update_value(self): pattern = self._get_pattern() if not pattern: self.setEnabled(False) old_block = self._spinbox.blockSignals(True) self._spinbox.setValue(0) self._spinbox.blockSignals(old_block) return length = pattern.get_length() length_val = float(length) self.setEnabled(True) old_block = self._spinbox.blockSignals(True) if length_val != self._spinbox.value(): self._spinbox.setValue(length_val) self._spinbox.blockSignals(old_block) def _change_value(self, new_value, is_final): pattern = self._get_pattern() if not pattern: return sheet_mgr = self._ui_model.get_sheet_manager() length = tstamp.Tstamp(new_value) if length == pattern.get_length(): if is_final and not self._is_latest_committed: sheet_mgr.set_pattern_length(pattern, length, is_final) self._is_latest_committed = True return sheet_mgr.set_pattern_length(pattern, length, is_final) self._updater.signal_update('signal_pattern_length') def _change_length(self, new_value): self._is_latest_committed = False self._change_value(new_value, is_final=False) def _change_length_final(self): new_value = self._spinbox.value() self._change_value(new_value, is_final=True)
class TonePitchSpin(QWidget, ProcessorUpdater): def __init__(self, index): super().__init__() self._index = index self._spin = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._spin.setMinimum(0.000001) self._spin.setMaximum(1024.0) self._spin.setValue(1) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.addWidget(QLabel('Pitch factor:')) h.addWidget(self._spin) self.setLayout(h) def _on_setup(self): self.register_action('signal_au', self._update_value) self.register_action(self._get_update_signal_type(), self._update_value) self._update_value() self._spin.valueChanged.connect(self._value_changed) self.register_action('signal_style_changed', self._update_style) self._update_style() def _update_style(self): style_mgr = self._ui_model.get_style_manager() self._spin.update_style(style_mgr) self.layout().setSpacing(style_mgr.get_scaled_size_param('small_padding')) def _get_update_signal_type(self): return ''.join(('signal_proc_add_tone_', self._au_id, self._proc_id)) def _update_value(self): add_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) if self._index >= add_params.get_tone_count(): # We have been removed return old_block = self._spin.blockSignals(True) new_pitch = add_params.get_tone_pitch(self._index) if new_pitch != self._spin.value(): self._spin.setValue(new_pitch) self._spin.blockSignals(old_block) def _value_changed(self, pitch): add_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) add_params.set_tone_pitch(self._index, pitch) self._updater.signal_update(self._get_update_signal_type())
class HarmonicLevelEditor(QWidget, ProcessorUpdater): def __init__(self, index): super().__init__() self._index = index self._pitch_factor = VarPrecSpinBox(step_decimals=0, max_decimals=4) self._pitch_factor.setRange(0.0001, 1024.0) self._pitch_factor.setValue(1) self._level = LevelEditor(index) self._remove_button = ProcessorIconButton() self._remove_button.setEnabled(self._index != 0) self.add_to_updaters(self._remove_button) h = QHBoxLayout() h.setContentsMargins(4, 0, 0, 0) h.setSpacing(2) h.addWidget(QLabel('Pitch factor:')) h.addWidget(self._pitch_factor) h.addWidget(self._level) h.addWidget(self._remove_button) self.setLayout(h) def _on_setup(self): self.add_to_updaters(self._level) self.register_action('signal_style_changed', self._update_style) self._remove_button.set_icon('delete_small') style_mgr = self._ui_model.get_style_manager() self._remove_button.set_sizes( style_mgr.get_style_param('list_button_size'), style_mgr.get_style_param('list_button_padding')) self._pitch_factor.valueChanged.connect(self._change_pitch_factor) self._remove_button.clicked.connect(self._remove_harmonic) self._update_style() self.update_index(self._index) def _get_params(self): return utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) def _update_style(self): style_mgr = self._ui_model.get_style_manager() self._pitch_factor.update_style(style_mgr) self.layout().setContentsMargins( style_mgr.get_scaled_size_param('medium_padding'), 0, 0, 0) self.layout().setSpacing( style_mgr.get_scaled_size_param('small_padding')) def update_index(self, index): self._index = index levels = self._get_params().get_harmonic_levels() if self._index >= levels.get_count(): return level = levels.get_level(self._index) old_block = self._pitch_factor.blockSignals(True) new_pitch_factor = level.get_freq_mul() if new_pitch_factor != self._pitch_factor.value(): self._pitch_factor.setValue(new_pitch_factor) self._pitch_factor.blockSignals(old_block) self._remove_button.setEnabled(levels.get_count() > 1) def _get_update_signal_type(self): return 'signal_padsynth_{}'.format(self._proc_id) def _change_pitch_factor(self, value): levels = self._get_params().get_harmonic_levels() if self._index >= levels.get_count(): return level = levels.get_level(self._index) level.set_freq_mul(value) self._updater.signal_update(self._get_update_signal_type()) def _remove_harmonic(self): levels = self._get_params().get_harmonic_levels() if self._index >= levels.get_count(): return levels.remove_level(self._index) self._updater.signal_update(self._get_update_signal_type())
class GeneralEditor(QWidget, Updater): def __init__(self): super().__init__() self._name = QLineEdit() self._length = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._length.setMinimum(1) self._length.setMaximum(32) self._spacing_style = LineStyle(is_major_enabled=True) self._spacing_value = VarPrecSpinBox(step_decimals=1, max_decimals=2) self._spacing_value.setMinimum(0.01) self._spacing_value.setMaximum(1.0) self._offset = VarPrecSpinBox(step_decimals=1, max_decimals=5) self._offset.setMinimum(0) self._offset.setMaximum(32) nl = QHBoxLayout() nl.setContentsMargins(0, 0, 0, 0) nl.setSpacing(2) nl.addWidget(QLabel('Name:'), 0) nl.addWidget(self._name, 1) ll = QHBoxLayout() ll.setContentsMargins(0, 0, 0, 0) ll.setSpacing(2) ll.addWidget(QLabel('Grid length:'), 0) ll.addWidget(self._length, 1) sl = QHBoxLayout() sl.setContentsMargins(0, 0, 0, 0) sl.setSpacing(2) sl.addWidget(QLabel('Show lines'), 0) sl.addWidget(self._spacing_style, 3) sl.addWidget(QLabel('when spacing is ≥:'), 0) sl.addWidget(self._spacing_value, 1) ol = QHBoxLayout() ol.setContentsMargins(0, 0, 0, 0) ol.setSpacing(2) ol.addWidget(QLabel('Grid offset:'), 0) ol.addWidget(self._offset, 1) v = QVBoxLayout() v.setContentsMargins(0, 0, 0, 0) v.setSpacing(2) v.addLayout(nl) v.addLayout(ll) v.addLayout(sl) v.addLayout(ol) self.setLayout(v) def _on_setup(self): self.register_action('signal_grid_pattern_selection', self._update_all) self.register_action('signal_grid_pattern_modified', self._update_all) self.register_action('signal_style_changed', self._update_style) self._update_config() self._name.textEdited.connect(self._change_name) self._length.valueChanged.connect(self._change_length) self._spacing_style.currentIndexChanged.connect( self._select_spacing_style) self._spacing_value.valueChanged.connect(self._change_spacing) self._offset.valueChanged.connect(self._change_offset) self._update_all() def _update_style(self): self._update_config() style_mgr = self._ui_model.get_style_manager() for vps in (self._length, self._spacing_value, self._offset): vps.update_style(style_mgr) self.update() def _update_config(self): style_mgr = self._ui_model.get_style_manager() config = DEFAULT_CONFIG.copy() custom_config = get_config_with_custom_style(style_mgr) config.update(custom_config) layout = self.layout() spacing = style_mgr.get_scaled_size_param('small_padding') for i in range(layout.count()): sub_layout = layout.itemAt(i).layout() if sub_layout: sub_layout.setSpacing(spacing) self._spacing_style.set_config(config, style_mgr) def _get_selected_grid_pattern(self): grid_mgr = self._ui_model.get_grid_manager() gp_id = grid_mgr.get_selected_grid_pattern_id() if gp_id == None: return None gp = grid_mgr.get_grid_pattern(gp_id) return gp def _update_all(self): gp = self._get_selected_grid_pattern() self.setEnabled(gp != None) if gp == None: return gp_name = gp.get_name() if gp_name != str(self._name.text()): old_block = self._name.blockSignals(True) self._name.setText(gp_name) self._name.blockSignals(old_block) gp_length = gp.get_length() gp_length_f = float(gp_length) if gp_length_f != self._length.value(): old_block = self._length.blockSignals(True) self._length.setValue(gp_length_f) self._length.blockSignals(old_block) spacing_value = gp.get_line_style_spacing( self._spacing_style.get_current_line_style()) if spacing_value != self._spacing_value.value(): old_block = self._spacing_value.blockSignals(True) self._spacing_value.setValue(spacing_value) self._spacing_value.blockSignals(old_block) gp_offset = gp.get_offset() gp_offset_f = float(gp_offset) if gp_offset_f != self._offset.value(): old_block = self._offset.blockSignals(True) self._offset.setValue(gp_offset_f) self._offset.blockSignals(old_block) def _change_name(self, text): text = str(text) gp = self._get_selected_grid_pattern() if gp == None: return gp.set_name(text) self._updater.signal_update('signal_grid_pattern_modified', 'signal_grid_pattern_list') def _change_length(self, new_length): new_length_ts = tstamp.Tstamp(new_length) gp = self._get_selected_grid_pattern() if gp == None: return gp.set_length(new_length_ts) self._updater.signal_update('signal_grid_pattern_modified') def _select_spacing_style(self, new_style): self._spacing_style.select_line_style(new_style) self._update_all() def _change_spacing(self, new_spacing): gp = self._get_selected_grid_pattern() if gp == None: return line_style = self._spacing_style.get_current_line_style() gp.set_line_style_spacing(line_style, new_spacing) self._updater.signal_update('signal_grid_pattern_modified') def _change_offset(self, new_offset): new_offset_ts = tstamp.Tstamp(new_offset) gp = self._get_selected_grid_pattern() if gp == None: return gp.set_offset(new_offset_ts) self._updater.signal_update('signal_grid_pattern_modified')
class InitStateEditor(QWidget, ProcessorUpdater): def __init__(self): super().__init__() self._init_val = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._init_val.setMinimum(-99999) self._init_val.setMaximum(99999) self._osc_speed = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_speed.setMinimum(0) self._osc_speed.setMaximum(1000) self._osc_depth = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_depth.setMinimum(0) self._osc_depth.setMaximum(99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(10) h.addWidget(QLabel('Initial value:'), 0) h.addWidget(self._init_val, 1) h.addWidget(QLabel('Initial oscillation speed:'), 0) h.addWidget(self._osc_speed, 1) h.addWidget(QLabel('Initial oscillation depth:'), 0) h.addWidget(self._osc_depth, 1) self.setLayout(h) def _on_setup(self): self.register_action(self._get_update_signal_type(), self._update_state) self.register_action('signal_style_changed', self._update_style) self._init_val.valueChanged.connect(self._set_init_value) self._osc_speed.valueChanged.connect(self._set_osc_speed) self._osc_depth.valueChanged.connect(self._set_osc_depth) self._update_style() self._update_state() def _get_update_signal_type(self): return 'signal_stream_init_state_{}'.format(self._proc_id) def _get_stream_params(self): module = self._ui_model.get_module() au = module.get_audio_unit(self._au_id) proc = au.get_processor(self._proc_id) stream_params = proc.get_type_params() return stream_params def _update_style(self): style_mgr = self._ui_model.get_style_manager() for vps in (self._init_val, self._osc_speed, self._osc_depth): vps.update_style(style_mgr) self.layout().setSpacing(style_mgr.get_scaled_size_param('large_padding')) def _update_state(self): stream_params = self._get_stream_params() init_value = stream_params.get_init_value() if init_value != self._init_val.value(): old_block = self._init_val.blockSignals(True) self._init_val.setValue(init_value) self._init_val.blockSignals(old_block) osc_speed = stream_params.get_init_osc_speed() if osc_speed != self._osc_speed.value(): old_block = self._osc_speed.blockSignals(True) self._osc_speed.setValue(osc_speed) self._osc_speed.blockSignals(old_block) osc_depth = stream_params.get_init_osc_depth() if osc_depth != self._osc_depth.value(): old_block = self._osc_depth.blockSignals(True) self._osc_depth.setValue(osc_depth) self._osc_depth.blockSignals(old_block) def _set_init_value(self, value): stream_params = self._get_stream_params() stream_params.set_init_value(value) self._updater.signal_update(self._get_update_signal_type()) def _set_osc_speed(self, value): stream_params = self._get_stream_params() stream_params.set_init_osc_speed(value) self._updater.signal_update(self._get_update_signal_type()) def _set_osc_depth(self, value): stream_params = self._get_stream_params() stream_params.set_init_osc_depth(value) self._updater.signal_update(self._get_update_signal_type())
class TriggerImpulseBounds(QWidget, ProcessorUpdater): def __init__(self): super().__init__() self._start_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._stop_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._start_value.setRange(-99999, 99999) self._stop_value.setRange(-99999, 99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(8) h.addWidget(QLabel('Start value:')) h.addWidget(self._start_value, 1) h.addWidget(QLabel('Stop value:')) h.addWidget(self._stop_value, 1) self.setLayout(h) def _get_update_signal_type(self): return 'signal_env_trig_{}'.format(self._proc_id) def _on_setup(self): self.register_action(self._get_update_signal_type(), self._update_all) self.register_action('signal_style_changed', self._update_style) self._start_value.editingFinished.connect(self._change_start) self._stop_value.editingFinished.connect(self._change_stop) self._update_style() self._update_all() def _get_egen_params(self): return utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) def _update_style(self): style_mgr = self._ui_model.get_style_manager() self._start_value.update_style(style_mgr) self._stop_value.update_style(style_mgr) self.layout().setSpacing(style_mgr.get_scaled_size_param('medium_padding')) def _update_all(self): self._update_enabled() self._update_bounds() def _try_update_bounds(self, bounds): def try_update(sb, value): if value != sb.value(): old_block = sb.blockSignals(True) sb.setValue(value) sb.blockSignals(old_block) try_update(self._start_value, bounds[0]) try_update(self._stop_value, bounds[1]) # Protected callbacks def _update_enabled(self): raise NotImplementedError def _update_bounds(self): raise NotImplementedError def _change_start(self): raise NotImplementedError def _change_stop(self): raise NotImplementedError
class RangeEditor(QWidget, ProcessorUpdater): def __init__(self): super().__init__() self._min_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._min_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) for editor in (self._min_editor, self._max_editor): editor.setMinimum(-99999) editor.setMaximum(99999) for editor in (self._min_var_editor, self._max_var_editor): editor.setMinimum(0) editor.setMaximum(99999) d = QHBoxLayout() d.setContentsMargins(0, 0, 0, 0) d.setSpacing(4) d.addWidget(QLabel('Minimum value:')) d.addWidget(self._min_editor) d.addWidget(QLabel('±')) d.addWidget(self._min_var_editor) d.addWidget(QLabel('Maximum value:')) d.addWidget(self._max_editor) self._disableables = d h = QHBoxLayout() h.setContentsMargins(10, 0, 10, 0) h.setSpacing(4) h.addLayout(self._disableables) h.addWidget(QLabel('±')) h.addWidget(self._max_var_editor) h.addStretch(1) self.setLayout(h) def _on_setup(self): self.register_action(self._get_update_signal_type(), self._update_range_params) self.register_action(self._get_linear_force_signal_type(), self._update_force_type) self._min_editor.editingFinished.connect(self._set_range_min) self._min_var_editor.valueChanged.connect(self._set_range_min_var) self._max_editor.editingFinished.connect(self._set_range_max) self._max_var_editor.valueChanged.connect(self._set_range_max_var) self._update_range_params() self._update_force_type() def _get_update_signal_type(self): return '_'.join(('signal_env_range', self._proc_id)) def _get_linear_force_signal_type(self): return 'signal_egen_linear_force_{}'.format(self._proc_id) def _update_range_params(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) y_range = egen_params.get_y_range() min_var = egen_params.get_y_range_min_var() max_var = egen_params.get_y_range_max_var() def try_update(sb, value): if value != sb.value(): old_block = sb.blockSignals(True) sb.setValue(value) sb.blockSignals(old_block) try_update(self._min_editor, y_range[0]) try_update(self._max_editor, y_range[1]) try_update(self._min_var_editor, min_var) try_update(self._max_var_editor, max_var) def _update_force_type(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) lf_enabled = egen_params.get_linear_force_enabled() for i in range(self._disableables.count()): self._disableables.itemAt(i).widget().setEnabled(not lf_enabled) def _set_range_min(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) y_range = egen_params.get_y_range() y_range[0] = self._min_editor.value() y_range[1] = max(y_range) egen_params.set_y_range(y_range) self._updater.signal_update(self._get_update_signal_type()) def _set_range_min_var(self, value): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) egen_params.set_y_range_min_var(value) self._updater.signal_update(self._get_update_signal_type()) def _set_range_max(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) y_range = egen_params.get_y_range() y_range[1] = self._max_editor.value() y_range[0] = min(y_range) egen_params.set_y_range(y_range) self._updater.signal_update(self._get_update_signal_type()) def _set_range_max_var(self, value): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) egen_params.set_y_range_max_var(value) self._updater.signal_update(self._get_update_signal_type())
class LengthEditor(QWidget, Updater): def __init__(self): super().__init__() self._is_latest_committed = True self._spinbox = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._spinbox.setMinimum(0) self._spinbox.setMaximum(1024) h = QHBoxLayout() h.setContentsMargins(5, 0, 5, 0) h.setSpacing(5) h.addWidget(QLabel('Pattern length')) h.addWidget(self._spinbox) self.setLayout(h) def _on_setup(self): self.register_action('signal_module', self._update_value) self.register_action('signal_pattern_length', self._update_value) self.register_action('signal_selection', self._update_value) self.register_action('signal_order_list', self._update_value) self.register_action('signal_sheet_undo', self._update_value) self.register_action('signal_sheet_redo', self._update_value) self._update_value() self._spinbox.valueChanged.connect(self._change_length) self._spinbox.editingFinished.connect(self._change_length_final) def _get_pattern(self): module = self._ui_model.get_module() album = module.get_album() if not album.get_existence(): return None selection = self._ui_model.get_selection() location = selection.get_location() song = album.get_song_by_track(location.get_track()) pinst = song.get_pattern_instance(location.get_system()) pattern = pinst.get_pattern() return pattern def _update_value(self): pattern = self._get_pattern() if not pattern: self.setEnabled(False) old_block = self._spinbox.blockSignals(True) self._spinbox.setValue(0) self._spinbox.blockSignals(old_block) return length = pattern.get_length() length_val = float(length) self.setEnabled(True) old_block = self._spinbox.blockSignals(True) if length_val != self._spinbox.value(): self._spinbox.setValue(length_val) self._spinbox.blockSignals(old_block) def _change_value(self, new_value, is_final): pattern = self._get_pattern() if not pattern: return sheet_mgr = self._ui_model.get_sheet_manager() length = tstamp.Tstamp(new_value) if length == pattern.get_length(): if is_final and not self._is_latest_committed: sheet_mgr.set_pattern_length(pattern, length, is_final) self._is_latest_committed = True return sheet_mgr.set_pattern_length(pattern, length, is_final) self._updater.signal_update('signal_pattern_length') def _change_length(self, new_value): self._is_latest_committed = False self._change_value(new_value, is_final=False) def _change_length_final(self): new_value = self._spinbox.value() self._change_value(new_value, is_final=True)
class InitStateEditor(QWidget, ProcessorUpdater): def __init__(self): super().__init__() self._init_val = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._init_val.setMinimum(-99999) self._init_val.setMaximum(99999) self._osc_speed = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_speed.setMinimum(0) self._osc_speed.setMaximum(1000) self._osc_depth = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._osc_depth.setMinimum(0) self._osc_depth.setMaximum(99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(10) h.addWidget(QLabel('Initial value:'), 0) h.addWidget(self._init_val, 1) h.addWidget(QLabel('Initial oscillation speed:'), 0) h.addWidget(self._osc_speed, 1) h.addWidget(QLabel('Initial oscillation depth:'), 0) h.addWidget(self._osc_depth, 1) self.setLayout(h) def _on_setup(self): self.register_action(self._get_update_signal_type(), self._update_state) self._init_val.valueChanged.connect(self._set_init_value) self._osc_speed.valueChanged.connect(self._set_osc_speed) self._osc_depth.valueChanged.connect(self._set_osc_depth) self._update_state() def _get_update_signal_type(self): return 'signal_stream_init_state_{}'.format(self._proc_id) def _get_stream_params(self): module = self._ui_model.get_module() au = module.get_audio_unit(self._au_id) proc = au.get_processor(self._proc_id) stream_params = proc.get_type_params() return stream_params def _update_state(self): stream_params = self._get_stream_params() init_value = stream_params.get_init_value() if init_value != self._init_val.value(): old_block = self._init_val.blockSignals(True) self._init_val.setValue(init_value) self._init_val.blockSignals(old_block) osc_speed = stream_params.get_init_osc_speed() if osc_speed != self._osc_speed.value(): old_block = self._osc_speed.blockSignals(True) self._osc_speed.setValue(osc_speed) self._osc_speed.blockSignals(old_block) osc_depth = stream_params.get_init_osc_depth() if osc_depth != self._osc_depth.value(): old_block = self._osc_depth.blockSignals(True) self._osc_depth.setValue(osc_depth) self._osc_depth.blockSignals(old_block) def _set_init_value(self, value): stream_params = self._get_stream_params() stream_params.set_init_value(value) self._updater.signal_update(self._get_update_signal_type()) def _set_osc_speed(self, value): stream_params = self._get_stream_params() stream_params.set_init_osc_speed(value) self._updater.signal_update(self._get_update_signal_type()) def _set_osc_depth(self, value): stream_params = self._get_stream_params() stream_params.set_init_osc_depth(value) self._updater.signal_update(self._get_update_signal_type())
class TriggerImpulseBounds(QWidget, ProcessorUpdater): def __init__(self): super().__init__() self._start_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._stop_value = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._start_value.setRange(-99999, 99999) self._stop_value.setRange(-99999, 99999) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.setSpacing(8) h.addWidget(QLabel('Start value:')) h.addWidget(self._start_value, 1) h.addWidget(QLabel('Stop value:')) h.addWidget(self._stop_value, 1) self.setLayout(h) def _get_update_signal_type(self): return 'signal_env_trig_{}'.format(self._proc_id) def _on_setup(self): self.register_action(self._get_update_signal_type(), self._update_all) self._start_value.editingFinished.connect(self._change_start) self._stop_value.editingFinished.connect(self._change_stop) self._update_all() def _get_egen_params(self): return utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) def _update_all(self): self._update_enabled() self._update_bounds() def _try_update_bounds(self, bounds): def try_update(sb, value): if value != sb.value(): old_block = sb.blockSignals(True) sb.setValue(value) sb.blockSignals(old_block) try_update(self._start_value, bounds[0]) try_update(self._stop_value, bounds[1]) # Protected callbacks def _update_enabled(self): raise NotImplementedError def _update_bounds(self): raise NotImplementedError def _change_start(self): raise NotImplementedError def _change_stop(self): raise NotImplementedError
class TonePitchSpin(QWidget, ProcessorUpdater): def __init__(self, index): super().__init__() self._index = index self._spin = VarPrecSpinBox(step_decimals=0, max_decimals=6) self._spin.setMinimum(0.000001) self._spin.setMaximum(1024.0) self._spin.setValue(1) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) h.addWidget(QLabel('Pitch factor:')) h.addWidget(self._spin) self.setLayout(h) def _on_setup(self): self.register_action('signal_au', self._update_value) self.register_action(self._get_update_signal_type(), self._update_value) self._update_value() self._spin.valueChanged.connect(self._value_changed) self.register_action('signal_style_changed', self._update_style) self._update_style() def _update_style(self): style_mgr = self._ui_model.get_style_manager() self._spin.update_style(style_mgr) self.layout().setSpacing( style_mgr.get_scaled_size_param('small_padding')) def _get_update_signal_type(self): return ''.join(('signal_proc_add_tone_', self._au_id, self._proc_id)) def _update_value(self): add_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) if self._index >= add_params.get_tone_count(): # We have been removed return old_block = self._spin.blockSignals(True) new_pitch = add_params.get_tone_pitch(self._index) if new_pitch != self._spin.value(): self._spin.setValue(new_pitch) self._spin.blockSignals(old_block) def _value_changed(self, pitch): add_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) add_params.set_tone_pitch(self._index, pitch) self._updater.signal_update(self._get_update_signal_type())
class RangeEditor(QWidget, ProcessorUpdater): def __init__(self): super().__init__() self._min_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._min_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) self._max_var_editor = VarPrecSpinBox(step_decimals=0, max_decimals=3) for editor in (self._min_editor, self._max_editor): editor.setMinimum(-99999) editor.setMaximum(99999) for editor in (self._min_var_editor, self._max_var_editor): editor.setMinimum(0) editor.setMaximum(99999) d = QHBoxLayout() d.setContentsMargins(0, 0, 0, 0) d.setSpacing(4) d.addWidget(QLabel('Minimum value:')) d.addWidget(self._min_editor) d.addWidget(QLabel('±')) d.addWidget(self._min_var_editor) d.addWidget(QLabel('Maximum value:')) d.addWidget(self._max_editor) self._disableables = d h = QHBoxLayout() h.setContentsMargins(10, 0, 10, 0) h.setSpacing(4) h.addLayout(self._disableables) h.addWidget(QLabel('±')) h.addWidget(self._max_var_editor) h.addStretch(1) self.setLayout(h) def _on_setup(self): self.register_action(self._get_update_signal_type(), self._update_range_params) self.register_action( self._get_linear_force_signal_type(), self._update_force_type) self.register_action('signal_style_changed', self._update_style) self._min_editor.editingFinished.connect(self._set_range_min) self._min_var_editor.valueChanged.connect(self._set_range_min_var) self._max_editor.editingFinished.connect(self._set_range_max) self._max_var_editor.valueChanged.connect(self._set_range_max_var) self._update_style() self._update_range_params() self._update_force_type() def _get_update_signal_type(self): return '_'.join(('signal_env_range', self._proc_id)) def _get_linear_force_signal_type(self): return 'signal_egen_linear_force_{}'.format(self._proc_id) def _update_style(self): style_mgr = self._ui_model.get_style_manager() spinboxes = (self._min_editor, self._max_editor, self._min_var_editor, self._max_var_editor) for vps in spinboxes: vps.update_style(style_mgr) self._disableables.setSpacing(style_mgr.get_scaled_size_param('medium_padding')) margin_x = style_mgr.get_scaled_size_param('large_padding') self.layout().setContentsMargins(margin_x, 0, margin_x, 0) self.layout().setSpacing(style_mgr.get_scaled_size_param('medium_padding')) def _update_range_params(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) y_range = egen_params.get_y_range() min_var = egen_params.get_y_range_min_var() max_var = egen_params.get_y_range_max_var() def try_update(sb, value): if value != sb.value(): old_block = sb.blockSignals(True) sb.setValue(value) sb.blockSignals(old_block) try_update(self._min_editor, y_range[0]) try_update(self._max_editor, y_range[1]) try_update(self._min_var_editor, min_var) try_update(self._max_var_editor, max_var) def _update_force_type(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) lf_enabled = egen_params.get_linear_force_enabled() for i in range(self._disableables.count()): self._disableables.itemAt(i).widget().setEnabled(not lf_enabled) def _set_range_min(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) y_range = egen_params.get_y_range() y_range[0] = self._min_editor.value() y_range[1] = max(y_range) egen_params.set_y_range(y_range) self._updater.signal_update(self._get_update_signal_type()) def _set_range_min_var(self, value): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) egen_params.set_y_range_min_var(value) self._updater.signal_update(self._get_update_signal_type()) def _set_range_max(self): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) y_range = egen_params.get_y_range() y_range[1] = self._max_editor.value() y_range[0] = min(y_range) egen_params.set_y_range(y_range) self._updater.signal_update(self._get_update_signal_type()) def _set_range_max_var(self, value): egen_params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) egen_params.set_y_range_max_var(value) self._updater.signal_update(self._get_update_signal_type())
class GeneralEditor(QWidget, Updater): def __init__(self): super().__init__() self._name = QLineEdit() self._length = VarPrecSpinBox(step_decimals=0, max_decimals=5) self._length.setMinimum(1) self._length.setMaximum(32) self._spacing_style = LineStyle(is_major_enabled=True) self._spacing_value = VarPrecSpinBox(step_decimals=1, max_decimals=2) self._spacing_value.setMinimum(0.01) self._spacing_value.setMaximum(1.0) self._offset = VarPrecSpinBox(step_decimals=1, max_decimals=5) self._offset.setMinimum(0) self._offset.setMaximum(32) nl = QHBoxLayout() nl.setContentsMargins(0, 0, 0, 0) nl.setSpacing(2) nl.addWidget(QLabel('Name:'), 0) nl.addWidget(self._name, 1) ll = QHBoxLayout() ll.setContentsMargins(0, 0, 0, 0) ll.setSpacing(2) ll.addWidget(QLabel('Grid length:'), 0) ll.addWidget(self._length, 1) sl = QHBoxLayout() sl.setContentsMargins(0, 0, 0, 0) sl.setSpacing(2) sl.addWidget(QLabel('Show lines'), 0) sl.addWidget(self._spacing_style, 3) sl.addWidget(QLabel('when spacing is ≥:'), 0) sl.addWidget(self._spacing_value, 1) ol = QHBoxLayout() ol.setContentsMargins(0, 0, 0, 0) ol.setSpacing(2) ol.addWidget(QLabel('Grid offset:'), 0) ol.addWidget(self._offset, 1) v = QVBoxLayout() v.setContentsMargins(0, 0, 0, 0) v.setSpacing(2) v.addLayout(nl) v.addLayout(ll) v.addLayout(sl) v.addLayout(ol) self.setLayout(v) def _on_setup(self): self.register_action('signal_grid_pattern_selection', self._update_all) self.register_action('signal_grid_pattern_modified', self._update_all) self.register_action('signal_style_changed', self._update_style) self._update_config() self._name.textEdited.connect(self._change_name) self._length.valueChanged.connect(self._change_length) self._spacing_style.currentIndexChanged.connect(self._select_spacing_style) self._spacing_value.valueChanged.connect(self._change_spacing) self._offset.valueChanged.connect(self._change_offset) self._update_all() def _update_style(self): self._update_config() style_mgr = self._ui_model.get_style_manager() for vps in (self._length, self._spacing_value, self._offset): vps.update_style(style_mgr) self.update() def _update_config(self): style_mgr = self._ui_model.get_style_manager() config = DEFAULT_CONFIG.copy() custom_config = get_config_with_custom_style(style_mgr) config.update(custom_config) layout = self.layout() spacing = style_mgr.get_scaled_size_param('small_padding') for i in range(layout.count()): sub_layout = layout.itemAt(i).layout() if sub_layout: sub_layout.setSpacing(spacing) self._spacing_style.set_config(config, style_mgr) def _get_selected_grid_pattern(self): grid_mgr = self._ui_model.get_grid_manager() gp_id = grid_mgr.get_selected_grid_pattern_id() if gp_id == None: return None gp = grid_mgr.get_grid_pattern(gp_id) return gp def _update_all(self): gp = self._get_selected_grid_pattern() self.setEnabled(gp != None) if gp == None: return gp_name = gp.get_name() if gp_name != str(self._name.text()): old_block = self._name.blockSignals(True) self._name.setText(gp_name) self._name.blockSignals(old_block) gp_length = gp.get_length() gp_length_f = float(gp_length) if gp_length_f != self._length.value(): old_block = self._length.blockSignals(True) self._length.setValue(gp_length_f) self._length.blockSignals(old_block) spacing_value = gp.get_line_style_spacing( self._spacing_style.get_current_line_style()) if spacing_value != self._spacing_value.value(): old_block = self._spacing_value.blockSignals(True) self._spacing_value.setValue(spacing_value) self._spacing_value.blockSignals(old_block) gp_offset = gp.get_offset() gp_offset_f = float(gp_offset) if gp_offset_f != self._offset.value(): old_block = self._offset.blockSignals(True) self._offset.setValue(gp_offset_f) self._offset.blockSignals(old_block) def _change_name(self, text): text = str(text) gp = self._get_selected_grid_pattern() if gp == None: return gp.set_name(text) self._updater.signal_update( 'signal_grid_pattern_modified', 'signal_grid_pattern_list') def _change_length(self, new_length): new_length_ts = tstamp.Tstamp(new_length) gp = self._get_selected_grid_pattern() if gp == None: return gp.set_length(new_length_ts) self._updater.signal_update('signal_grid_pattern_modified') def _select_spacing_style(self, new_style): self._spacing_style.select_line_style(new_style) self._update_all() def _change_spacing(self, new_spacing): gp = self._get_selected_grid_pattern() if gp == None: return line_style = self._spacing_style.get_current_line_style() gp.set_line_style_spacing(line_style, new_spacing) self._updater.signal_update('signal_grid_pattern_modified') def _change_offset(self, new_offset): new_offset_ts = tstamp.Tstamp(new_offset) gp = self._get_selected_grid_pattern() if gp == None: return gp.set_offset(new_offset_ts) self._updater.signal_update('signal_grid_pattern_modified')