-
Notifications
You must be signed in to change notification settings - Fork 757
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
Fix Server volume and mute after reboot #3125
Conversation
I messed up my first attempt at this PR. This is a redo. |
Oops... I should just stop now. |
Please review :) |
would it be possible to add a regression test for this? |
}).send(server); | ||
|
||
server.sync; | ||
|
||
this.updateSynth; | ||
|
||
if(updateFunc.isNil) { | ||
ServerTree.add(updateFunc = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while we're at it... this use of an assignment as an expression makes me cringe, could you move it out to updateFunc = { }; ServerTree.add(updateFunc)
? i'm warming up to brian's policy of cleaning up adjacent code when working on things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can confirm that this fixes the issues. a unit test would be nice.
please do go ahead and change that. I don't think an assignment in an argument should make you cringe, though. It can be a bit obscure. But it is a clear consequence of the fact that every expression returns a value. but I'm fine with a change of course if it helps readability |
I can write a unit test for this in a few days. |
Hmmm... with my last commit I get a warning while booting. Everthing seems to work fine though.
Looks like |
I made the server sync before creating the SynthDef. Maybe this is a little too hacky? I'm open to improvements. |
|
||
if(updateFunc.isNil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't test it here, but could you make sure that ServerTree
doesn't accumulate these functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any accumulation happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean that you start the server when you change the volume?
No, you can change the volume and mute the server as usual. The server volume mechanism still functions as before, except for the missing SynthDef errors. What gives you the impression that the server will boot when the volume changes? |
testsuite/classlibrary/TestVolume.sc
Outdated
var server = Server.default; | ||
var volume = Server.default.volume; | ||
var level = Server.default.volume.volume; | ||
var temp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to me that a temp variable should not be declared at class scope, and probably deserves a better name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right. I'll fix that right away.
I've added a UnitTest to this PR. Please have a look. In order to make the tests, I've had to modify Volume.sc slightly. Volume's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good. UnitTest is nice to have.
testsuite/classlibrary/TestVolume.sc
Outdated
@@ -0,0 +1,40 @@ | |||
TestVolume : UnitTest { | |||
|
|||
var server = Server.default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this creates a parse error. Did you test the UnitTest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to look into this and got this far (see below). However, I got
PASS:a TestVolume:test_setVolume - initial volume is 0 db
*** ERROR: SynthDef volumeAmpControl2 not found
FAILURE IN SERVER /s_new SynthDef not found
PASS:a TestVolume:test_setVolume - Server volume synth exists
FAILURE IN SERVER /n_set Node 1000 not found
FAILURE IN SERVER /s_get Node 1000 not found
ERROR: Message '-' not understood.
now I need to sleep... so leave this to others...
TestVolume : UnitTest {
test_setVolume {
var server = Server.default;
var serverVolume = server.volume.volume;
var ampSynthVolume;
this.bootServer;
this.assert(serverVolume == 0, "initial volume is 0 db");
server.volume.volume = -36;
server.sync;
this.assert(server.volume.ampSynth.notNil, "Server volume synth exists");
server.volume.ampSynth.get(\volumeAmp, { |level| ampSynthVolume = level });
server.sync;
this.assertFloatEquals(ampSynthVolume, serverVolume, "volume level correctly set");
server.volume.reset;
server.sync;
server.quit;
}
// [...]
}
@LFSaw thanks for looking at this. The tests should work now 👍 |
I confirmed with running the UnitTests locally. |
thanks for that @LFSaw :) |
This PR is an attempt to fix #3105 & #3110.
Description
The problem is that, on reboot, ServerTree calls its updateFunc (it was added the first time the server booted) before ServerBoot's initFunc is done sending the SynthDef. This causes the "SynthDef not found" error.
Changes proposed
The fix removes the updateFunc from ServerTree when the server quits. That way, on reboot, ServerTree has nothing to call. When initFunc is finished sending the SynthDef, updateFunc gets added to ServerTree.
Also, this.updateSynth needs to be called at the end of sendSynthDef so that the volume synth gets created, if necessary.
This change also makes Server.quit call Volume.freeSynth.
Result
The Server's volume and mute status persist across reboots. No more SynthDef not found errors posted after reboot.
Test