Esempio n. 1
0
 def _allocate_buffer_id(self):
     if self.buffer_id is None:
         buffer_id = self.server.buffer_allocator.allocate(1)
         if buffer_id is None:
             ServerObjectProxy.free(self)
             raise ValueError
         self._buffer_id = buffer_id
Esempio n. 2
0
 def free(self):
     import supriya.commands
     synthdef_name = self.actual_name
     del (self.server._synthdefs[synthdef_name])
     request = supriya.commands.SynthDefFreeRequest(synthdef=self, )
     if self.server.is_running:
         request.communicate(server=self.server)
     ServerObjectProxy.free(self)
Esempio n. 3
0
 def free(self):
     if not self.is_allocated:
         raise supriya.exceptions.BusNotAllocated
     if not self._bus_id_was_set_manually:
         allocator = self._get_allocator(
             calculation_rate=self.calculation_rate, server=self.server)
         allocator.free(self.bus_id)
     self._bus_id = None
     ServerObjectProxy.free(self)
     return self
Esempio n. 4
0
 def free(self):
     import supriya.realtime
     if not self.is_allocated:
         return
     allocator = supriya.realtime.Bus._get_allocator(
         calculation_rate=self.calculation_rate,
         server=self.server,
         )
     allocator.free(self.bus_id)
     self._bus_id = None
     ServerObjectProxy.free(self)
Esempio n. 5
0
 def _register_with_local_server(self, server):
     ServerObjectProxy.allocate(self, server=server)
     allocator = self.server.buffer_allocator
     buffer_id = allocator.allocate(len(self))
     if buffer_id is None:
         ServerObjectProxy.free(self)
         raise ValueError
     self._buffer_id = buffer_id
     for buffer_ in self:
         buffer_._register_with_local_server()
     return buffer_id
Esempio n. 6
0
 def free(self):
     if not self.is_allocated:
         return
     if not self._bus_id_was_set_manually:
         allocator = self._get_allocator(
             calculation_rate=self.calculation_rate,
             server=self.server,
         )
         allocator.free(self.bus_id)
     self._bus_id = None
     ServerObjectProxy.free(self)
Esempio n. 7
0
 def _unregister_with_local_server(self):
     node_id = self.node_id
     if self.server is not None:
         if self._node_id in self._server._nodes:
             del (self._server._nodes[self._node_id])
         if self.node_id_is_permanent:
             self.server.node_id_allocator.free_permanent_node_id(
                 self.node_id, )
     self._node_id = None
     self._node_id_is_permanent = None
     ServerObjectProxy.free(self)
     return node_id
Esempio n. 8
0
 def free(self) -> 'BufferGroup':
     """
     Frees all buffers in buffer group.
     """
     if not self.is_allocated:
         raise supriya.exceptions.BufferNotAllocated
     for buffer_ in self:
         buffer_.free()
     buffer_id = self.buffer_id
     self._buffer_id = None
     self.server.buffer_allocator.free(buffer_id)
     ServerObjectProxy.free(self)
     return self
Esempio n. 9
0
    def free(self):
        """
        Frees all buffers in buffer group.

        Returns none.
        """
        if not self.is_allocated:
            return
        for buffer_ in self:
            buffer_.free()
        buffer_id = self.buffer_id
        self._buffer_id = None
        self.server.buffer_allocator.free(buffer_id)
        ServerObjectProxy.free(self)
Esempio n. 10
0
    def allocate(self, server=None):
        import supriya.realtime

        if self.is_allocated:
            raise supriya.exceptions.BusAlreadyAllocated
        ServerObjectProxy.allocate(self, server=server)
        allocator = supriya.realtime.Bus._get_allocator(
            calculation_rate=self.calculation_rate, server=self.server)
        bus_id = allocator.allocate(len(self))
        if bus_id is None:
            ServerObjectProxy.free(self)
            raise ValueError
        self._bus_id = bus_id
        return self
Esempio n. 11
0
 def free(self) -> "Buffer":
     """
     Frees buffer.
     """
     if not self.is_allocated:
         raise supriya.exceptions.BufferNotAllocated
     buffer_id = self._unregister_with_local_server()
     request = self._unregister_with_remote_server(buffer_id)
     if self.server.is_running:
         request.communicate(server=self.server, sync=False)
     if not self._buffer_id_was_set_manually:
         self.server.buffer_allocator.free(self.buffer_id)
     self._buffer_id = None
     ServerObjectProxy.free(self)
     return self
Esempio n. 12
0
 def allocate(self, server=None, sync=False):
     if self.bus_group is not None:
         return
     if self.is_allocated:
         raise supriya.exceptions.BusAlreadyAllocated
     ServerObjectProxy.allocate(self, server=server)
     if self.bus_id is None:
         allocator = self._get_allocator(
             calculation_rate=self.calculation_rate, server=self.server)
         bus_id = allocator.allocate(1)
         if bus_id is None:
             ServerObjectProxy.free(self)
             raise ValueError
         self._bus_id = bus_id
     if sync:
         self.server.sync()
     return self
Esempio n. 13
0
    def free(self):
        """
        Frees buffer.

        Returns none.
        """
        if not self.is_allocated:
            return
        buffer_id = self._unregister_with_local_server()
        request = self._unregister_with_remote_server(buffer_id)
        if self.server.is_running:
            request.communicate(
                server=self.server,
                sync=False,
            )
        if not self._buffer_id_was_set_manually:
            self.server.buffer_allocator.free(self.buffer_id)
        self._buffer_id = None
        ServerObjectProxy.free(self)
Esempio n. 14
0
 def allocate(
     self,
     server=None,
     sync=False,
     ):
     import supriya.realtime
     if self.is_allocated:
         return
     ServerObjectProxy.allocate(self, server=server)
     allocator = supriya.realtime.Bus._get_allocator(
         calculation_rate=self.calculation_rate,
         server=self.server,
         )
     bus_id = allocator.allocate(len(self))
     if bus_id is None:
         ServerObjectProxy.free(self)
         raise ValueError
     self._bus_id = bus_id
     if sync:
         self.server.sync()
     return self