Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sockets changing Nexus #146

Open
luisarandas opened this issue Mar 4, 2019 · 6 comments
Open

Sockets changing Nexus #146

luisarandas opened this issue Mar 4, 2019 · 6 comments

Comments

@luisarandas
Copy link

Hello and good day!
I am posting this issue because I am instantiating a received socket to change the GUI value and I'm getting problems.
Almost all the time I receive a socket that wants to change a slider or a knob from other person (like as I'm changing mine, I change all others) the software freezes. But if I instantiate it to just control tonejs audio there is no problem, only when I want to change the nexus uis
I am doing it like this
(values is an array of vars for each widget)
socket.on('uiSocketSynthVolume', function(data) {
if (isStreaming == true) {
if (data.y == "synthVolume") {
//polySynth.volume.value = data.x;
values[0] = data.x;
if (UI.synthvolume.value != values[0]) {
UI.synthvolume.value = values[0];
}
} else {
console.log("");
}
}
});
And a socket.on all the other users to when they change it
Best, Luis

@taylorbf
Copy link
Contributor

taylorbf commented Mar 4, 2019

Hi Luis, this is freezing because it creates an infinite loop or socket emissions.any time you set the value of a dial, the 'change' function is called. So the sequence of events in your situation is:

You change a dial
It emits the value through a websocket
All other dials are set to that new value
All those other dials emit their value through the websocket
All dials are again set to that value
Etc

Their needs to be a built-in solution to this kind of loop. I believe there is already. I'll look at the code and get back to you.

@luisarandas
Copy link
Author

Thank you for quick answer, as always.
I hope we can fix this.
Best, Luis

@taylorbf
Copy link
Contributor

taylorbf commented Mar 6, 2019

Luis, can you give me a complete list of the types of interface components you are using in this setup? You mentioned sliders and knobs -- anything else?

Basically, I don't see an easy general solution, and this was unfortunately an oversight of the version 2 API I created. I think it will take some extra development to resolve, which I can't do at the moment. But if you let me know the types of interfaces you are using, I can send you patch functions which will get the job done for your project at the moment.

@luisarandas
Copy link
Author

Thank you very much for the quick answer Taylor.
Well at the moment I am using only sliders and knobs yes! I have buttons but are not actually from NexusUI and I am not broadcasting them
Let me know if I can help, Luis.

@taylorbf
Copy link
Contributor

taylorbf commented Mar 6, 2019

In both cases (slider and dial) you can use the following code to set the value without causing the slider/dial to trigger its 'change' function.

dial1._value.update(v);
dial1.render();

However, since this causes the dial/slider to update without triggering its 'change' function, that means it will also not execute any web audio code you have in its 'change' function. So you will need to manually duplicate your web audio code here in the socket listener. It's not great -- again, this is a temp fix to keep your project rolling.

dial1._value.update(v);
dial1.render();
// web audio code goes here
polySynth.volume.value = v

I will keep thinking about a more elegant solution for this.

@luisarandas
Copy link
Author

Thank you again taylorbf, always accurate.
I didn't answer before due to personal impossibilities
I just tested this, seems to work perfectly. Didn't test with sockets both ways and 50 people at the same time but the architecture seems to solve the problem.
Best, Luis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants