![]() |
![]() ![]() ![]() ![]() ![]()
|
next newest topic | next oldest topic |
Author | Topic: Keywords. What are they exactly? |
TazioSchiesari Member |
![]() ![]() ![]() Hello folks! I just joined this amazing environment and like probably most of you have I'm reading the manual. 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 ( Could anybody clear this out for me? Tazio IP: Logged |
Phi Curtis Member |
![]() ![]() ![]() 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: 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: Good luck! Phil
[This message has been edited by Phi Curtis (edited 30 May 2013).] IP: Logged |
SSC Administrator |
![]() ![]() ![]() 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: [This message has been edited by SSC (edited 31 May 2013).] IP: Logged |
Phi Curtis Member |
![]() ![]() ![]() 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 |
![]() ![]() ![]() 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 |
![]() ![]() ![]() Thanks a lot guys they make more sense to me now! Bests, IP: Logged |
SeanFlannery Member |
![]() ![]() ![]() @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 |
![]() ![]() |
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.