First time here? Check out the FAQ!
x

How can I evaluate a capytalk expression every 10 ms?

0 votes
452 views

I was looking at the exponential smoothing thing again using capytalk. 

If I want to evaluate a capytalk expression every capytalk cycle (every 1 ms) I could do something like this:

| lastValue |

lastValue := EventVariable new initialValue: 0.

(!localTime true:
    (lastValue <~ (lastValue + (!Input - lastValue / !Factor)))
false:
    nil
),
(lastValue).

If I want to evaluate less often I could use "0.1 s tick evaluate:..." instead of "!localTime true:...". But tick can't seem to go faster than 0.02 s.

How do you create faster triggers in capytalk, between 1 and 10 ms?

(Also would it be much more efficient to use a tick of 0.1 s duration in the example above and smooth the output, or just evaluate the expression at full capytalk rate?)

 

asked May 17, 2019 in Capytalk & Smalltalk by alan-jackson (Virtuoso) (15,840 points)
edited May 17, 2019 by alan-jackson

1 Answer

+1 vote

Here's a Sound that does exponential smoothing of input values.

answered May 17, 2019 by ssc (Savant) (128,000 points)
I would never have thought to use an AmplitudeFollower. You know all the tricks!

So the AmplitudeFollower goes to 64% of the input value in the time set in TimeConstant.
whileTrue:timeStep - How does this work?
...