Kyma Forum
  Kyma Support
  what does 'Hot variables cannot perform..' mean actually

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

next newest topic | next oldest topic
Author Topic:   what does 'Hot variables cannot perform..' mean actually
cristian_vogel
Member
posted 08 April 2006 14:06         Edit/Delete Message   Reply w/Quote
i'm trying to write this little bit of code for a 'drunk' controller in the frequency field, alternating between forwards and backwards but with more of a chance of going forwards again than to go backwards in the first place

but I just don't get why the compiler doesn't let me do this!!!

| trig rnd |
rnd := (1 bpm: !BPM) nextRandomWithSeed: 55.
trig := (( 1 toggleWhen: (rnd gt: 0.9)) countTriggersMod: 2) of: #(1 -1).
trig negative
IfTrue: [
trig := (( 1 toggleWhen: (rnd gt: 0.3)) countTriggersMod: 2) of: #(0 1)
].

(default * trig) smooth: 0.5s


it says 'hot variable cannot perform...' but its not a hot variable really is it?

IP: Logged

SSC
Administrator
posted 08 April 2006 16:17         Edit/Delete Message   Reply w/Quote
"trig := (( 1 toggleWhen: (rnd gt: 0.9)) countTriggersMod: 2) of: #(1 -1).
trig negative
IfTrue: [
trig := (( 1 toggleWhen: (rnd gt: 0.3)) countTriggersMod: 2) of: #(0 1)
]."

I notice a couple of problems. There is no CapyTalk message called "negative"; thus you cannot test the value of trig (which is a CapyTalk expression) in this way. Secondly, the Smalltalk expression ifTrue: should not have an uppercase "I" but should start with a lowercase "i"

IP: Logged

SSC
Administrator
posted 08 April 2006 16:36         Edit/Delete Message   Reply w/Quote
If I understand your intentions, the following CapyTalk expression would be one way to do this:

| r |

r := (1 bpm: !BPM) nextRandom abs.
default * (((r gt: 0.3) true: ((r gt: 0.9) true: -1 false: 1) false: 0) smooth: 0.5 s

This generates a new random number (-1,1) on each beat and takes the absolute value so the range is (0,1).

Depending on the value of the random number, choose a multiplier for default:

r between 0 and 0.3: multiply by 0
r between 0.3 and 0.9: multiply by 1
r between 0.9 and 1: multiply by -1

IP: Logged

cristian_vogel
Member
posted 08 April 2006 16:38         Edit/Delete Message   Reply w/Quote
i know its painstaking...

but!

i have now refined it to this, which seems to be working syntax wise and I understand it..

BUT... it doesn't ever seem to enter into the ifTrue block ( i have put some exagerrated values in the fwd: array , but its never entering that block... ermm...

| bkwd rnd rnd2 pulse|
pulse := (1 bpm: (!BPM * 8)).
rnd := pulse nextRandomWithSeed: 55.
rnd2 := pulse nextRandom.
bkwd := (( pulse toggleWhen: (rnd ge: 0.90)) countTriggersMod: 2) of: #(1 -1) .

(bkwd = -1)
ifTrue: [ | fwd |
fwd := (( pulse toggleWhen: (rnd2 ge: 0.10)) countTriggersMod: 2) of: #(2 -2) .
(default * fwd) smooth: 0.2s .

]

ifFalse:[
(default * bkwd) smooth: 0.2s
].


IP: Logged

cristian_vogel
Member
posted 08 April 2006 16:41         Edit/Delete Message   Reply w/Quote
I'll check out your suggestion now , of course its much more streamlined - I was into using the random-triggered countTriggersMod as a switching mechanism for choosing values sequentually from an array, to allow for really wildstyle drunken DJing - but i can't figure out this conditional stuff and now i really do need a drink! - next time i try something, it'll be easier i'm sure..

edit
"| r |
r := (1 bpm: !BPM) nextRandom abs.
default * (((r gt: 0.3) true: ((r gt: 0.9) true: -1 false: 1) false: 1) smooth: 0.5 s)"

gives me the sort of result i was after, thanks

[This message has been edited by cristian_vogel (edited 08 April 2006).]

IP: Logged

SSC
Administrator
posted 08 April 2006 16:44         Edit/Delete Message   Reply w/Quote
An alternative approach is to create a "dartboard" where some numbers take up a larger "area" of the dartboard and are therefore easier to hit with your random dart. For example

-=-
| direction |

direction := ((1 bpm: !BPM) nextRandom abs * 10) of: #(0 0 0 1 1 1 1 1 1 -1).
default * direction smooth: 0.5 s.

-=-

This version generates a random number, takes the absolute value, multiplies it by 10 so it is (0,10), uses that as an index into an array that has more 1s in it than -1s so it is more likely to go forward than backward (and a little bit likely to be silent).

IP: Logged

cristian_vogel
Member
posted 08 April 2006 16:52         Edit/Delete Message   Reply w/Quote
quote:
Originally posted by SSC:
An alternative approach is to create a "dartboard" where some numbers take up a larger "area" of the dartboard and are therefore easier to hit with your random dart.

A-ha! Random Darts and a Drunk DJ - Sounds like a quality night out to me!


IP: Logged

cristian_vogel
Member
posted 09 April 2006 05:31         Edit/Delete Message   Reply w/Quote
I'm just writing this little expression, so I can learn about conditionals ..

there's still something's unclear

I'll go back to my array indexing example - it has a different behavior to random darts style... once its going backwards, the probabilities that it will go forward again is different.

So, in this example, the compiler works fine if the conditional is

(direction = -1 )

also works fine if

(direction ~= -1 )

but gives me the 'Hot variables cannot perform..'

with

(direction < 0 )

or ( direction <=0 ) or ( direction negative )

this is the part I really want to understand , before going further - why doesn't the compiler want to compile theses SmallTalk messages?

| randomPulse direction |
randomPulse := (1 bpm:!BPM) nextRandom asLogicValue.
direction := ( randomPulse countTriggersMod: 4) of: #(1 1 1 -1).
(direction = -1 )
ifTrue:[
direction := (( 1 bpm: (!BPM )) nextRandom abs * 4) of: #(1 1 -0.5 -1).
].
default * direction smooth: 0.2 s.

IP: Logged

SSC
Administrator
posted 09 April 2006 12:20         Edit/Delete Message   Reply w/Quote
In CapyTalk, the tests are:

eq: (for =)
lt: (for < )
le: (for <=)
ne: (for ~=)

etc...

You cannot do a Smalltalk equality test on a CapyTalk expression because the Smalltalk is evaluated on the parameter field *before* the Sound starts playing and before those CapyTalk expressions start changing value.

IP: Logged

cristian_vogel
Member
posted 10 April 2006 03:49         Edit/Delete Message   Reply w/Quote
thats what i figured , but the when I try a Capytalk expression like eq: , the compiler gives me an error regarding the ifTrue message . .

IP: Logged

SSC
Administrator
posted 10 April 2006 09:19         Edit/Delete Message   Reply w/Quote
In CapyTalk, after the test, you would use the true: message (not a Smalltalk message). For example:

(!KeyNumber eq: 72) true: (1 ramp: 1 s)

IP: Logged

cristian_vogel
Member
posted 10 April 2006 09:43         Edit/Delete Message   Reply w/Quote
And can true: and false: evaluate optional blocks of code according to the result, in the same way ifTrue [ ] does?

IP: Logged

SSC
Administrator
posted 10 April 2006 10:18         Edit/Delete Message   Reply w/Quote
true:, false:, and true:false: take expressions as arguments (as opposed to Smalltalk blocks for the ifTrue:, ifFalse:, and ifTrue:ifFalse: messages). Please see the CapyTalk quick reference on page 370 and the CapyTalk section on conditional expressions, page 251.

IP: Logged

cristian_vogel
Member
posted 11 April 2006 06:26         Edit/Delete Message   Reply w/Quote
SSC , i'm sorry i'm being slow here, believe me i won't be the last to get confused by this!

So, just to clarify...


When you want to evaluate code after the sound has started running, you must think in terms of Capytalk, the dynamic variable language.

In Capytalk, there aren't blocks like in Smalltalk, but expressions, right?

so a program can't run through iterative loops or other SmallTalk processes dynamically - for example , once the sound is running, could the program test if a condition is true ( a !sw01 down for example) and then execute differnt bits of looped code to re-generate the contents of an array?

IP: Logged

SSC
Administrator
posted 11 April 2006 08:56         Edit/Delete Message   Reply w/Quote
You could make the array conditional, e.g.

!sw01 true: #(1 2 3) false: #(3 2 1)

or you could make each element of the array depend on some condition, eg.
#({!sw01 true: 1 false: 3} 2 {!sw01 true: 3 false: 1})

If you prefer to use Smalltalk instead, take a look through the Kyma X Revealed chapter on building Tools. In a Tool, you specify blocks of Smalltalk code that are executed in response to specific conditions.

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