![]() |
![]() ![]() ![]() ![]() ![]()
|
next newest topic | next oldest topic |
Author | Topic: what does 'Hot variables cannot perform..' mean actually |
cristian_vogel Member |
![]() ![]() ![]() 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 | (default * trig) smooth: 0.5s
IP: Logged |
SSC Administrator |
![]() ![]() ![]() "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 |
![]() ![]() ![]() If I understand your intentions, the following CapyTalk expression would be one way to do this: | r | r := (1 bpm: !BPM) nextRandom abs. 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 IP: Logged |
cristian_vogel Member |
![]() ![]() ![]() 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| (bkwd = -1) ] ifFalse:[ IP: Logged |
cristian_vogel Member |
![]() ![]() ![]() 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 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 |
![]() ![]() ![]() 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 := ((1 bpm: !BPM) nextRandom abs * 10) of: #(0 0 0 1 1 1 1 1 1 -1). -=- 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 |
![]() ![]() ![]() quote: A-ha! Random Darts and a Drunk DJ - Sounds like a quality night out to me! IP: Logged |
cristian_vogel Member |
![]() ![]() ![]() 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 | IP: Logged |
SSC Administrator |
![]() ![]() ![]() In CapyTalk, the tests are: eq: (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 |
![]() ![]() ![]() 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 |
![]() ![]() ![]() 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 |
![]() ![]() ![]() And can true: and false: evaluate optional blocks of code according to the result, in the same way ifTrue [ ] does? IP: Logged |
SSC Administrator |
![]() ![]() ![]() 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 |
![]() ![]() ![]() 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...
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 |
![]() ![]() ![]() 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. 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 |
![]() ![]() |
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.