First time here? Check out the FAQ!
x

When is Smalltalk actually Capytalk (and how to spot)?

+1 vote
863 views
Hi Along with a few others I'm taking part in Never Engine Labs Rhythmic Computation Lab currently which is excellent. A question arose which is best asked here as it relates to general Kyma not the lab. I'm new to Kyma (ish) but have read lots, including Kyma X, but clearly misunderstood sonething. We're using a simple but of Smalltalk code within a parameter field to create 8 faders (Gates01 through Gates08) which control a generated Global !GenGate value: !GenGate {1 to: 8 collect: [:i | !gates suffix: i ] } I understand how this code works. Added to this though is then some Capytalk to add some random to the value of the gate generated: !GenGate {1 to: 8 collect: [:i | !gates suffix: i * (1 s tick random gt: 0)] } I understand the code here (i.e. what it's doing) but I'm confused how we're mixing Smalltalk and Capytalk in the same parameter box. My takeaway from Kyma X Revealed is that ST is evaluated before compiling and CT during and I was under the impression they couldn't be easily mixed like this (not without generating our own tools as it states on page 269 of Kyma X). Please could you explain a little or point me to where I should read again specifically? Many thanks Geoff
asked Jun 12, 2018 in Capytalk & Smalltalk by ghood (Master) (3,060 points)

2 Answers

+1 vote

To answer your question, yes it is possible to mix Capytalk and Smalltalk; there are lots of examples of mixing the two in the Kyma Sound Library and in Gallery-generated Sounds. In a parameter field, the Capytalk code is displayed in purple and Smalltalk is displayed in black (EventValues are red).

Here is your example with Smalltalk in bold (I've added some missing parentheses and removed the tick messsage since the correct syntax is either (1 s tick nextRandom) or (1 s random)):

{1 to: 8 collect: [ :i | (!gates suffix: i) * (1 s random gt: 0)]}

The result would be a collection of eight EventExpressions:

!Gates1 * (1 s random gt: 0)

!Gates2 * (1 s random gt: 0)

..

!Gates8 * (1 s random gt: 0)

answered Jun 12, 2018 by ssc (Savant) (127,060 points)
Thanks, appreciated. So I guess what I'm interested in is in when you can't mix them. As in, when is the statement on Page 269 of Kyma X true?
Thanks
Geoff
Hi Geoff, I couldn't find the statement you're asking about on that page, could you tell me which one you're referring to? Thanks!
By the way, just now I used "Smalltalk Capytalk" to search the PDF of KXR & it turned up a lot of information on how to use them together (in case it's useful).
Hi Carla
Now I feel like a wolly as upon reading the statement again with my new understanding I'm interpreting it differently.  I had (erroneously) been referring to this:
"Code in the MIDIVoice Script field (like Smalltalk code in any parameter field)
is compiled when you tell the Sound to play. Thus, the Smalltalk portion of the
code cannot execute conditionally based on live input. (For interactive, conditionally
executed Smalltalk code, see “Writing Your Own Tools” on page 309)"

I had upon knowing that Smalltalk is compiled prior to play, misunderstood (and mis-read!) this to be that what goes in a parameter box is either generated before OR can be conditionally executed using hotvalues - not both.  False alarm.  I now see that Page 253 of KXR perfectly describes the correct situation.  Apologies for my misunderstanding...annoyingly, now you have pointed it out I can see hundreds of examples of code that I understand which perfectly marry smalltalk and capytalk together...I'm not sure why i'd got it in my head that they couldn't be mixed.  

Coding doesn't come naturally to me but my head is full of the things it can do!

Thank you!
Thanks, Geoff, really glad you brought this up as it is one of the more mind-bending (and powerful!) features in Kyma. Thanks for the great questions!
0 votes

I like to think of Smalltalk scripts as a way of programatically creating more complex collective expressions or functions which involve Event Expressions. The Event driven language that is constantly evaluated in realtime is called Capytalk and allows you interact with the code running on the Pacarana. It is a dialect of Smalltalk (in that it uses Smalltalk syntax) except that it is the only way to program continuously changing music or sound related Events, hence the terms 'Event Driven' and 'Event Expressions'.  All event expressions in Capytalk are evaluated every millisecond and Smalltalk scripts are only evaluated at compile time. In Kyma, a user manipulates and interacts with realtime variables in Capytalk, but can also  (optionally) build a complex interactive program of Event Expressions by using a Smalltalk script which is evaluated before the program starts to run.

I wrote an informal guide for NeverEngine Labs Rhythmic Computation participants which may be useful alongside Carla's definitive guide in Kyma X Revealed...  you can download it at http://www.cristianvogel.com/neverenginelabs/product/rhythmic-computation-lab-2018 (scroll down the page to find the UserGuide download link )

answered Jun 13, 2018 by cristian-vogel (Master) (8,410 points)
edited Jun 14, 2018 by cristian-vogel
Thanks, Cristian! One correction: you write that: "All event expressions in Capytalk are evaluated every millisecond".
A Capytalk expression is evaluated whenever one of the values it depends on changes; they are event-driven. Only the expressions that depend on time are evaluated once per millisecond (since they depend on the millisecond clock value).
Thanks for clarifying - by time expressions, Carla means expressions such as
1 ramp: 10 s
or
1 bpm: !bpm

What I was trying to say is that the fastest possible update rate for a Capytalk expression is every millisecond.
I struggle sometimes to know which bits of an expression are SmallTalk and which are CapyTalk. Is there a guide to what the different syntax highlighting colours mean in the parameter fields?
Hi Alan. SmallTalk messages are in grey. SmallTalk variables are in green. CapyTalk (and HotValues ) are in purple and red
Fantastic that's really helpful thanks Cristian!
...