One client, multiple "mirrored" servers?

Hi there, I know there can be multiple clients sharing a scsynth server (https://doc.sccode.org/Guides/MultiClient_Setups.html) and an sclang client can access multiple servers… But can you set it up so there are “mirror” scsynth servers, e.g. one on the local machine and one off-site, that stay in sync? In other words, assuming they have the same SynthDefs and filesystem paths for buffers, they would be running (as much as possible) the same thing? You run { SinOsc.ar(440) }.play and it starts on both servers at once…or use Ndefs and such…

I expect the recommended solution might be instead to do some code-sharing mechanism (language side), like HyperDisCo…(?)

Thanks for any suggestions,
Glen.

It would be possible to create a drop-in replacement for NetAddr that sends messages to multiple locations. The tricky bits there are the timestamps: if the remote server machine’s clock time is later than the machine sending the messages, then the remote machine will see the messages as being late – e.g. the sender includes a timestamp for 4:37:21.188 and the remote server’s time is 4:37:25.762 = late. On a LAN, if the machines are NNTP synced, then it “should” work. I’m not sure what would be involved in NNTP syncing truly remote machines.

For that reason, it probably is easier to transmit code.

hjh

There is a MultiServer class in the wslib quark that provides this functionality (Word of warning: take caution when installing wslib! It’s powerful but slightly out of date, and overrides some core library functionality that can occasionally break things. If you need MultiServer, it might be better to extract just that class vs using the whole quark).

FWIW I’ve also built this by hand once or twice - it’s not hard. Just a matter of writing a custom “array” NetAddr - that keeps a list of NetAddr’s and forwards all calls to each NetAddr in its list. I’ve even used this for syncing several servers running on different computers, each handling sound for part of a very large multi-speaker array.

@jamshark70 is right - time sync is critical and much harder to achieve :). Another more minor thing: any synths with non-deterministic (e.g. random) UGens need to have the same seed value specified, else they will be producing different random values on different mirrored servers. This is easy to do with the RandSeed UGen

Thanks to both of you. I knew about the non-determinism issues (and solution), but didn’t know about MultiServer; will take a look at that. It looks quite “intended” for Mac use, with references to paths relative to the “/Volumes” directory. :wink: Anyhow, given the timing issues you mention (this would be to work with a truly remote – i.e. not on LAN – server), I may go for a language side solution.

How does sclang handle receiving messages from the server if you’re sending to more than one server? E.g. /done, /sync, /notify, /status, etc? I imagine you could get some pretty weird bugs if it thinkg all messages are from the same server…