sc3nb.sc_objects.server

Module for managing Server related stuff.

Module Contents

Class List

MasterControlReply

Reply addresses of the Master Control Commands.

MasterControlCommand

Master Control commands of scsynth.

ReplyAddress

Specific reply addresses.

ServerStatus

Information about the status of the Server program

ServerVersion

Information about the version of the Server program

ServerOptions

Options for the SuperCollider audio server

NodeWatcher

The NodeWatcher is used to handle Node Notifications.

Hook

A simple class for storing a function and arguments and allows later execution.

SCServer

SuperCollider audio server representaion.

Content

sc3nb.sc_objects.server._LOGGER[source]
class sc3nb.sc_objects.server.MasterControlReply[source]

Bases: str, enum.Enum

Reply addresses of the Master Control Commands.

Initialize self. See help(type(self)) for accurate signature.

VERSION_REPLY = '/version.reply'[source]
SYNCED = '/synced'[source]
STATUS_REPLY = '/status.reply'[source]
class sc3nb.sc_objects.server.MasterControlCommand[source]

Bases: str, enum.Enum

Master Control commands of scsynth.

Initialize self. See help(type(self)) for accurate signature.

DUMP_OSC = '/dumpOSC'[source]
STATUS = '/status'[source]
VERSION = '/version'[source]
CLEAR_SCHED = '/clearSched'[source]
NOTIFY = '/notify'[source]
QUIT = '/quit'[source]
SYNC = '/sync'[source]
class sc3nb.sc_objects.server.ReplyAddress[source]

Bases: str, enum.Enum

Specific reply addresses.

Initialize self. See help(type(self)) for accurate signature.

WILDCARD_ADDR = '/*'[source]
FAIL_ADDR = '/fail'[source]
DONE_ADDR = '/done'[source]
RETURN_ADDR = '/return'[source]
sc3nb.sc_objects.server.ASYNC_CMDS[source]
sc3nb.sc_objects.server.CMD_PAIRS[source]
sc3nb.sc_objects.server.LOCALHOST = '127.0.0.1'[source]
sc3nb.sc_objects.server.SC3NB_SERVER_CLIENT_ID = 1[source]
sc3nb.sc_objects.server.SC3NB_DEFAULT_PORT = 57130[source]
sc3nb.sc_objects.server.SCSYNTH_DEFAULT_PORT = 57110[source]
sc3nb.sc_objects.server.SC3_SERVER_NAME = 'scsynth'[source]
class sc3nb.sc_objects.server.ServerStatus[source]

Bases: NamedTuple

Information about the status of the Server program

num_ugens: int[source]
num_synths: int[source]
num_groups: int[source]
num_synthdefs: int[source]
avg_cpu: float[source]
peak_cpu: float[source]
nominal_sr: float[source]
actual_sr: float[source]
class sc3nb.sc_objects.server.ServerVersion[source]

Bases: NamedTuple

Information about the version of the Server program

name: str[source]
major_version: int[source]
minor_version: int[source]
patch_version: str[source]
git_branch: str[source]
commit: str[source]
class sc3nb.sc_objects.server.ServerOptions(udp_port: int = SCSYNTH_DEFAULT_PORT, max_logins: int = 6, num_input_buses: int = 2, num_output_buses: int = 2, num_audio_buses: int = 1024, num_control_buses: int = 4096, num_sample_buffers: int = 1024, publish_rendezvous: bool = False, block_size: Optional[int] = None, hardware_buffer_size: Optional[int] = None, hardware_sample_size: Optional[int] = None, hardware_input_device: Optional[str] = None, hardware_output_device: Optional[str] = None, other_options: Optional[Sequence[str]] = None)[source]

Options for the SuperCollider audio server

This allows the encapsulation and handling of the command line server options.

Overview:

__repr__

Return repr(self).

__repr__()[source]

Return repr(self).

class sc3nb.sc_objects.server.NodeWatcher(server: SCServer)[source]

The NodeWatcher is used to handle Node Notifications.

Parameters:
serverSCServer

Server belonging to the notifications

Overview:

handle_notification

Handle a Notification

handle_notification(*args)[source]

Handle a Notification

class sc3nb.sc_objects.server.Hook(fun: Callable, *args: Any, **kwargs: Any)[source]

A simple class for storing a function and arguments and allows later execution.

Create a Hook

Parameters:
funCallable

Function to be executed

argsAny, optional

Arguments given to function

kwargsAny, optional

Keyword arguments given to function

Overview:

execute

Execute the Hook

execute()[source]

Execute the Hook

class sc3nb.sc_objects.server.SCServer(options: Optional[ServerOptions] = None)[source]

Bases: sc3nb.osc.osc_communication.OSCCommunication

SuperCollider audio server representaion.

Parameters

optionsOptional[ServerOptions], optional

Options used to start the local server, by default None

Create an OSC communication server

Parameters:
server_ipstr

IP address to use for this server

server_portint

port to use for this server

default_receiver_ipstr

IP address used for sending by default

default_receiver_portint

port used for sending by default

Overview:

boot

Start the Server process.

init

Initialize the server.

execute_init_hooks

Run all init hook functions.

connect_sclang

Connect sclang to the server

add_init_hook

Create and add a hook to be executed when the server is initialized

remove_init_hook

Remove a previously added init Hook

bundler

Generate a Bundler with added server latency.

blip

Make a blip sound

remote

Connect to remote Server

reboot

Reboot this server

ping

Ping the server.

quit

Quits and tries to kill the server.

sync

Sync the server with the /sync command.

send_synthdef

Send a SynthDef as bytes.

load_synthdef

Load SynthDef file at path.

load_synthdefs

Load all SynthDefs from directory.

notify

Notify the server about this client.

free_all

Free all node ids.

clear_schedule

Send /clearSched to the server.

send_default_groups

Send the default groups for all clients.

mute

Mute audio

unmute

Set volume back to volume prior to muting

version

Server version information

status

Server status information

dump_osc

Enable dumping incoming OSC messages at the server process

dump_tree

Server process prints out current nodes

query_tree

Query all nodes at the server and return a NodeTree

_init_osc_communication

_get_errors_for_address

_log_repr

_log_message

_warn_fail

__repr__

Return repr(self).

boot(scsynth_path: Optional[str] = None, timeout: float = 5, console_logging: bool = True, with_blip: bool = True, kill_others: bool = True, allowed_parents: Sequence[str] = ALLOWED_PARENTS)[source]

Start the Server process.

Parameters:
scsynth_pathstr, optional

Path of scscynth executable, by default None

timeoutfloat, optional

Timeout for starting the executable, by default 5

console_loggingbool, optional

If True write process output to console, by default True

with_blipbool, optional

make a sound when booted, by default True

kill_othersbool

kill other SuperCollider server processes.

allowed_parentsSequence[str], optional

Names of parents that are allowed for other instances of scsynth processes that won’t be killed, by default ALLOWED_PARENTS

Raises:
ValueError

If UDP port specified in options is already used

ProcessTimeout

If the process fails to start.

init(with_blip: bool = True)[source]

Initialize the server.

This adds allocators, loads SynthDefs, send default Groups etc.

Parameters:
with_blipbool, optional

make a sound when initialized, by default True

execute_init_hooks() None[source]

Run all init hook functions.

This is automatically done when running free_all, init or connect_sclang.

Hooks can be added using add_init_hook

connect_sclang(port: int) None[source]

Connect sclang to the server

This will add the “sclang” receiver and execute the init hooks

Parameters:
portint

Port of sclang (NetAddr.langPort)

add_init_hook(fun: Callable, *args: Any, **kwargs: Any) Hook[source]

Create and add a hook to be executed when the server is initialized

Parameters:
hookCallable[…, None]

Function to be executed

argsAny, optional

Arguments given to function

kwargsAny, optional

Keyword arguments given to function

Returns:
Hook

The created Hook

remove_init_hook(hook: Hook)[source]

Remove a previously added init Hook

Parameters:
hookHook

the hook to be removed

bundler(timetag=0, msg=None, msg_params=None, send_on_exit=True)[source]

Generate a Bundler with added server latency.

This allows the user to easly add messages/bundles and send it.

Parameters:
timetagfloat

Time at which bundle content should be executed. This servers latency will be added upon this. If timetag <= 1e6 it is added to time.time().

msg_addrstr

SuperCollider address.

msg_paramslist, optional
List of parameters to add to message.

(Default value = None)

Returns:
Bundler

bundler for OSC bundling.

blip() None[source]

Make a blip sound

remote(address: str, port: int, with_blip: bool = True) None[source]

Connect to remote Server

Parameters:
addressstr

address of remote server

portint

port of remote server

with_blipbool, optional

make a sound when initialized, by default True

reboot() None[source]

Reboot this server

Raises:
RuntimeError

If this server is remote and can’t be restarted.

abstract ping()[source]

Ping the server.

quit() None[source]

Quits and tries to kill the server.

sync(timeout=5) bool[source]

Sync the server with the /sync command.

Parameters:
timeoutint, optional
Time in seconds that will be waited for sync.

(Default value = 5)

Returns:
bool

True if sync worked.

send_synthdef(synthdef_bytes: bytes)[source]

Send a SynthDef as bytes.

Parameters:
synthdef_bytesbytes

SynthDef bytes

waitbool

If True wait for server reply.

load_synthdef(synthdef_path: str)[source]

Load SynthDef file at path.

Parameters:
synthdef_pathstr

Path with the SynthDefs

bundlebool

Wether the OSC Messages can be bundle or not. If True sc3nb will not wait for the server response, by default False

load_synthdefs(synthdef_dir: Optional[str] = None, completion_msg: Optional[bytes] = None) None[source]

Load all SynthDefs from directory.

Parameters:
synthdef_dirstr, optional

directory with SynthDefs, by default sc3nb default SynthDefs

completion_msgbytes, optional

Message to be executed by the server when loaded, by default None

notify(receive_notifications: bool = True, client_id: Optional[int] = None, timeout: float = 1) None[source]

Notify the server about this client.

This provides the client id and max logins info needed for default groups.

Parameters:
receive_notificationsbool, optional

Flag for receiving node notification from server, by default True

client_idint, optional

Propose a client id, by default None

timeoutfloat, optional

Timeout for server reply, by default 1.0

Raises:
RuntimeError

If server has too many users.

OSCCommunicationError

If OSC communication fails.

free_all(root: bool = True) None[source]

Free all node ids.

Parameters:
rootbool, optional

If False free only the default group of this client, by default True

clear_schedule()[source]

Send /clearSched to the server.

This clears all scheduled bundles and removes all bundles from the scheduling queue.

send_default_groups() None[source]

Send the default groups for all clients.

mute() None[source]

Mute audio

unmute() None[source]

Set volume back to volume prior to muting

version() ServerVersion[source]

Server version information

status() ServerStatus[source]

Server status information

dump_osc(level: int = 1) None[source]

Enable dumping incoming OSC messages at the server process

Parameters:
levelint, optional

Verbosity code, by default 1 0 turn dumping OFF. 1 print the parsed contents of the message. 2 print the contents in hexadecimal. 3 print both the parsed and hexadecimal representations.

dump_tree(controls: bool = True, return_tree=False) Optional[str][source]

Server process prints out current nodes

Parameters:
controlsbool, optional

If True include control values, by default True

return_treebool, optional

If True return output as string, by default False

Returns:
str

If return_tree this is the node tree string.

query_tree(include_controls: bool = True) sc3nb.sc_objects.node.Group[source]

Query all nodes at the server and return a NodeTree

Parameters:
include_controlsbool, optional

If True include control values, by default True

Returns:
NodeTree

object containing all the nodes.

_init_osc_communication()[source]
_get_errors_for_address(address: str)[source]
_log_repr()[source]
_log_message(sender, *params)[source]
_warn_fail(sender, *params)[source]
__repr__() str[source]

Return repr(self).