Beispiel #1
0
    def __on_project_nodes_changed(self,
                                   change: model_base.PropertyChange) -> None:
        if isinstance(change, model_base.PropertyListInsert):
            messages = audioproc.ProcessorMessageList()
            messages.messages.extend(self.add_node(change.new_value))
            self.send_node_messages(messages)

        elif isinstance(change, model_base.PropertyListDelete):
            self.remove_node(change.old_value)

        elif isinstance(change, model_base.PropertyListMove):
            pass

        else:
            raise TypeError("Unsupported change type %s" % type(change))
Beispiel #2
0
    async def setup(self) -> None:
        logger.info("Setting up player instance %s..", self.id)

        if self.callback_address is not None:
            logger.info("Connecting to client callback server %s..",
                        self.callback_address)
            self.callback_stub = ipc.Stub(self.event_loop,
                                          self.callback_address)
            await self.callback_stub.connect()

        self.__listeners[
            'pipeline_mutations'] = self.project.pipeline_mutation.add(
                self.handle_pipeline_mutation)

        logger.info("Populating realm with project state...")
        for mutation in self.project.get_add_mutations():
            await self.publish_pipeline_mutation(mutation)

        await self.audioproc_client.update_project_properties(
            self.realm,
            audioproc.ProjectProperties(
                bpm=self.project.bpm,
                duration=self.project.duration.to_proto()))

        messages = audioproc.ProcessorMessageList()
        for node in self.project.nodes:
            messages.messages.extend(self.add_node(node))
        await self.audioproc_client.send_node_messages(self.realm, messages)

        await self.set_session_values(self.session_values.values())
        self.__listeners[
            'session_values'] = self.session_values.values_changed.add(
                self.set_session_values)

        self.__listeners['project:nodes'] = self.project.nodes_changed.add(
            self.__on_project_nodes_changed)
        self.__listeners['project:bpm'] = self.project.bpm_changed.add(
            self.__on_project_bpm_changed)
        self.__listeners[
            'project:duration'] = self.project.duration_changed.add(
                self.__on_project_duration_changed)

        logger.info("Player instance %s setup complete.", self.id)
Beispiel #3
0
 async def sendNodeMessage(self, msg: audioproc.ProcessorMessage) -> None:
     await self.audioproc_client.send_node_messages(
         self.__player_realm, audioproc.ProcessorMessageList(messages=[msg]))
Beispiel #4
0
 def send_node_message(self, msg: audioproc.ProcessorMessage) -> None:
     messages = audioproc.ProcessorMessageList()
     messages.messages.extend([msg])
     self.event_loop.create_task(self.__send_node_messages_async(messages))