#
3. Controlling stimulus parameters in realtime

When using the `Presentation` class, you have a powerful method of updating parameters in realtime available to you. ``Controllers'' are instances of the class `Controller`. A controller is called at pre-defined intervals and updates the value of some stimulus parameter. For example, in the ``target'' demo script, the ``center'' parameter of a `Target2D` stimulus is updated on every frame by a function which computes position based upon the current time. You can also control parameters without using controllers by simply changing the values as your program executes.

Instances of `Controller` are called by instances of the `Presentation` class. After creating an instance of `Controller`, it must be ``registered'' by calling the `add_controller` method of `Presentation`, during which the stimulus parameter under control is specified. The `Presentation` takes care of calling the controller from this point. Specifically, the `during_go_eval()` is called during a `go()` loop, and `between_go_eval()` is called by `between_presentations()` (during `run_forever()`, for example.) These ``eval'' methods return a value which becomes the new value of the parameter being controller.

The frequency with which `during_go_eval()` and `between_go_eval()` are evaluated is determined by the eval_frequency attribute of the controller. The default eval_frequency is every frame.

The temporal_variables attribute of the controller specifies what temporal variables the ``eval'' methods have available to base calculations on. The default value is TIME_SEC_SINCE_GO, so when `during_go_eval()` is called, the instance will have an attribute time_sec_since_go set to the time since the onset of the `go()` loop.

For more information, see the documentation for the `Controller` and `Presentation` classes in the `VisionEgg.Core` module.