First time here? Check out the FAQ!
x

StepSequencer index from script?

0 votes
368 views

Is it possible to generate a StepSequencer's Generated Index from a script? I'm looking at Jon Bellona's TSV tutorial, which has the following suggestion: 

One way to view the bound EventValues in the VCS is to place the EventValue we are controlling (e.g. !Pan) in the Value field of a SoundToGlobalController. The SoundToGlobalController generatedEvent parameter could be something like !PanMonitor. That would cause !PanMonitor to display the data-driven changes to !Pan in the VCS.

I've tried doing this in Jon's patch but I can't get it to work (I put the SoundToGlobalController at the end, right after the MidiVoice - maybe that's the wrong place).

In my own project, I'm using a script to read through a text file (a big DNA string), using "Make a StepSequencer from a Text file" by ssc (this is a little different because Jon's project doesn't use StepSequencer). 

I'd like the VCS to show how far we are through the text file. Right now I'm doing that with the GeneratedIndex field of StepSequencer; but I have to manually set the maximum value of the slider (in this case, 5000). But if I use a different text file, the length will be different. Is there any way to set the maximum value of a fader in the VCS from a script? Or would SoundToGlobalController be the solution?

Thanks for any ideas!

asked Jul 1, 2016 in Capytalk & Smalltalk by stephen-taylor (Adept) (1,620 points)

1 Answer

0 votes

You could create a normalized progress meter by adding a SoundToGlobalController to your Script inputs.  Set the value of the STGC to the index generated by the StepSequencer (in this case it is !Stage) 

!Stage / ?fileLength

Then in the Script, start the STGC and set the value of ?fileLength to the size of your file (since you are reading from a text file, you can simply use the size of the file stream).  So the loop would become:

[f atEnd] whileFalse: [
    nbr := f next asInteger.
    (nbr < 97) ifTrue: [durs add: 1] ifFalse: [durs add: 0.25].
    pitches add: (nbr max: 20)].
seq start: 0 s length: f size pitches: pitches durations: durs.
stgc start: 0 s fileLength: f size.

 

 Here's an example Sound to show what I mean.  It will show you the current stage as a fraction of the total sequence.  To change it to a count down timer, you could use:

1 - (!Stage / ?fileLength)

 

answered Jul 1, 2016 by ssc (Savant) (128,120 points)
Fantastic, thanks so much! That is particularly nice to see that the seq and stgc variables show up as red in the script - I did not realize how that worked.
...