First time here? Check out the FAQ!

Can I pass EventVariables from a Script?

+1 vote


I am trying to optimise my GlobSeq code, and thought I could move some of it to a script. But I'm running into this '#asEvent' error.



asked Jul 25, 2018 in Capytalk & Smalltalk by cristian-vogel (Master) (8,370 points)

1 Answer

+2 votes

You are using the assign-plus-pop so the Capytalk expression stored in c has a side-effect but no value. But the problem generating that error message is that you cannot send triggerEvery: to a Sound; you can only send it to an EventValue. To convert a Sound to an EventValue, you can send it the message L (to get its left output) or R (to get its right output).

The following version of your Script works:

| c |

c := ClockStream sound L triggerEvery: 2.
(inputs at: 1) start: 0 s index: c.

answered Jul 25, 2018 by ssc (Savant) (118,030 points)
This has been an amazing help. Thankyou!

What I have learned is that I can cast an Input to a Script as a SOUND and pass it then as a lifted variable. Before I was using a complicated signal flow technique, pasting 'Variable' Sounds -- turns out ( in what I am currently programming at least ) that this was no way near as efficient on replication, as the method you described above --- never stop learning new tricks in Kyma!