Book Image

OpenFrameworks Essentials

Book Image

OpenFrameworks Essentials

Overview of this book

Table of Contents (19 chapters)
openFrameworks Essentials
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using time values for a parameter's automation


Using time values is apparently the most commonly used method to automate a parameter. In this approach, a parameter's value is set to be a function depending on the time, and more precisely, the number of seconds measured from some initial point in time.

Tip

Dependency of time can be implemented in many ways—as a mathematical expression, in tabular form, or even by drawing it using a graphics tablet. We will consider the simplest way, which is using mathematical expressions.

To implement dependency of time, we need a function to measure it. In openFrameworks, such a function is ofGetElapsedTime(). It returns the number of seconds elapsed from the project's start. This is a float value and is measured with millisecond precision.

To check this function, add the following command to the end of update():

kangle = ofGetElapsedTimef();

This command sets the value of the kangle slider to the number of seconds elapsed from the project's start. On running...