First time here? Check out the FAQ!
x

Control an Array of HotValues via a Script?

+1 vote
680 views

Starting from the "Select Partials from Grid" Sound, I have 

TrackNumber of: {((0 to: 64) collect: [ :i | !Fader suffix2: i ] )}  inside the AmpScale field.  This is fine for turning individual partials up and down in volume in the VCS, but I am looking to control these !Faders from a data file. Hence, I am looking to control an Array via a Script.  Should I try controlling !Fader01 !Fader02, etc. values via Script?  Collect TrackNumber amplitudes as Collection inside the Script?  Any point to an existing Sound or example would be much appreciated.

I know I jumped into the deep end on this one. I wasn't able to locate TrackNumber in the manual. Only inside Sounds. As a side, I also feel like my loops are creating multiples of the Sound, not looping on TrackNumber.

Thanks all!

My culled example Sounds: http://kyma.symbolicsound.com/qa/?qa=blob&qa_blobid=3400754592562117064

asked Feb 18, 2016 in Capytalk & Smalltalk by jonbellona (Adept) (1,360 points)

2 Answers

+1 vote
 
Best answer

To create a spectrum that smoothly changes its partial amplitudes over time according to what you read from a data file, start with a MIDIVoice and select Script as the Source.  The "instrument" can be the Sound you already have, with

 TrackNumber of: {!Fader copies: 65}

in the AmpScale field.  Then, in the Script field of the MIDIVoice, you can use something like this (of course substituting the name of your own data file and ensuring that the ranges of your data points are (0,1) or scaling/offsetting them in your Script to make sure they are in the right range for the AmpScale controls.  You may prefer to use another way of incrementing time; I just used the line number as the start time in seconds.  This assumes that you have 65 or fewer data variables on each line of your text file:

| f params line |

    f :=  'yourDataFile.txt' asFilename textFileStream.

    line := 0.
    [f atEnd] whileFalse: [
        params := f nextParameters.
 
        1 to: params size do: [ :i |
            self controller: (i - 1 of: {!Fader copies: 65}) slideTo: (params at: i) abs byTime: line s].
        line := line + 1].

answered Feb 18, 2016 by ssc (Savant) (128,200 points)
selected Feb 18, 2016 by jonbellona
I'm no cat lover, but that answer was Purrfect. Answered my unspoken question about updating time within a script sans MIDI message. Thank you!
+1 vote

Hey Jon,

I think the best way is to collect the array in the script and copy the code:

| AmpArray |

AmpArray := {(1 to: 64) collect: [ :i | !Fader suffix2: i ]}.

(inputs at: 1) start: 0

AmpArray: AmpArray

Then use TrackNumber of: ?AmpArray in the parameter field (or maybe (TrackNumber - 1), I think it starts at 1). This will give you the same result but controlled by a script, so you can go on from there and collect your array from a data file or whatever. If you use an OrderedCollection or some other type of collection make sure to convert it into an array before sending it with the script (using asArray).

Not sure about your looping thing, not with Kyma at the moment so I can't have a look at your Sound.

Cheers,

Gustav

 

 

answered Feb 18, 2016 by kymaguy (Virtuoso) (10,580 points)
Got it to work. Thanks Gustav.  the (inputs at: 1) start: 0 pitched the formants? or morph? up, but by replacing the name of my input Sound "partials" (e.g. partials start: 0 s), I am off and running.  Wow. For not being inside Kyma, you nailed it!  Thanks!
Hi Gustl,
Thanks for helping Jon!

To avoid potential conflicts with class names, we strongly recommend starting local and temporary variables with lowercase letters (since global variables and class names in Smalltalk start with uppercase letters).
@Jon You're welcome :) The side effect is possibly because you were using more than one input to the script, I just used (inputs at: 1) because as long as you are using a single input it always works.. anyway, glad you got it to work! for your specific task SSCs approach of using a MIDIVoice is of course better :)
@SSC yes, thanks for making that clear, I've never run into problems yet but I'll try to use smalltalk with style ;)
BTW does that mean I could also define GlobalVariables in a script?
...