Kyma Forum
  Tips & Techniques
  Keywords. What are they exactly?

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Keywords. What are they exactly?
TazioSchiesari
Member
posted 29 May 2013 04:53         Edit/Delete Message   Reply w/Quote
Hello folks!

I just joined this amazing environment and like probably most of you have I'm reading the manual.
One of the things I seems not to fully understand is the concept of "Keywords".

At page 225 at the bottom the book states: "A keyword message takes two or more arguments (all EventExpressions), and is composed of a sequence of keywords, each of which is followed by a colon ( and an argument."
Thats fine, but considering the colon rule above I don't understand why a Keyword message like "60 nn hz" is not "60 nn: hz:"

Could anybody clear this out for me?

Tazio


IP: Logged

Phi Curtis
Member
posted 30 May 2013 23:43         Edit/Delete Message   Reply w/Quote
Hi Tazio,

I'm no Smalltalk expert (Smalltalk being the language that Capytalk is derived from - they share syntax, and this question relates to basic Smalltalk syntax) - I'm sure there are a lot of people more qualified to answer this question here, but I'll give it a shot.

Keyword messages are one of several different kinds of message, in which the message involves one or more arguments. Take for example the Capytalk message:

!KeyNumber gt: 60

Here the receiver (the recipient of the message) is the hot parameter !Keynumber, the message is gt: (greater than), and the parameter involved is 60. Basically it's saying something like "given the variable number !KeyNumber, tell me when it is greater than 60." So when !KeyNumber is greater than 60, the whole expression equals 1, and when !KeyNumber is not greater than 60, the expression equals 0.

If there's more than one parameter, the Keyword expression takes form:
[Receiver] keywordPart1: argument keywordPart2: argument.

Together, what I'm calling keywordPart1: and keywordPart2: are a single message which takes 2 arguments.

For example, here is the message true: false: in use:

[comparison expression] true: 0 false: !KeyNumber

Pasting in our other expression for the [comparison expression], you could turn this into:

((!KeyNumber gt: 60) true:0 false:!KeyNumber)

Now when our original expression asking if !KeyNumber is greater than 60 becomes a 1 (true), that triggers the true: part of the message, which makes the entire expression equal to the argument 0. If, however, !KeyNumber is 60 or under, the false: argument is invoked, and !KeyNumber is returned (or, !Keynumber is allowed to pass through unaltered, so that effectively you've just turned !KeyNumber values above 60 to 0).

Hope that makes some sense.

The other message type you mention is binary, which don't have any arguments.

In the expression "60 nn" the receiver, the NUMBER 60, is converted by the message "nn" into a different type of object, a NOTE NUMBER (basically a midi note number, where 60 equals middle c). The expression "hz", when sent to a receiver that is a note number, converts the note number into hz. So it wouldn't be 60 nn: hz, because hertz isn't functioning as an argument in the expression - the whole expression is actually one binary receiver/message pair, followed by another receiver/message pair. The first pair is "60 nn," which is converting a number 60 into a note number 60, and the second receiver/message pair is the note number 60, which is receiving the message from hz, converting it to hz (which I believe rounds to 261 hz).

Hope that helps.

You might try looking online for resources explaining Smalltalk syntax. I just found a bunch of videos that I should watch at:
http://smalltalk.org/videos/video_Basics_Block.html

Good luck!

Phil


[This message has been edited by Phi Curtis (edited 30 May 2013).]

[This message has been edited by Phi Curtis (edited 30 May 2013).]

IP: Logged

SSC
Administrator
posted 31 May 2013 11:00         Edit/Delete Message   Reply w/Quote
Thanks Phil!

There are also some examples and explanations in Kyma X Revealed which you can access from the Help menu in Kyma and search for "keyword". For example on page 225:

quote:

A unary message has one argument (the receiver), for example

!Fader negated

A binary message has two arguments (also EventExpressions), for example

!Fader1 + !Fader2

A keyword message takes two or more arguments (all EventExpressions), and is composed of a sequence of keywords, each of which is followed by a colon ( :) and an argument. The number of keywords equals the number of arguments, and the ordering of the keywords is an essential property of the message. In other words, all of the keywords taken together form the “keyword message”. For example, if you wanted to define the CapyTalk keyword message

!Trig bpm: !BPM dutyCycle: !Duty

with all of the keywords combined to form the name of the function as a C function, it would probably come out looking something like this:

bpmWithDutyCycle (!Trig, !BPM, !Duty)


[This message has been edited by SSC (edited 31 May 2013).]

IP: Logged

Phi Curtis
Member
posted 31 May 2013 19:54         Edit/Delete Message   Reply w/Quote
Ah, yes... "60 nn" is an example of a unary message, not binary. And and "60 nn hz" two unary messages (the "hz" message working on the result of the first unary message).

I think what can be initially confusing about a message like "1 bpm: 60" is that the receiver, 1, is just a number (a number acting as a trigger, but still just a number). The idea that numbers can be made to launch a repeating pulse seems a little abstract.

Phil

IP: Logged

SSC
Administrator
posted 31 May 2013 20:27         Edit/Delete Message   Reply w/Quote
Hi Phil,

"I think what can be initially confusing about a message like "1 bpm: 60" is that the receiver, 1, is just a number (a number acting as a trigger, but still just a number). The idea that numbers can be made to launch a repeating pulse seems a little abstract."

That's true. Maybe it would be more clear if we started with an example where the metronome can be turned on or off, so

!Gate bpm: 60

and then explain that a !Gate value of 0 is off and !Gate value of 1 is on, and only then proceed to:

1 bpm: 60

as a gate that is permanently stuck in the ON position.

You're right, though, nearly everything in CapyTalk requires a trigger to make it happen.

IP: Logged

TazioSchiesari
Member
posted 04 June 2013 11:13         Edit/Delete Message   Reply w/Quote
Thanks a lot guys they make more sense to me now!

Bests,
Tazio

IP: Logged

SeanFlannery
Member
posted 20 June 2013 20:01         Edit/Delete Message   Reply w/Quote
@SSC

This aspect of 1 !BPM has had me wondering why it was so since the first time I saw it.

Finally the penny drops.

thanks

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c