Skip to content

Commit

Permalink
add classvar defaultValues
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdupuis committed Oct 18, 2018
1 parent bfdf4bf commit 230258a
Showing 1 changed file with 100 additions and 47 deletions.
147 changes: 100 additions & 47 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=1024;
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,
numControlBusChannels: 16384,
numInputBusChannels: 2,
numOutputBusChannels: 2,
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,
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,44 +126,44 @@ ServerOptions {

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

if (numControlBusChannels !== 16384, {
if (numControlBusChannels !== defaultValues[\numControlBusChannels], {
numControlBusChannels = numControlBusChannels.asInteger;
o = o ++ " -c " ++ numControlBusChannels;
});
if (numInputBusChannels != 2, {
if (numInputBusChannels != defaultValues[\numInputBusChannels], {
o = o ++ " -i " ++ numInputBusChannels;
});
if (numOutputBusChannels != 2, {
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;
});
Expand All @@ -136,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 Down

0 comments on commit 230258a

Please sign in to comment.