def get_initial_parameter_mutations(self) -> Iterator[audioproc.Mutation]: for cv in self.control_values: yield audioproc.Mutation( set_control_value=audioproc.SetControlValue( name='%s:%s' % (self.pipeline_node_id, cv.name), value=cv.value, generation=cv.generation)) for port in self.description.ports: yield audioproc.Mutation( set_node_port_properties=audioproc.SetNodePortProperties( node_id=self.pipeline_node_id, port_properties=self.get_port_properties(port.name).to_proto()))
def get_remove_mutations(self) -> Iterator[audioproc.Mutation]: yield audioproc.Mutation( disconnect_ports=audioproc.DisconnectPorts( src_node_id=self.source_node.pipeline_node_id, src_port=self.source_port, dest_node_id=self.dest_node.pipeline_node_id, dest_port=self.dest_port))
def get_add_mutations(self) -> Iterator[audioproc.Mutation]: yield audioproc.Mutation( connect_ports=audioproc.ConnectPorts( src_node_id=self.source_node.pipeline_node_id, src_port=self.source_port, dest_node_id=self.dest_node.pipeline_node_id, dest_port=self.dest_port, type=self.type))
def __get_spec_mutation(self) -> audioproc.Mutation: params = audioproc.NodeParameters() spec = params.Extensions[processor_pb2.oscilloscope_spec] spec.foo = 1 return audioproc.Mutation( set_node_parameters=audioproc.SetNodeParameters( node_id=self.pipeline_node_id, parameters=params))
def set_plugin_state(self, plugin_state: audioproc.PluginState) -> None: self.plugin_state = plugin_state if self.attached_to_project: self.project.handle_pipeline_mutation( audioproc.Mutation( set_plugin_state=audioproc.SetPluginState( node_id=self.pipeline_node_id, state=plugin_state)))
def get_add_mutations(self) -> Iterator[audioproc.Mutation]: yield audioproc.Mutation( add_node=audioproc.AddNode( description=self.description, id=self.pipeline_node_id, name=self.name, initial_state=self.plugin_state)) yield from self.get_initial_parameter_mutations()
def __get_spec_mutation(self) -> audioproc.Mutation: params = audioproc.NodeParameters() spec = params.Extensions[processor_pb2.cv_mapper_spec] spec.transfer_function.CopyFrom(self.transfer_function.get_function_spec()) return audioproc.Mutation( set_node_parameters=audioproc.SetNodeParameters( node_id=self.pipeline_node_id, parameters=params))
def __get_code_mutation(self) -> audioproc.Mutation: params = audioproc.NodeParameters() csound_params = params.Extensions[ processor_pb2.custom_csound_parameters] csound_params.orchestra = self.full_orchestra csound_params.score = self.score or '' return audioproc.Mutation( set_node_parameters=audioproc.SetNodeParameters( node_id=self.pipeline_node_id, parameters=params))
def __get_spec_mutation(self) -> audioproc.Mutation: params = audioproc.NodeParameters() spec = params.Extensions[processor_pb2.metronome_spec] spec.sample_path = self.sample_path spec.duration.numerator = 1 spec.duration.denominator = 4 return audioproc.Mutation( set_node_parameters=audioproc.SetNodeParameters( node_id=self.pipeline_node_id, parameters=params))
def __get_spec_mutation(self) -> audioproc.Mutation: params = audioproc.NodeParameters() spec = params.Extensions[processor_pb2.midi_looper_spec] spec.duration.CopyFrom(self.duration.to_proto()) for event in self.patches[0].events: pb_event = spec.events.add() pb_event.CopyFrom(event.to_proto()) return audioproc.Mutation( set_node_parameters=audioproc.SetNodeParameters( node_id=self.pipeline_node_id, parameters=params))
def __get_spec_mutation(self) -> audioproc.Mutation: params = audioproc.NodeParameters() spec = params.Extensions[processor_pb2.midi_cc_to_cv_spec] for channel_idx, channel in enumerate(self.channels): channel_spec = spec.channels.add() channel_spec.midi_channel = channel.midi_channel channel_spec.midi_controller = channel.midi_controller channel_spec.initial_value = self.__controller_values.get( channel_idx, 0) channel_spec.min_value = channel.min_value channel_spec.max_value = channel.max_value channel_spec.log_scale = channel.log_scale return audioproc.Mutation( set_node_parameters=audioproc.SetNodeParameters( node_id=self.pipeline_node_id, parameters=params))
def set_port_properties(self, port_properties: value_types.NodePortProperties) -> None: assert any(port_desc.name == port_properties.name for port_desc in self.description.ports) new_props = None # type: audioproc.NodePortProperties for idx, props in enumerate(self.port_properties): if props.name == port_properties.name: new_props = props.to_proto() new_props.MergeFrom(port_properties.to_proto()) self.port_properties[idx] = value_types.NodePortProperties.from_proto(new_props) break else: new_props = port_properties.to_proto() self.port_properties.append(port_properties) if self.attached_to_project: self.project.handle_pipeline_mutation( audioproc.Mutation( set_node_port_properties=audioproc.SetNodePortProperties( node_id=self.pipeline_node_id, port_properties=new_props)))
def __get_spec_mutation(self) -> audioproc.Mutation: params = audioproc.NodeParameters() spec = params.Extensions[processor_pb2.step_sequencer_spec] spec.num_steps = self.num_steps spec.time_synched = self.time_synched for channel in self.channels: channel_spec = spec.channels.add() channel_spec.type = channel.type for step in channel.steps[:self.num_steps]: if channel.type in (model_pb2.StepSequencerChannel.GATE, model_pb2.StepSequencerChannel.TRIGGER): channel_spec.step_enabled.append(step.enabled) else: assert channel.type == model_pb2.StepSequencerChannel.VALUE channel_spec.step_value.append( step.value * (channel.max_value - channel.min_value) + channel.min_value) return audioproc.Mutation( set_node_parameters=audioproc.SetNodeParameters( node_id=self.pipeline_node_id, parameters=params))
def set_control_value(self, name: str, value: float, generation: int = None) -> None: for idx, control_value in enumerate(self.control_values): if control_value.name == name: if generation is None: generation = control_value.generation + 1 elif generation < control_value.generation: return self.control_values[idx] = value_types.ControlValue( name=name, value=value, generation=generation) break else: if generation is None: generation = 2 self.control_values.append(value_types.ControlValue( name=name, value=value, generation=generation)) if self.attached_to_project: self.project.handle_pipeline_mutation( audioproc.Mutation( set_control_value=audioproc.SetControlValue( name='%s:%s' % (self.pipeline_node_id, name), value=value, generation=generation)))
def __description_changed(self, change: model_base.PropertyChange) -> None: if self.attached_to_project: self.project.handle_pipeline_mutation(audioproc.Mutation( set_node_description=audioproc.SetNodeDescription( node_id=self.pipeline_node_id, description=self.description)))
def get_remove_mutations(self) -> Iterator[audioproc.Mutation]: yield audioproc.Mutation( remove_node=audioproc.RemoveNode(id=self.pipeline_node_id))