def test_boot_and_connect(): server = Server() assert not server.is_running assert not server.is_owner server.boot() assert server.is_running assert server.is_owner server.connect() assert server.is_running assert server.is_owner
def test_boot_and_quit(): server = Server() assert not server.is_running assert not server.is_owner server.boot() assert server.is_running assert server.is_owner server.quit() assert not server.is_running assert not server.is_owner
def test_connect_and_reconnect(): try: options = BootOptions(maximum_logins=4) process = options.boot(options.find_scsynth(), 57110) server = Server(port=57110) server.connect() assert server.is_running and not server.is_owner assert server.client_id == 0 assert str(server.query_local_nodes(True)) == normalize( """ NODE TREE 0 group 1 group 2 group 3 group 4 group """ ) server.disconnect() server.connect() assert server.is_running and not server.is_owner assert server.client_id == 1 assert str(server.query_local_nodes(True)) == normalize( """ NODE TREE 0 group 1 group 2 group 3 group 4 group """ ) finally: process.terminate() process.wait()
def test_boot_a_and_connect_b_and_force_disconnect_a(): server_a, server_b = Server(), Server() assert not server_a.is_running and not server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_a.boot(maximum_logins=2) server_b.connect() assert server_a.is_running and server_a.is_owner assert server_b.is_running and not server_b.is_owner server_a.disconnect(force=True) assert not server_a.is_running and not server_a.is_owner assert server_b.is_running and not server_b.is_owner
def test_boot_a_and_boot_b_cannot_boot(): server_a, server_b = Server(), Server() assert not server_a.is_running and not server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_a.boot(maximum_logins=4) assert server_a.is_running and server_a.is_owner assert not server_b.is_running and not server_b.is_owner with pytest.raises(supriya.exceptions.ServerCannotBoot): server_b.boot(maximum_logins=4) assert server_a.is_running and server_a.is_owner assert not server_b.is_running and not server_b.is_owner
def test_boot_a_and_connect_b_too_many_clients(): server_a, server_b = Server(), Server() assert not server_a.is_running and not server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_a.boot(maximum_logins=1) assert server_a.is_running and server_a.is_owner assert not server_b.is_running and not server_b.is_owner with pytest.raises(supriya.exceptions.TooManyClients): server_b.connect() assert server_a.is_running and server_a.is_owner assert not server_b.is_running and not server_b.is_owner
def test_boot_a_and_connect_b_and_quit_b(): server_a, server_b = Server(), Server() assert not server_a.is_running and not server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_a.boot(maximum_logins=2) server_b.connect() assert server_a.is_running and server_a.is_owner assert server_b.is_running and not server_b.is_owner with pytest.raises(supriya.exceptions.UnownedServerShutdown): server_b.quit() assert server_a.is_running and server_a.is_owner assert server_b.is_running and not server_b.is_owner
def test_boot_a_and_connect_b_and_force_quit_b(): server_a, server_b = Server(), Server() assert not server_a.is_running and not server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_a.boot(maximum_logins=2) server_b.connect() assert server_a.is_running and server_a.is_owner assert server_b.is_running and not server_b.is_owner server_b.quit(force=True) assert not server_b.is_running and not server_b.is_owner time.sleep(2) # wait for status watcher assert not server_a.is_running and not server_a.is_owner
def test_shared_resources(): server_a, server_b = Server(), Server() server_a.boot(maximum_logins=2) server_b.connect() with supriya.SynthDefBuilder(frequency=440) as builder: _ = supriya.ugens.Out.ar( bus=0, source=supriya.ugens.SinOsc.ar(frequency=builder["frequency"]) ) synthdef = builder.build(name="foo") synth = supriya.Synth(synthdef=synthdef) transcript_a = server_a.osc_io.capture() transcript_b = server_b.osc_io.capture() with transcript_a, transcript_b: synth.allocate(target_node=server_b) assert synth not in server_a assert synth in server_b assert [(label, osc_message) for _, label, osc_message, _ in transcript_a] == [ ("R", OscMessage("/n_go", 67109864, 2, -1, -1, 0)) ] assert [(label, osc_message) for _, label, osc_message, _ in transcript_b] == [ ("S", OscMessage(5, synthdef.compile(), OscMessage(9, "foo", 67109864, 0, 2))), ("R", OscMessage("/n_go", 67109864, 2, -1, -1, 0)), ("R", OscMessage("/done", "/d_recv")), ] # TODO: Server A doesn't actually know what this SynthDef should be. assert str(server_a.query_local_nodes(True)) == normalize( """ NODE TREE 0 group 1 group 2 group 67109864 default amplitude: 0.1, frequency: 440.0, gate: 1.0, out: 0.0, pan: 0.5 """ ) assert str(server_b.query_local_nodes(True)) == normalize( """ NODE TREE 0 group 1 group 2 group 67109864 foo frequency: 440.0 """ )
def test_boot_a_and_connect_b(): server_a, server_b = Server(), Server() assert not server_a.is_running and not server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_a.boot(maximum_logins=4) assert server_a.is_running and server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_b.connect() assert server_a.is_running and server_a.is_owner assert server_b.is_running and not server_b.is_owner assert server_a.query_remote_nodes() == server_b.query_remote_nodes() assert server_a.client_id == 0 and server_b.client_id == 1 assert server_a.default_group.node_id == 1 and server_b.default_group.node_id == 2 group = supriya.Group() group.allocate(target_node=server_a) assert server_a.root_node[0][0] is group server_b.sync() assert server_b.root_node[0][0] is not group assert server_a.query_remote_nodes() == server_b.query_remote_nodes()
def test_boot_and_boot(): server = Server() assert not server.is_running assert not server.is_owner server.boot() assert server.is_running assert server.is_owner with pytest.raises(exceptions.ServerOnline): server.boot() assert server.is_running assert server.is_owner
def test_boot_a_and_connect_b_and_quit_a(): server_a, server_b = Server(), Server() assert not server_a.is_running and not server_a.is_owner assert not server_b.is_running and not server_b.is_owner server_a.boot(maximum_logins=2) server_b.connect() assert server_a.is_running and server_a.is_owner assert server_b.is_running and not server_b.is_owner server_a.quit() assert not server_a.is_running and not server_a.is_owner for _ in range(45): time.sleep(1) if not server_b.is_running: break assert not server_b.is_running and not server_b.is_owner
def test_shared_resources(): server_a, server_b = Server(), Server() server_a.boot(maximum_logins=2) server_b.connect() with supriya.SynthDefBuilder(frequency=440) as builder: _ = supriya.ugens.Out.ar( bus=0, source=supriya.ugens.SinOsc.ar(frequency=builder["frequency"])) synthdef = builder.build(name="foo") synth = supriya.Synth(synthdef=synthdef) transcript_a = server_a.osc_protocol.capture() transcript_b = server_b.osc_protocol.capture() with transcript_a, transcript_b: synth.allocate(target_node=server_b) time.sleep(0.1) # Wait for all clients to receive /n_go assert synth not in server_a assert synth in server_b assert [(label, osc_message) for _, label, osc_message in transcript_a if osc_message.address not in ["/status", "/status.reply"] ] == [("R", OscMessage("/n_go", 67109864, 2, -1, -1, 0))] assert [(label, osc_message) for _, label, osc_message in transcript_b if osc_message.address not in ["/status", "/status.reply"]] == [ ( "S", OscMessage( "/d_recv", synthdef.compile(), OscMessage("/s_new", "foo", 67109864, 0, 2), ), ), ("R", OscMessage("/n_go", 67109864, 2, -1, -1, 0)), ("R", OscMessage("/done", "/d_recv")), ] # TODO: Server A doesn't actually know what this SynthDef should be. assert str(server_a.query_local_nodes(True)) == normalize(""" NODE TREE 0 group 1 group 2 group 67109864 default amplitude: 0.1, frequency: 440.0, gate: 1.0, out: 0.0, pan: 0.5 """) assert str(server_b.query_local_nodes(True)) == normalize(""" NODE TREE 0 group 1 group 2 group 67109864 foo frequency: 440.0 """)
def server(): server = Server() server.boot() default.allocate(server=server) yield server server.quit()
def test_reset(): server = Server() with pytest.raises(exceptions.ServerOffline): server.reset() server.boot() server.add_synthdef(default) server.add_synth() server.add_group() server.add_buffer(1, 1024) server.add_bus("audio") server.add_bus("control") assert default in server server.reset() assert server.is_running assert default not in server server.add_synthdef(default) assert default in server
def test_reset_and_reboot(): server = Server() server.boot() server.reset() server.reboot() assert server.is_running
def test_reset_and_reboot_with_resources(): server = Server() server.boot() server.add_buffer(1, 1024) server.add_bus("audio") server.add_bus("control") server.add_group() server.add_synth() server.reset() server.reboot() assert server.is_running
def test_boot_and_quit_with_resources(): server = Server() server.boot() server.add_buffer(1, 1024) server.add_bus("audio") server.add_bus("control") server.add_group() server.add_synth() server.quit()
with config_path.open() as file_pointer: config.read_file(file_pointer) del appdirs del configparser del pathlib from supriya._version import __version__, __version_info__ # noqa from supriya import utils # noqa from supriya.clock import TempoClock # noqa from supriya.enums import ( # noqa AddAction, BinaryOperator, CalculationRate, DoneAction, EnvelopeShape, HeaderFormat, NodeAction, ParameterRate, RequestId, RequestName, SampleFormat, SignalRange, UnaryOperator, Unit, ) from supriya.io import graph, play, render # noqa from supriya.synthdefs import ( # noqa Envelope, Parameter, Range, SynthDef, SynthDefBuilder, SynthDefFactory, ) from supriya.realtime import ( # noqa Buffer, BufferGroup, Bus, BusGroup, Group, Synth, Server, ) from supriya import assets # noqa from supriya.nonrealtime import Session # noqa from supriya.provider import Provider # noqa from supriya.scsynth import Options # noqa from supriya.soundfiles import Say, SoundFile # noqa from supriya.system import Assets # noqa server = Server.default()
Unit, ) from supriya import utils # noqa from supriya.midi import Device # noqa from supriya.live import Application, Mixer # noqa from supriya.nonrealtime import Session # noqa from supriya.realtime import ( # noqa BootOptions, Buffer, BufferGroup, Bus, BusGroup, Group, Server, Synth, ) from supriya.soundfiles import Say, SoundFile # noqa from supriya.synthdefs import ( # noqa Envelope, Parameter, Range, SynthDef, SynthDefBuilder, SynthDefFactory, ) from supriya.system import Assets, Bindable, Binding, bind # noqa from supriya.io import graph, play, render # noqa from supriya import assets # noqa server = Server.default()