Skip to content

Commit 35b7d3f

Browse files
authored
Merge pull request #195 from tremblap/feature/seedable-random
class definition with seeding
2 parents 7954685 + ac5bec8 commit 35b7d3f

File tree

8 files changed

+42
-38
lines changed

8 files changed

+42
-38
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
FluidBufNMF : FluidBufProcessor
22
{
3-
*kr {|source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, resynth, resynthMode = 0, bases, basesMode = 0, activations, actMode = 0, components = 1, iterations = 100, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 0|
3+
*kr {|source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, resynth, resynthMode = 0, bases, basesMode = 0, activations, actMode = 0, components = 1, iterations = 100, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 0|
44

55
source.isNil.if {"FluidBufNMF: Invalid source buffer".throw};
66
resynth = resynth ? -1;
77
bases = bases ? -1;
88
activations = activations ? -1;
99

10-
^FluidProxyUgen.kr(\FluidBufNMFTrigger,-1,source.asUGenInput, startFrame, numFrames, startChan, numChans, resynth.asUGenInput, resynthMode, bases.asUGenInput, basesMode, activations.asUGenInput, actMode, components, iterations, windowSize, hopSize, fftSize, fftSize, trig, blocking);
10+
^FluidProxyUgen.kr(\FluidBufNMFTrigger,-1,source.asUGenInput, startFrame, numFrames, startChan, numChans, resynth.asUGenInput, resynthMode, bases.asUGenInput, basesMode, activations.asUGenInput, actMode, components, iterations, seed, windowSize, hopSize, fftSize, fftSize, trig, blocking);
1111
}
1212

13-
*process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, resynth = -1, resynthMode = 0, bases = -1, basesMode = 0, activations = -1, actMode = 0, components = 1, iterations = 100, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action|
13+
*process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, resynth = -1, resynthMode = 0, bases = -1, basesMode = 0, activations = -1, actMode = 0, components = 1, iterations = 100, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action|
1414

1515
source.isNil.if {"FluidBufNMF: Invalid source buffer".throw};
1616
resynth = resynth ? -1;
@@ -19,10 +19,10 @@ FluidBufNMF : FluidBufProcessor
1919

2020
^this.new(
2121
server,nil,[resynth, bases, activations].select{|x| x!= -1}
22-
).processList([source, startFrame, numFrames, startChan, numChans, resynth, resynthMode, bases, basesMode, activations, actMode, components,iterations, windowSize, hopSize, fftSize, fftSize, 0],freeWhenDone,action);
22+
).processList([source, startFrame, numFrames, startChan, numChans, resynth, resynthMode, bases, basesMode, activations, actMode, components, iterations, seed, windowSize, hopSize, fftSize, fftSize, 0],freeWhenDone,action);
2323
}
2424

25-
*processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, resynth = -1, resynthMode = 0, bases = -1, basesMode = 0, activations = -1, actMode = 0, components = 1, iterations = 100, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action|
25+
*processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, resynth = -1, resynthMode = 0, bases = -1, basesMode = 0, activations = -1, actMode = 0, components = 1, iterations = 100, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action|
2626

2727
source.isNil.if {"FluidBufNMF: Invalid source buffer".throw};
2828
resynth = resynth ? -1;
@@ -31,7 +31,7 @@ FluidBufNMF : FluidBufProcessor
3131

3232
^this.new(
3333
server,nil,[resynth, bases, activations].select{|x| x!= -1}
34-
).processList([source, startFrame, numFrames, startChan, numChans, resynth, resynthMode, bases, basesMode, activations, actMode, components,iterations, windowSize, hopSize, fftSize, fftSize, 1],freeWhenDone,action);
34+
).processList([source, startFrame, numFrames, startChan, numChans, resynth, resynthMode, bases, basesMode, activations, actMode, components, iterations, seed, windowSize, hopSize, fftSize, fftSize, 1],freeWhenDone,action);
3535
}
3636
}
3737
FluidBufNMFTrigger : FluidProxyUgen {}

release-packaging/Classes/FluidBufNMFCross.sc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FluidBufNMFCross : FluidBufProcessor {
22

3-
*kr { |source, target, output , timeSparsity = 7, polyphony = 10, continuity = 7, iterations = 50, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 0|
3+
*kr { |source, target, output , timeSparsity = 7, polyphony = 10, continuity = 7, iterations = 50, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 0|
44

55
source = source.asUGenInput;
66
target = target.asUGenInput;
@@ -9,10 +9,10 @@ FluidBufNMFCross : FluidBufProcessor {
99
target.isNil.if {"FluidBufNMFCross: Invalid target buffer".throw};
1010
output.isNil.if {"FluidBufNMFCross: Invalid output buffer".throw};
1111

12-
^FluidProxyUgen.kr(\FluidBufNMFCrossTrigger, -1, source, target, output, timeSparsity, polyphony, continuity, iterations, windowSize, hopSize, fftSize, fftSize, trig, blocking);
12+
^FluidProxyUgen.kr(\FluidBufNMFCrossTrigger, -1, source, target, output, timeSparsity, polyphony, continuity, iterations, seed, windowSize, hopSize, fftSize, fftSize, trig, blocking);
1313
}
1414

15-
*process { |server, source, target, output , timeSparsity = 7, polyphony = 10, continuity = 7, iterations = 50, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
15+
*process { |server, source, target, output , timeSparsity = 7, polyphony = 10, continuity = 7, iterations = 50, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
1616

1717
source = source.asUGenInput;
1818
target = target.asUGenInput;
@@ -25,11 +25,11 @@ FluidBufNMFCross : FluidBufProcessor {
2525
^this.new(
2626
server, nil, [output]
2727
).processList(
28-
[source, target, output, timeSparsity, polyphony, continuity, iterations, windowSize, hopSize, fftSize, fftSize, 0],freeWhenDone, action
28+
[source, target, output, timeSparsity, polyphony, continuity, iterations, seed, windowSize, hopSize, fftSize, fftSize, 0],freeWhenDone, action
2929
);
3030
}
3131

32-
*processBlocking { |server, source, target, output , timeSparsity = 7, polyphony = 10, continuity = 7, iterations = 50, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
32+
*processBlocking { |server, source, target, output , timeSparsity = 7, polyphony = 10, continuity = 7, iterations = 50, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
3333

3434
source = source.asUGenInput;
3535
target = target.asUGenInput;
@@ -42,7 +42,7 @@ FluidBufNMFCross : FluidBufProcessor {
4242
^this.new(
4343
server, nil, [output]
4444
).processList(
45-
[source, target, output, timeSparsity, polyphony, continuity, iterations, windowSize, hopSize, fftSize, fftSize, 1],freeWhenDone, action
45+
[source, target, output, timeSparsity, polyphony, continuity, iterations, seed, windowSize, hopSize, fftSize, fftSize, 1],freeWhenDone, action
4646
);
4747
}
4848
}

release-packaging/Classes/FluidBufNMFSeed.sc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FluidBufNMFSeed : FluidBufProcessor{
22

3-
*kr { |source, bases, activations, minComponents = 1, maxComponents = 200, coverage = 0.5, method = 0, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 0|
3+
*kr { |source, bases, activations, minComponents = 1, maxComponents = 200, coverage = 0.5, method = 0, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 0|
44

55
source.isNil.if {"FluidBufNMFSeed: Invalid source buffer".throw};
66
bases.isNil.if {"FluidBufNMFSeed: Invalid bases buffer".throw};
@@ -9,11 +9,11 @@ FluidBufNMFSeed : FluidBufProcessor{
99
bases = bases.asUGenInput;
1010
activations = activations.asUGenInput;
1111

12-
^FluidProxyUgen.kr1(\FluidBufNMFSeedTrigger, -1, source, bases, activations, minComponents, maxComponents, coverage, method, windowSize, hopSize, fftSize, fftSize, trig, blocking);
12+
^FluidProxyUgen.kr1(\FluidBufNMFSeedTrigger, -1, source, bases, activations, minComponents, maxComponents, coverage, method, seed, windowSize, hopSize, fftSize, fftSize, trig, blocking);
1313
}
1414

1515

16-
*process { |server, source, bases, activations, minComponents = 1, maxComponents = 200, coverage = 0.5, method = 0, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
16+
*process { |server, source, bases, activations, minComponents = 1, maxComponents = 200, coverage = 0.5, method = 0, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
1717

1818
source.isNil.if {"FluidBufNMFSeed: Invalid source buffer".throw};
1919
bases.isNil.if {"FluidBufNMFSeed: Invalid bases buffer".throw};
@@ -25,11 +25,11 @@ FluidBufNMFSeed : FluidBufProcessor{
2525
^this.new(
2626
server, nil, [bases,activations]
2727
).processList(
28-
[source, bases, activations, minComponents, maxComponents, coverage, method, windowSize, hopSize, fftSize, fftSize, 0],freeWhenDone, action
28+
[source, bases, activations, minComponents, maxComponents, coverage, method, seed, windowSize, hopSize, fftSize, fftSize, 0],freeWhenDone, action
2929
)
3030
}
3131

32-
*processBlocking { |server, source, bases, activations, minComponents = 1, maxComponents = 200, coverage = 0.5, method = 0, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
32+
*processBlocking { |server, source, bases, activations, minComponents = 1, maxComponents = 200, coverage = 0.5, method = 0, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, freeWhenDone = true, action|
3333

3434
source.isNil.if {"FluidBufNMFSeed: Invalid source buffer".throw};
3535
bases.isNil.if {"FluidBufNMFSeed: Invalid bases buffer".throw};
@@ -41,7 +41,7 @@ FluidBufNMFSeed : FluidBufProcessor{
4141
^this.new(
4242
server, nil, [bases,activations]
4343
).processList(
44-
[source, bases, activations, minComponents, maxComponents, coverage, method, windowSize, hopSize, fftSize, fftSize, 1],freeWhenDone, action
44+
[source, bases, activations, minComponents, maxComponents, coverage, method, seed, windowSize, hopSize, fftSize, fftSize, 1],freeWhenDone, action
4545
)
4646
}
4747
}

release-packaging/Classes/FluidMLP.sc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ FluidMLPRegressor : FluidModelObject {
55
const <relu = 2;
66
const <tanh = 3;
77

8-
var <>hiddenLayers, <>activation, <>outputActivation, <>tapIn, <>tapOut, <>maxIter, <>learnRate, <>momentum, <>batchSize, <>validation;
8+
var <>hiddenLayers, <>activation, <>outputActivation, <>tapIn, <>tapOut, <>maxIter, <>learnRate, <>momentum, <>batchSize, <>validation, <>seed;
99

10-
*new {|server, hiddenLayers = #[3,3] , activation = 2, outputActivation = 0, tapIn = 0, tapOut = -1,maxIter = 1000, learnRate = 0.0001, momentum = 0.9, batchSize = 50, validation = 0.2|
10+
*new {|server, hiddenLayers = #[3,3] , activation = 2, outputActivation = 0, tapIn = 0, tapOut = -1,maxIter = 1000, learnRate = 0.0001, momentum = 0.9, batchSize = 50, validation = 0.2, seed = -1|
1111

12-
^super.new(server, [hiddenLayers.size] ++ hiddenLayers ++ [activation, outputActivation, tapIn, tapOut, maxIter, learnRate, momentum, batchSize, validation])
12+
^super.new(server, [hiddenLayers.size] ++ hiddenLayers ++ [activation, outputActivation, tapIn, tapOut, maxIter, learnRate, momentum, batchSize, validation, seed])
1313
.hiddenLayers_(hiddenLayers)
1414
.activation_(activation)
1515
.outputActivation_(outputActivation)
@@ -19,11 +19,12 @@ FluidMLPRegressor : FluidModelObject {
1919
.learnRate_(learnRate)
2020
.momentum_(momentum)
2121
.batchSize_(batchSize)
22-
.validation_(validation);
22+
.validation_(validation)
23+
.seed_(seed);
2324
}
2425

2526
prGetParams{
26-
^[this.id, this.hiddenLayers.size] ++ this.hiddenLayers ++ [this.activation, this.outputActivation, this.tapIn, this.tapOut, this.maxIter, this.learnRate, this.momentum, this.batchSize, this.validation]
27+
^[this.id, this.hiddenLayers.size] ++ this.hiddenLayers ++ [this.activation, this.outputActivation, this.tapIn, this.tapOut, this.maxIter, this.learnRate, this.momentum, this.batchSize, this.validation, this.seed]
2728
}
2829

2930
clearMsg{ ^this.prMakeMsg(\clear, id) }
@@ -120,21 +121,22 @@ FluidMLPClassifier : FluidModelObject {
120121
const <relu = 2;
121122
const <tanh = 3;
122123

123-
var <>hiddenLayers, <>activation, <> maxIter, <>learnRate, <> momentum, <>batchSize, <>validation;
124+
var <>hiddenLayers, <>activation, <> maxIter, <>learnRate, <> momentum, <>batchSize, <>validation, <>seed;
124125

125-
*new {|server, hiddenLayers = #[3,3] , activation = 2, maxIter = 1000, learnRate = 0.0001, momentum = 0.9, batchSize = 50, validation = 0.2|
126-
^super.new(server,[hiddenLayers.size] ++ hiddenLayers ++ [activation, maxIter, learnRate, momentum, batchSize, validation])
126+
*new {|server, hiddenLayers = #[3,3] , activation = 2, maxIter = 1000, learnRate = 0.0001, momentum = 0.9, batchSize = 50, validation = 0.2, seed = -1|
127+
^super.new(server,[hiddenLayers.size] ++ hiddenLayers ++ [activation, maxIter, learnRate, momentum, batchSize, validation, seed])
127128
.hiddenLayers_(hiddenLayers)
128129
.activation_(activation)
129130
.maxIter_(maxIter)
130131
.learnRate_(learnRate)
131132
.momentum_(momentum)
132133
.batchSize_(batchSize)
133-
.validation_(validation);
134+
.validation_(validation)
135+
.seed_(seed)
134136
}
135137

136138
prGetParams{
137-
^[this.id, this.hiddenLayers.size] ++ this.hiddenLayers ++ [this.activation, this.maxIter, this.learnRate, this.momentum, this.batchSize, this.validation];
139+
^[this.id, this.hiddenLayers.size] ++ this.hiddenLayers ++ [this.activation, this.maxIter, this.learnRate, this.momentum, this.batchSize, this.validation, this.seed];
138140
}
139141

140142
clearMsg{ ^this.prMakeMsg(\clear,id) }

release-packaging/Classes/FluidNMFFilter.sc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FluidNMFFilter : FluidRTMultiOutUGen {
22

3-
*ar { arg in = 0, bases, maxComponents = 1, iterations = 10, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = -1;
4-
^this.multiNew('audio', in.asAudioRateInput(this), bases, maxComponents, maxComponents, iterations, windowSize, hopSize, fftSize, maxFFTSize);
3+
*ar { arg in = 0, bases, maxComponents = 1, iterations = 10, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = -1;
4+
^this.multiNew('audio', in.asAudioRateInput(this), bases, maxComponents, maxComponents, iterations, seed, windowSize, hopSize, fftSize, maxFFTSize);
55
}
66

77
init {arg ...theInputs;

release-packaging/Classes/FluidNMFMatch.sc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FluidNMFMatch : FluidRTMultiOutUGen {
22

3-
*kr { arg in = 0, bases, maxComponents = 1, iterations = 10, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = -1;
4-
^this.multiNew('control', in.asAudioRateInput(this), bases, maxComponents, maxComponents, iterations, windowSize, hopSize, fftSize, maxFFTSize);
3+
*kr { arg in = 0, bases, maxComponents = 1, iterations = 10, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = -1;
4+
^this.multiNew('control', in.asAudioRateInput(this), bases, maxComponents, maxComponents, iterations, seed, windowSize, hopSize, fftSize, maxFFTSize);
55
}
66

77
init {arg ...theInputs;

release-packaging/Classes/FluidNMFMorph.sc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
FluidNMFMorph : FluidRTUGen {
22

3-
*ar { arg source = -1, target = -1, activations = -1, autoassign = 1, interpolation = 0, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = -1;
3+
*ar { arg source = -1, target = -1, activations = -1, autoassign = 1, interpolation = 0, seed = -1, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = -1;
44

55
source = source ?? {-1};
66
target = target ?? {-1};
77
activations = activations ?? {-1};
88

9-
^this.new1('audio', source, target, activations, autoassign, interpolation, windowSize, hopSize, fftSize, maxFFTSize);
9+
^this.new1('audio', source, target, activations, autoassign, interpolation, seed, windowSize, hopSize, fftSize, maxFFTSize);
1010
}
1111

1212
init {arg ...theInputs;

release-packaging/Classes/FluidUMAP.sc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
FluidUMAP : FluidModelObject {
22

3-
var <>numDimensions, <>numNeighbours, <>minDist, <>iterations, <>learnRate;
3+
var <>numDimensions, <>numNeighbours, <>minDist, <>iterations, <>learnRate, <>seed;
44

5-
*new {|server,numDimensions = 2, numNeighbours = 15, minDist = 0.1, iterations = 200, learnRate = 0.1|
6-
^super.new(server,[numDimensions, numNeighbours, minDist, iterations, learnRate])
5+
*new {|server,numDimensions = 2, numNeighbours = 15, minDist = 0.1, iterations = 200, learnRate = 0.1, seed = -1|
6+
^super.new(server,[numDimensions, numNeighbours, minDist, iterations, learnRate, seed])
77
.numDimensions_(numDimensions)
88
.numNeighbours_(numNeighbours)
99
.minDist_(minDist)
1010
.iterations_(iterations)
11-
.learnRate_(learnRate);
11+
.learnRate_(learnRate)
12+
.seed_(seed);
1213
}
1314

1415
prGetParams{
@@ -19,6 +20,7 @@ FluidUMAP : FluidModelObject {
1920
this.minDist,
2021
this.iterations,
2122
this.learnRate,
23+
this.seed
2224
]
2325
}
2426

0 commit comments

Comments
 (0)