First time here? Check out the FAQ!
x

Visible Script Information

0 votes
889 views

I have made a sound where the script reads a .txt file to control parameters. I would like the sound to inform me when it has completed all the lines in the text and/or show which line it is reading so I can use this information to cue another sound.

Thanks.

http://kyma.symbolicsound.com/qa/?qa=blob&qa_blobid=11518554564070911

asked Aug 26, 2019 in Capytalk & Smalltalk by anne-la-berge (Adept) (2,170 points)
Can you post the script that you're using?
| f params line rate duty freq pan |


f :=  'Skywatch_11-26aug2019.txt' asFilename textFileStream.

    line := 0.
    [f atEnd] whileFalse: [
        params := f nextParameters.

    "2nd parameter, temp controls BPM fader."
    "min: 22.2 and max: 36.5"
    rate := ((params at: 2) into: #({22.2@500.0} {36.5@1500.0}) ) abs.
    self controller: !Rate slideTo: rate byTime: (line * 500) ms.

    "3rd parameter, humidity controls DutyCycle fader."
    "min: 28.6 and max: 87.0"
       duty := ((params at: 3) into: #({28.6@0.3} {87.0@0.65}) ) abs.
    self controller: !DutyCycle slideTo: duty byTime: (line * 500) ms.

       "1st parameter, wind, controls pan."
    "min: 0.0 and max: 3.3"
        pan := ((params at: 1) into: #({0.0@0.3} {3.3@1.0}) ) abs.
    self controller: !Pan slideTo: pan byTime: (line * 500) ms.

       "2nd parameter, temp, controls Frequency."
    "min: 22.2 and max: 36.5"
    freq := ((params at: 2) into: #({22.2@106.0} {36.5@110.0}) ) abs.
    self controller: !Frequency slideTo: freq byTime: (line * 500) ms.


     line := line + 1
].

2 Answers

+1 vote
 
Best answer

This is a bit of a wild guess but could you add something like this after the script (ie on a new line after the final "]."):

 

self controller: !Progress setTo: 1 atTime: (line * 500) ms.

I'm wondering if that would give you a !Progress fader that would become 1 when the scripted events have finished (or to be precise 500ms after the final event has slid to its value). 

----

I had a chance to try this out now. Any controller I put in the script isn't visible in the VCS. But if I put a SoundToGlobalController to the left of the script I can display that controller. So for the example above create an STGC with these parameters:

GeneratedEvent: !VisibleProgress
Value: !Progress

!VisibleProgress should turn up on the VCS and show the value of !Progress.  

 

answered Aug 27, 2019 by alan-jackson (Virtuoso) (15,840 points)
selected Sep 11, 2019 by anne-la-berge
Nice try!
It doesn't show the !Progress in the VCS.
Any other ideas?
I can calculate the timing by using the ms per line and number of lines but it would be more cool to have the sound send a message when it's finished it's #of lines. Would it be better to put that in a calculation/clock that runs separately?
Ah... yes.... I've edited my answer. Hopefully that will work.
The Visible Progress Shows up in the VCS but it doesn't show any action.
The script looks like this:
| f params line rate duty freq pan |


f :=  'Skywatch_11-28aug2019.txt' asFilename textFileStream.

    line := 0.
    [f atEnd] whileFalse: [
        params := f nextParameters.

    "2nd parameter, temp controls BPM fader."
    "min: 22.2 and max: 36.5"
    rate := ((params at: 2) into: #({22.2@500.0} {36.5@1500.0}) ) abs.
    self controller: !Rate slideTo: rate byTime: (line * 100) ms.

    "3rd parameter, humidity controls DutyCycle fader."
    "min: 28.6 and max: 87.0"
       duty := ((params at: 3) into: #({28.6@0.3} {87.0@0.65}) ) abs.
    self controller: !DutyCycle slideTo: duty byTime: (line * 100) ms.

       "1st parameter, wind, controls pan."
    "min: 0.0 and max: 4.4"
        pan := ((params at: 1) into: #({0.0@0.3} {4.4@0.9}) ) abs.
    self controller: !Pan slideTo: pan byTime: (line * 100) ms.

       "2nd parameter, temp, controls Frequency."
    "min: 22.2 and max: 36.5"
    freq := ((params at: 2) into: #({22.2@106.0} {36.5@110.0}) ) abs.
    self controller: !Frequency slideTo: freq byTime: (line * 100) ms.


     line := line + 1
].

self controller: !Progress setTo: 1 atTime: (line * 100) ms.

And I put the STGC in a mixer just to the left of the MidiVoiceDescription Sound with the script in it.

Where can I upload the sound so you can have a look at it?

Thanks!
I also tried putting the self controller: !Progress code above the line:=line +1 and that also has the same results except the VCS reads 1 instead of 0.

| f params line rate duty freq pan |


f :=  'Skywatch_11-28aug2019.txt' asFilename textFileStream.

    line := 0.
    [f atEnd] whileFalse: [
        params := f nextParameters.

    "2nd parameter, temp controls BPM fader."
    "min: 22.2 and max: 36.5"
    rate := ((params at: 2) into: #({22.2@500.0} {36.5@1500.0}) ) abs.
    self controller: !Rate slideTo: rate byTime: (line * 100) ms.

    "3rd parameter, humidity controls DutyCycle fader."
    "min: 28.6 and max: 87.0"
       duty := ((params at: 3) into: #({28.6@0.3} {87.0@0.65}) ) abs.
    self controller: !DutyCycle slideTo: duty byTime: (line * 100) ms.

       "1st parameter, wind, controls pan."
    "min: 0.0 and max: 4.4"
        pan := ((params at: 1) into: #({0.0@0.3} {4.4@0.9}) ) abs.
    self controller: !Pan slideTo: pan byTime: (line * 100) ms.

       "2nd parameter, temp, controls Frequency."
    "min: 22.2 and max: 36.5"
    freq := ((params at: 2) into: #({22.2@106.0} {36.5@110.0}) ) abs.
    self controller: !Frequency slideTo: freq byTime: (line * 100) ms.

        self controller: !Progress setTo: 1 atTime: (line * 100) ms.

     line := line + 1


].
Hi Anne,

You may need to set the value to zero at the beginning of the script, before the loop. Try adding
self controller: !Progress setTo: 0 atTime: 0 ms.
Here's another version of your script with two progress indicators. One called !Progress which continually slides from zero to one over the duration of the file. Map that to another EventValue using a SoundToGlobalController, eg. !VisibleProgress and display that as a fader.

The other indicator is called !Finished. Again you need to map that with an STGC to another EventValue, eg. !VisibleFinished. That value is zero until the file is finished and then it becomes 1.

I've tested these and they're working for me after the latest kyma update.

----

| f params line rate duty freq pan |


f :=  'Skywatch_11-28aug2019.txt' asFilename textFileStream.

    line := 0.
    [f atEnd] whileFalse: [
        params := f nextParameters.

    "2nd parameter, temp controls BPM fader."
    "min: 22.2 and max: 36.5"
    rate := ((params at: 2) into: #({22.2@500.0} {36.5@1500.0}) ) abs.
    self controller: !Rate slideTo: rate byTime: (line * 100) ms.

    "3rd parameter, humidity controls DutyCycle fader."
    "min: 28.6 and max: 87.0"
       duty := ((params at: 3) into: #({28.6@0.3} {87.0@0.65}) ) abs.
    self controller: !DutyCycle slideTo: duty byTime: (line * 100) ms.

       "1st parameter, wind, controls pan."
    "min: 0.0 and max: 4.4"
        pan := ((params at: 1) into: #({0.0@0.3} {4.4@0.9}) ) abs.
    self controller: !Pan slideTo: pan byTime: (line * 100) ms.

       "2nd parameter, temp, controls Frequency."
    "min: 22.2 and max: 36.5"
    freq := ((params at: 2) into: #({22.2@106.0} {36.5@110.0}) ) abs.
    self controller: !Frequency slideTo: freq byTime: (line * 100) ms.

        

     line := line + 1


].

self controller: !Finished setTo: 0 atTime: 0 s.
self controller: !Finished setTo: 1 atTime: ((line - 1) * 100) ms.

self controller: !Progress setTo: 0 atTime: 0 s.
self controller: !Progress slideTo: 1 steps: 100 byTime: ((line - 1) * 100) ms.
Dear Alan,
This works great!

I'll be submitting more questions soon since I'm on a roll with my data.

Anne
+1 vote
The Script has completely finished before the Sound starts to play. You can use self debug: in a Script to give you feedback while the Script is compiling but that wouldn’t allow for making choices while the Sound is playing. Is the text file different each time you play?
answered Aug 27, 2019 by ssc (Savant) (128,080 points)
The two steps in my programming skills that I would love to make are:
Using the self debug if that will give me access to the data as it is being used.
Being able to load a different data file in another way than typing in the name of the file in the beginning of the script and making a new sound.
...