def __init__( self, input_bus_channel_count=None, output_bus_channel_count=None, input_=None, name=None, ): from supriya.tools import nonrealtimetools self._options = servertools.ServerOptions( input_bus_channel_count=input_bus_channel_count, output_bus_channel_count=output_bus_channel_count, ) self._active_moments = [] self._session_ids = {} self._states = {} self._buffers = timetools.TimespanCollection() self._nodes = timetools.TimespanCollection() self._offsets = [] self._root_node = nonrealtimetools.RootNode(self) self._setup_initial_states() self._setup_buses() if input_ is not None and not isinstance(input_, type(self)): input_ = str(input_) self._input = input_ self._name = name self._transcript = None
def _build_render_command( self, output_filename, input_file_path=None, server_options=None, sample_rate=44100, header_format=soundfiletools.HeaderFormat.AIFF, sample_format=soundfiletools.SampleFormat.INT24, ): """ Builds non-realtime rendering command. :: >>> session._build_render_command('output.aiff') 'scsynth -N {} _ output.aiff 44100 aiff int24' """ from abjad.tools import systemtools server_options = server_options or servertools.ServerOptions() scsynth_path = 'scsynth' if not systemtools.IOManager.find_executable('scsynth'): found_scsynth = False for path in ( '/Applications/SuperCollider/SuperCollider.app/Contents/MacOS/scsynth', # pre-7 '/Applications/SuperCollider/SuperCollider.app/Contents/Resources/scsynth', # post-7 ): if os.path.exists(path): scsynth_path = path found_scsynth = True if not found_scsynth: raise Exception('Cannot find scsynth. Is it on your $PATH?') parts = [scsynth_path, '-N', '{}'] if input_file_path: parts.append(os.path.expanduser(input_file_path)) else: parts.append('_') parts.append(os.path.expanduser(output_filename)) parts.append(str(int(sample_rate))) header_format = soundfiletools.HeaderFormat.from_expr(header_format) parts.append(header_format.name.lower()) # Must be lowercase. sample_format = soundfiletools.SampleFormat.from_expr(sample_format) parts.append(sample_format.name.lower()) # Must be lowercase. server_options = server_options.as_options_string(realtime=False) if server_options: parts.append(server_options) command = ' '.join(parts) return command
def boot(self, server_options=None, **kwargs): from supriya import new from supriya import supriya_configuration from supriya.tools import servertools if self.is_running: return self scsynth_path = supriya_configuration.scsynth_path self._osc_controller.boot() server_options = server_options or servertools.ServerOptions() assert isinstance(server_options, servertools.ServerOptions) if kwargs: server_options = new(server_options, **kwargs) options_string = server_options.as_options_string(self.port) command = '{} {} -V -1'.format(scsynth_path, options_string) self._server_process = subprocess.Popen(command, shell=True) time.sleep(0.25) self._is_running = True self._server_options = server_options self._setup() self.sync() PubSub.notify('server-booted') return self
def __init__( self, ip_address='127.0.0.1', port=57751, ): from supriya.tools import osctools from supriya.tools import responsetools from supriya.tools import servertools if hasattr(self, 'is_running') and self.is_running: return ### NET ADDRESS ### self._ip_address = ip_address self._port = port ### OSC MESSAGING ### self._latency = 0.1 self._response_dispatcher = responsetools.ResponseDispatcher() self._subscription_service = servertools.SubscriptionService() self._osc_dispatcher = osctools.OscDispatcher() self._osc_controller = osctools.OscController(server=self) for callback in ( responsetools.BufferResponseCallback(self), responsetools.ControlBusResponseCallback(self), responsetools.NodeResponseCallback(self), responsetools.SynthDefResponseCallback(self), ): self.register_response_callback(callback) fail_callback = osctools.OscCallback( address_pattern='/fail', procedure=lambda message: print('FAILED:', message), ) self.register_osc_callback(fail_callback) ### ALLOCATORS ### self._audio_bus_allocator = None self._buffer_allocator = None self._control_bus_allocator = None self._node_id_allocator = None ### SERVER PROCESS ### self._is_running = False self._server_options = servertools.ServerOptions() self._server_process = None self._status = None self._status_watcher = None ### PROXIES ### self._audio_input_bus_group = None self._audio_output_bus_group = None self._default_group = None self._root_node = None self._meters = servertools.ServerMeters(self) self._recorder = servertools.ServerRecorder(self) ### PROXY MAPPINGS ### self._audio_buses = {} self._control_buses = {} self._control_bus_proxies = {} self._buffers = {} self._buffer_proxies = {} self._nodes = {} self._synthdefs = {} ### DEBUG ### self.debug_osc = False self.debug_udp = False ### REGISTER WITH ATEXIT ### atexit.register(self.quit)