Hello all,
I’d like to choose different elements from a list every time an Array.series’ step argument creates a next element.
With rrand() this is easy:
(
~list = Array.series(
size: 10,
start: 100,
step: 100*{1+rand2(0.1)}
);
~test = Pbind(
\dur, 0.25,
\freq, Pseq(~list,2)
).play;
)
The distance between every element in ~list will be 100 and a deviation of + or - maximum 10%. But at each distance the deviation will be slightly different.
I’d like to replicate this with .choose, ie.:
(
~mrL = [0,3,7].midiratio;
~list = Array.series(
size: 10,
start: 100,
step: 100*{~mrL.choose}
);
~test = Pbind(
\dur, 0.25,
\freq, Pseq(~list,2)
).play;
)
So that with every step up, the distance will be either 100 + unison or 100 + third or 100 + fifth.
However, in this case SC 3.12.2 returns an error message:
ERROR: Message 'choose' not understood.
RECEIVER:
nil
ARGS:
PROTECTED CALL STACK:
Meta_MethodError:new 0x1170d1600
arg this = DoesNotUnderstandError
arg what = nil
arg receiver = nil
Meta_DoesNotUnderstandError:new 0x1170d3940
arg this = DoesNotUnderstandError
arg receiver = nil
arg selector = choose
arg args = [ ]
Object:doesNotUnderstand 0x11657a280
arg this = nil
arg selector = choose
arg args = nil
BinaryOpFunction:valueArray 0x117407a80
arg this = a BinaryOpFunction
arg args = [ ]
BinaryOpFunction:valueArray 0x117407a80
arg this = a BinaryOpFunction
arg args = [ ]
BinaryOpFunction:value 0x117407600
arg this = a BinaryOpFunction
arg args = nil
a FunctionDef 0x1188070c0
sourceCode = "#{
~freq.value + ~detune
}"
a FunctionDef 0x118818a40
sourceCode = "#{|server|
var freqs, lag, strum, sustain;
var bndl, addAction, sendGate, ids;
var msgFunc, instrumentName, offset, strumOffset;
// var schedBundleArray;
freqs = ~detunedFreq.value;
// msgFunc gets the synth's control values from the Event
msgFunc = ~getMsgFunc.valueEnvir;
instrumentName = ~synthDefName.valueEnvir;
// determine how to send those commands
// sendGate == false turns off releases
sendGate = ~sendGate ? ~hasG...etc..."
arg server = localhost
var freqs = nil
var lag = nil
var strum = nil
var sustain = nil
var bndl = nil
var addAction = nil
var sendGate = nil
var ids = nil
var msgFunc = nil
var instrumentName = nil
var offset = nil
var strumOffset = nil
a FunctionDef 0x118816e00
sourceCode = "#{
var tempo, server, eventTypes, parentType;
parentType = ~parentTypes[~type];
parentType !? { currentEnvironment.parent = parentType };
server = ~server = ~server ? Server.default;
~finish.value(currentEnvironment);
tempo = ~tempo;
tempo !? { thisThread.clock.tempo = tempo };
if(currentEnvironment.isRest.not) {
eventTypes = ~eventTypes;
(eventTypes[~type] ?? { eventTypes[\\note] }).value(server)
};
~callback.value(current...etc..."
var tempo = nil
var server = localhost
var eventTypes = ( 'fadeBus': a Function, 'freeAllocWrite': a Function, 'tree': a Function, 'on': a Function,
'load': a Function, 'freeBuffer': a Function, 'group': a Function, 'freeAllocRead': a Function, 'allocWrite': a Function,
'cue': a Function, 'grain': a Function, 'Synth': a Function, 'freeAllocWriteID': a Function, 'alloc': a Function,
'rest': a Function, 'sine2': a Function, 'sine1': a Function, 'midi': a Function, 'set': a Function,
'setProperties': a Function, 'parGroup': a Function, 'allocRead': a Fu...etc...
var parentType = nil
a FunctionDef 0x1187b8000
sourceCode = "<an open Function>"
Function:prTry 0x117397740
arg this = a Function
var result = nil
var thread = a Routine
var next = nil
var wasInProtectedFunc = false
CALL STACK:
DoesNotUnderstandError:reportError
arg this = <instance of DoesNotUnderstandError>
Nil:handleError
arg this = nil
arg error = <instance of DoesNotUnderstandError>
Thread:handleError
arg this = <instance of Thread>
arg error = <instance of DoesNotUnderstandError>
Thread:handleError
arg this = <instance of Routine>
arg error = <instance of DoesNotUnderstandError>
Object:throw
arg this = <instance of DoesNotUnderstandError>
Function:protect
arg this = <instance of Function>
arg handler = <instance of Function>
var result = <instance of DoesNotUnderstandError>
Environment:use
arg this = <instance of Event>
arg function = <instance of Function>
var result = nil
var saveEnvir = <instance of Environment>
Event:play
arg this = <instance of Event>
Event:playAndDelta
arg this = <instance of Event>
arg cleanup = <instance of EventStreamCleanup>
arg mute = false
EventStreamPlayer:prNext
arg this = <instance of EventStreamPlayer>
arg inTime = 10720.126477272
var nextTime = nil
var outEvent = <instance of Event>
< FunctionDef in Method EventStreamPlayer:init >
arg inTime = 10720.126477272
Routine:prStart
arg this = <instance of Routine>
arg inval = 10720.126477272
^^ ERROR: Message 'choose' not understood.
RECEIVER: nil
This issue - to my understanding - can be resolved with Array.fill:
(
~mrL = [0,3,7].midiratio;
~list = Array.fill(
size: 10,
function: { |i| i+1*100*~mrL.choose});
~test = Pbind(
\dur, 0.25,
\freq, Pseq(~list,2)
).play;
)
However, I was wondering if this can be achieved with Array.series in a simple/concise way?
Thanks,
cd