Muliple versions of same genserver cooperating

What I’m trying to do.
Build a reasonable audio sequencer using software and hardware synths as audio servers.

What I’ve got so far
I’ve got a fairly solid single voice version that drives a software synthesizer (supercollider). I’ve POC’d a version of this that does multiple voices and works reasonably well. This is built by adding complexity to the single voice version. Both of these versions are built as genservers.

After building the current multiple voice version, I felt like it should be a better path if I were to have multiple cooperating instances of the single voice version being controlled and synchronized by a separate process.

What I haven’t been able to figure out
How to launch mulitple instances of the same genserver. I’m sure I’m overlooking something basic, but I’m relatively new to genservers. When I try to launch another instance, by calling start_link, as one would expect, it tells me it’s already started. I’ve been digging through docs, but I’ve found no obvious solutions.

I suppose that a more basic question to ask is should I stick with the multi-voice version that I’ve already built using a single genserver? It behaves adequately, but my gut feeling is that it isn’t the right way to do it.

1 Like

Just do not give them name. You can spawn as many processes using the same code as you want, the only thing is that these cannot share the same name.

3 Likes

This isn’t a direct answer to your question, but given what you’re trying to accomplish, you really should go and read these archived blog posts that Joe Armstrong wrote over at Joe Armstrong - Erlang and other stuff.

Controlling Live Music
What is OSC?
Controlling Sound with OSC Messages

Check the index as there may be others…

Joe was very interested in this stuff – as you will discover – and even if you don’t learn anything new, Joe’s youthful excitement and enthusiasm is contagious and just might rub off on you!

Joe is sorely missed in these parts, but he left behind a lot of good stuff like this for others to discover and hopefully get just as excited about it as he did!

2 Likes

Thanks for the links. I had read the ones on OSC which were super helpful when I was doing my implementation!

In other news, with the hint from hauleth and a little experimenting with Registry, I think I’m on the path to enlightenment on this topic!

2 Likes

A DynamicSupervisor might also work well for you.

Registry + dynamicsupervisor power combo!!