InteractiveEnvironment:
Filter:
Dimple/Classes (extension) | Libraries > Interactive Environments

InteractiveEnvironment
ExtensionExtension

Utility Class to easily create interactive musical environments

Description

This class provides utility methods to setup interactive musical environments using DIMPLE. It it useful to

Class Methods

.new

Creates a new environment instance.

Arguments:

dimple

Dimple instance to associate the environment with.

Returns:

An instance of InteractiveEnvironment.

Instance Methods

.dimple

Returns:

The DIMPLE instance associated with this environment.

.creationFunc

Gets/sets the creation function, which contains code to create the environment. It is automatically invoked each time the -create method is triggered. The DIMPLE instance is given as parameter.

.create

Creates the environment. Therefore, a createFunction has to specified using -creationFunc. Furthermore, the object map (-objects) is initialized and the object Function (-objectFunc) is invoked for each object in the environment.

Arguments:

clear

Specifies if the environment and the object map should be cleared before creating the environment.

.handleCollisions

Enables collision detection and registers a callback function to be invoked for every collision.

Arguments:

callback

Callback function to be invoked when a collision occurs. The following parameters are given:

  1. Name of the first collided object (as Symbol)
  2. Name of the second collided object (as Symbol)
  3. Velocity of the collision

.objects

Returns:

Returns a map from object names (Symbols) to Dimple object instances.

.updateObjects

Updates the object map.

.objectFunc

Gets/sets a function which is invoked for each object in the environment. It receives a Dimple object as parameter.

.handleAttribute

Registers a callback function to track changes of an object's attribute.

Arguments:

object

Object to track

attribute

Attribute to track, specified as Symbol (e.g. \position, \color)

interval

Interval (in milliseconds) for attribute updates

callback

Callback function which is invoked on every attribute update. It receives the following arguments:

  1. The current value of the attribute of interest
  2. The associated object instance

.sonifyObject

Sonifies a moving object in the environment. Therefore a handler is automatically installed which updates the object's position regularly. A sound synthesis algorithm is specified in terms of a function which is installed as a Ndef.

Arguments:

object

Object to be sonified.

ndefFunc

Sound synthesis algorithm, which is installed as Ndef. It receives the following parameters:

  1. X Position of the object [-1;1]
  2. Y Position of the object [-1;1]
  3. Z Position of the object [-1;1]
positionUpdateRate

Position update interval (in milliseconds)

.clear

Clears all objects in the environment as well as the object map.

Examples