Kyma Forum
  Kyma Support
  testing if ?VoiceNumber is odd or even

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

next newest topic | next oldest topic
Author Topic:   testing if ?VoiceNumber is odd or even
cristian_vogel
Member
posted 16 January 2008 09:47         Edit/Delete Message   Reply w/Quote
what would be a simple expression to test if a HotValue or parameter like ?VoiceNumber is odd or even?

IP: Logged

SSC
Administrator
posted 16 January 2008 10:41         Edit/Delete Message   Reply w/Quote
?VoiceNumber is known at compile time so you could use the Smalltalk message 'even' which returns a boolean true or false, for example:

code:

?VoiceNumber even ifTrue: [!Evens] ifFalse: [!Odds]

To test the odd/evenness of a hot value (not known at compile time, so you have to use CapyTalk) you could test whether it is 0 in mod 2 arithmetic, for example:

code:

((!Formant rounded mod: 2) eq: 0)

When you count modulo 2, the sequence <0 1 2 3 4 5...> is <0 1 0 1 0 1...>, so the expression is true when !Formant is ODD (in CapyTalk 1 is true and 0 is false).

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