FoxDot.lib.ServerManager

Handles OSC messages being sent to SuperCollider.

class FoxDot.lib.ServerManager.BidirectionalOSCServer(server_address=('localhost', 0), client=None, return_port=0)[source]

Bases: OSCServer

This is a combination client/server

The UDP server is necessary for receiving responses from the SCLang server when we query it with requests.

Note that this is not thread-safe, as the receive() method can discard messages

connect(addr)[source]

Connect to an address and start the server thread

receive(pattern, timeout=2)[source]

Retrieve the first message matching the pattern

All messages received that do not match will be discarded

send(*args, **kwargs)[source]
start()[source]

Start the server thread.

stop()[source]

Stop the server thread and close the socket.

class FoxDot.lib.ServerManager.Message(data)[source]

Bases: object

Wrapper for JSON messages sent to the server

asString()[source]
class FoxDot.lib.ServerManager.OSCClientWrapper(server=None)[source]

Bases: OSCClient

error_printed = True
send(msg, timeout=None)[source]

Sends the message given but prints errors instead of raising them

class FoxDot.lib.ServerManager.OSCConnect(address)[source]

Bases: OSCClientWrapper

An OSCClientWrapper that connects on initialisation

class FoxDot.lib.ServerManager.RequestHandler(request, client_address, server)[source]

Bases: BaseRequestHandler

Created whenever a new connection to the server is made: self.request = socket self.server = Server instance self.client_address = (address, port)

disconnect()[source]

Prints a message to the master clock and removes a reference to this client

handle()[source]

Overload

master = None
update_tempo(bpm, bpm_start_beat, bpm_start_time)[source]
exception FoxDot.lib.ServerManager.RequestTimeout[source]

Bases: Exception

Raised if expecting a response from the server but received none

class FoxDot.lib.ServerManager.SCLangServerManager(addr, osc_port, sclang_port)[source]

Bases: ServerManager

add_forward(addr, port)[source]
boot()

Boots SuperCollider using subprocess.

bufferFree(bufnum)[source]

Sends a message to SuperCollider to free a buffer

bufferRead(path, bufnum)[source]

Sends a message to SuperCollider to read an audio file into a buffer

daemon: Popen[bytes] | None
dumpOSC(value=1)[source]

Debug - Dumps OSC messages SCLang side

dumpTree(group_id=0, flag=0)[source]

Server will print the node tree

freeAllNodes()[source]

Triggers a free all message to kill all active nodes (sounds) in SuperCollider

free_node(node)[source]

Sends a message to SuperCollider to stop a specific node

fxlist = None
getInfo()[source]

Fetch info about the SCLang server

get_bundle(synthdef, packet, timestamp=0)[source]

Returns the OSC Bundle for a notew based on a Player’s SynthDef, and event and effects dictionaries

get_control_effect_nodes(node, bus, group_id, packet)[source]
get_exit_node(node, bus, group_id, packet)[source]
get_init_node(node, bus, group_id, synthdef, packet)[source]
get_midi_message(synthdef, packet, timestamp)[source]

Prepares an OSC message to trigger midi sent from SuperCollider

get_post_env_effect_nodes(node, bus, group_id, packet)[source]
get_pre_env_effect_nodes(node, bus, group_id, packet)[source]
get_synth_envelope(node, bus, group_id, synthdef, packet)[source]
get_synth_node(node, bus, group_id, synthdef, packet)[source]
property is_runnig

Checks if the SuperCollider IDE or SCLang is running.

kill()[source]

Kill old sclang processes so that the startup can execute successfully.

loadCompiled(fn)[source]

Sends a message to SuperCollider to load a compiled SynthDef file

loadRecorder()[source]

Loads an OSCFunc that starts/stops recording to a set path

loadSynthDef(fn, cmd='/foxdot')[source]

Sends a message to the FoxDot class in SuperCollider to load a SynthDef from file

nextbusID()[source]

Gets the next SuperCollider bus to use

nextnodeID()[source]

Gets the next node ID to use in SuperCollider

prepare_effect(name, packet)[source]

Finds the child attributes in packet and returns an OSC style list

query()[source]

Prints debug status to SuperCollider console

quit()[source]
record(fn=None)[source]

Starts recording audio from SuperCollider

reset()[source]
send(address, message)[source]

Sends message (a list) to SuperCollider

sendMidi(msg, cmd='/foxdot_midi')[source]

Sends a message to the FoxDot class in SuperCollider to forward a MIDI message

sendOSC(osc_message)[source]

Sends an OSC message to the server. Checks for midi messages

setFx(fx_list)[source]
set_midi_nudge(value)[source]
start()[source]

Boots SuperCollider using subprocess.

stopRecording()[source]

Stops recording audio from SuperCollider

synthdefs = None
class FoxDot.lib.ServerManager.ServerInfo(sample_rate, actual_sample_rate, num_synths, num_groups, num_audio_bus_channels, num_control_bus_channels, num_input_bus_channels, num_output_bus_channels, num_buffers, max_nodes, max_synth_defs)

Bases: tuple

actual_sample_rate

Alias for field number 1

max_nodes

Alias for field number 9

max_synth_defs

Alias for field number 10

num_audio_bus_channels

Alias for field number 4

num_buffers

Alias for field number 8

num_control_bus_channels

Alias for field number 5

num_groups

Alias for field number 3

num_input_bus_channels

Alias for field number 6

num_output_bus_channels

Alias for field number 7

num_synths

Alias for field number 2

sample_rate

Alias for field number 0

class FoxDot.lib.ServerManager.ServerManager(addr, port, osc_address='/s_new')[source]

Bases: object

static create_osc_msg(dictionary)[source]

Converts a Python dictionary into an OSC style list

get_bundle(*args, **kwargs)[source]
loadSynthDef(*args, **kwargs)[source]
sendOSC(osc_message)[source]
setFx(*args, **kwargs)[source]
class FoxDot.lib.ServerManager.TempoClient(clock)[source]

Bases: object

calculate_latency(start, end)[source]

Returns (and stores) the latency using the start and end time to send a message to the master server

connect(hostname, port=57890)[source]

Connects to the server instance

kill()[source]

Properly terminates the connection to the server

listen()[source]

Listens out for data coming from the server and passes it on to the handler.

record_latency()[source]
send(data)[source]

Sends data to server

start_timing()[source]

Starts an internal timer for calculating latency

stop_timing()[source]

Stops the internal timer and calculates latency

update_tempo(bpm, bpm_start_beat, bpm_start_time)[source]

Sends data to other connected FoxDot instances to update their tempo

class FoxDot.lib.ServerManager.TempoServer(clock, port=57999)[source]

Bases: ThreadedServer

Used in TempoClock.py to connect to instances of FoxDot over a network. Sends bpm changes over the network. On initial request this sends the start_time value of the clock

kill()[source]

Properly terminates the server instance

start()[source]

Starts listening on the socket

update_tempo(source, bpm, bpm_start_beat, bpm_start_time)[source]

Sends information to all connected peers about changing tempo

class FoxDot.lib.ServerManager.ThreadedServer(server_address, RequestHandlerClass, bind_and_activate=True)[source]

Bases: ThreadingMixIn, TCPServer

Base class

FoxDot.lib.ServerManager.read_from_socket(sock)[source]

Reads data from the socket

FoxDot.lib.ServerManager.send_to_socket(sock, data)[source]

Converts Python data structure to JSON message and sends to a connected socket

FoxDot.lib.ServerManager.Server = FoxDot ServerManager Instance -> localhost:57110