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

[ServerOptions] convert to Integers when not set to default values #4110

Merged
merged 7 commits into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SCClassLibrary/Common/Control/Score.sc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Score {
classvar <>program, <>options;

*initClass {
// ensure default values are available in ServerOptions
Class.initClassTree(ServerOptions);
patrickdupuis marked this conversation as resolved.
Show resolved Hide resolved
options = ServerOptions.new;
}

Expand Down
167 changes: 114 additions & 53 deletions SCClassLibrary/Common/Control/Server.sc
Original file line number Diff line number Diff line change
@@ -1,58 +1,111 @@
ServerOptions {
classvar defaultValues;

// order of variables is important here. Only add new instance variables to the end.
var <numAudioBusChannels=1024;
var <>numControlBusChannels=16384;
var <numInputBusChannels=2;
var <numOutputBusChannels=2;
var <>numBuffers=1026;
var <numAudioBusChannels;
var <>numControlBusChannels;
var <numInputBusChannels;
var <numOutputBusChannels;
var <>numBuffers;

var <>maxNodes=1024;
var <>maxSynthDefs=1024;
var <>protocol = \udp;
var <>blockSize = 64;
var <>hardwareBufferSize = nil;
var <>maxNodes;
var <>maxSynthDefs;
var <>protocol;
var <>blockSize;
var <>hardwareBufferSize;

var <>memSize = 8192;
var <>numRGens = 64;
var <>numWireBufs = 64;
var <>memSize;
var <>numRGens;
var <>numWireBufs;

var <>sampleRate = nil;
var <>loadDefs = true;
var <>sampleRate;
var <>loadDefs;

var <>inputStreamsEnabled;
var <>outputStreamsEnabled;

var <>inDevice = nil;
var <>outDevice = nil;
var <>inDevice;
var <>outDevice;

var <>verbosity = 0;
var <>zeroConf = false; // Whether server publishes port to Bonjour, etc.
var <>verbosity;
var <>zeroConf; // Whether server publishes port to Bonjour, etc.

var <>restrictedPath = nil;
var <>ugenPluginsPath = nil;
var <>restrictedPath;
var <>ugenPluginsPath;

var <>initialNodeID = 1000;
var <>remoteControlVolume = false;
var <>initialNodeID;
var <>remoteControlVolume;

var <>memoryLocking = false;
var <>threads = nil; // for supernova
var <>useSystemClock = false; // for supernova
var <>memoryLocking;
var <>threads; // for supernova
var <>useSystemClock; // for supernova

var <numPrivateAudioBusChannels=1020;
var <numPrivateAudioBusChannels;

var <>reservedNumAudioBusChannels = 0;
var <>reservedNumControlBusChannels = 0;
var <>reservedNumBuffers = 0;
var <>pingsBeforeConsideredDead = 5;
var <>reservedNumAudioBusChannels;
var <>reservedNumControlBusChannels;
var <>reservedNumBuffers;
var <>pingsBeforeConsideredDead;

var <>maxLogins;

var <>maxLogins = 1;
var <>recHeaderFormat;
var <>recSampleFormat;
var <>recChannels;
var <>recBufSize;

var <>recHeaderFormat="aiff";
var <>recSampleFormat="float";
var <>recChannels = 2;
var <>recBufSize = nil;
*initClass {
defaultValues = IdentityDictionary.newFrom(
(
numAudioBusChannels: 1024, // see corresponding setter method below
numControlBusChannels: 16384,
numInputBusChannels: 2, // see corresponding setter method below
numOutputBusChannels: 2, // see corresponding setter method below
numBuffers: 1024,
maxNodes: 1024,
maxSynthDefs: 1024,
protocol: \udp,
blockSize: 64,
hardwareBufferSize: nil,
memSize: 8192,
numRGens: 64,
numWireBufs: 64,
sampleRate: nil,
loadDefs: true,
inputStreamsEnabled: nil,
outputStreamsEnabled: nil,
inDevice: nil,
outDevice: nil,
verbosity: 0,
zeroConf: false,
restrictedPath: nil,
ugenPluginsPath: nil,
initialNodeID: 1000,
remoteControlVolume: false,
memoryLocking: false,
threads: nil,
useSystemClock: false,
numPrivateAudioBusChannels: 1020, // see corresponding setter method below
reservedNumAudioBusChannels: 0,
reservedNumControlBusChannels: 0,
reservedNumBuffers: 0,
pingsBeforeConsideredDead: 5,
maxLogins: 1,
recHeaderFormat: "aiff",
recSampleFormat: "float",
recChannels: 2,
recBufSize: nil,
)
)
}

*new {
^super.new.init
}

init {
defaultValues.keysValuesDo { |key, val| this.instVarPut(key, val) }
}

device {
^if(inDevice == outDevice) {
Expand All @@ -73,37 +126,45 @@ ServerOptions {

o = o ++ " -a " ++ (numPrivateAudioBusChannels + numInputBusChannels + numOutputBusChannels) ;

if (numControlBusChannels != 16384, {
if (numControlBusChannels !== defaultValues[\numControlBusChannels], {
numControlBusChannels = numControlBusChannels.asInteger;
o = o ++ " -c " ++ numControlBusChannels;
});
if (numInputBusChannels != 8, {
if (numInputBusChannels != defaultValues[\numInputBusChannels], {
o = o ++ " -i " ++ numInputBusChannels;
});
if (numOutputBusChannels != 8, {
if (numOutputBusChannels != defaultValues[\numOutputBusChannels], {
o = o ++ " -o " ++ numOutputBusChannels;
});
if (numBuffers != 1024, {
if (numBuffers !== defaultValues[\numBuffers], {
numBuffers = numBuffers.asInteger;
o = o ++ " -b " ++ numBuffers;
});
if (maxNodes != 1024, {
if (maxNodes !== defaultValues[\maxNodes], {
maxNodes = maxNodes.asInteger;
o = o ++ " -n " ++ maxNodes;
});
if (maxSynthDefs != 1024, {
if (maxSynthDefs !== defaultValues[\maxSynthDefs], {
maxSynthDefs = maxSynthDefs.asInteger;
o = o ++ " -d " ++ maxSynthDefs;
});
if (blockSize != 64, {
if (blockSize !== defaultValues[\blockSize], {
blockSize = blockSize.asInteger;
o = o ++ " -z " ++ blockSize;
});
if (hardwareBufferSize.notNil, {
o = o ++ " -Z " ++ hardwareBufferSize;
});
if (memSize != 8192, {
if (memSize !== defaultValues[\memSize], {
memSize = memSize.asInteger;
o = o ++ " -m " ++ memSize;
});
if (numRGens != 64, {
if (numRGens !== defaultValues[\numRGens], {
numRGens = numRGens.asInteger;
o = o ++ " -r " ++ numRGens;
});
if (numWireBufs != 64, {
if (numWireBufs !== defaultValues[\numWireBufs], {
numWireBufs = numWireBufs.asInteger;
o = o ++ " -w " ++ numWireBufs;
});
if (sampleRate.notNil, {
Expand All @@ -128,7 +189,7 @@ ServerOptions {
{
o = o ++ " -H % %".format(inDevice.asString.quote, outDevice.asString.quote);
};
if (verbosity != 0, {
if (verbosity != defaultValues[\verbosity], {
o = o ++ " -V " ++ verbosity;
});
if (zeroConf.not, {
Expand All @@ -153,8 +214,8 @@ ServerOptions {
o = o ++ " -T " ++ threads;
}
});
if (useSystemClock.notNil, {
o = o ++ " -C " ++ useSystemClock.asInteger
if (useSystemClock, {
patrickdupuis marked this conversation as resolved.
Show resolved Hide resolved
o = o ++ " -C 1"
});
if (maxLogins.notNil, {
o = o ++ " -l " ++ maxLogins;
Expand All @@ -171,22 +232,22 @@ ServerOptions {
^this.primitiveFailed
}

numPrivateAudioBusChannels_ { |numChannels = 112|
numPrivateAudioBusChannels_ { |numChannels = 1020| // arg default value should match defaultValues above
numPrivateAudioBusChannels = numChannels;
this.recalcChannels;
}

numAudioBusChannels_ { |numChannels=1024|
numAudioBusChannels_ { |numChannels = 1024| // arg default value should match defaultValues above
numAudioBusChannels = numChannels;
numPrivateAudioBusChannels = numAudioBusChannels - numInputBusChannels - numOutputBusChannels;
}

numInputBusChannels_ { |numChannels=8|
numInputBusChannels_ { |numChannels = 2| // arg default value should match defaultValues above
numInputBusChannels = numChannels;
this.recalcChannels;
}

numOutputBusChannels_ { |numChannels=8|
numOutputBusChannels_ { |numChannels = 2| // arg default value should match defaultValues above
numOutputBusChannels = numChannels;
this.recalcChannels;
}
Expand Down