kyma•tweaky . Share . ContinuousRotary

The idea of this example was to create an EventValue that could be incremented/decremented indefinitely by using a rotary control. The basic algorithm is:

If !Pos (the position of the rotary) has changed, diff is the difference between its old and new positions. Otherwise diff = 0. Add diff to val.

Here is the CapyTalk code:

| diff oldPos val |

"Declare EventVariables"
diff := EventVariable new initialValue: 0.
oldPos := EventVariable new readEveryMillisecond.
val := EventVariable new initialValue: 60.

((!Pos ne: oldPos)
   true: ((diff <+ (!Pos - oldPos)),

         "Kludge to ignore when the rotary wraps around and resets to 0"
             ((diff abs gt: 0.75) true: (diff <+ 0) false: nil),

             (oldPos <+ !Pos))
   false: (diff <+ 0)),

(val <~ (val + diff))

-- CarlaScaletti - 07 Jan 2004

Heureka! This piece of CapyTalk works really fine and solves a question, which has kept me busy for a long time. Thanks a lot for providing it.

-- EckardVossas - 19 Jan 2004

excuse my lack of knowledge.. but, where do i paste this code? just replace my hot parameters (ie: !LoopStart) with this entire bit? can i freely change the label of !Pos to reflect the name of the function?

-- TaylorDeupree - 21 Jan 2004

Taylor, please take a look at the example Sound for an example of how to use this code in the value field of a SoundToGlobalController.

-- CarlaScaletti - 31 Jan 2004

----- Revision r1.4 - 31 Jan 2004 - 17:36 GMT - CarlaScaletti
Copyright © 1999-2014 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding kyma•tweaky? Send feedback.