Recherche Google
OpenMusic 6 – User ManualAdvanced Visual Programming > Instance Objects > Slots
previous pagenext page

Reading and Modifying Instances : Slots

The slots box can read or modify the values of a slot – that is, a "field" or parameter – of an instance or global variable.

Reminder : Instances and Global Variables

Instances1 are created out of classes via factory boxes.

  • They can be materialized in a patch editor by instance boxes  .
  • They can be stored as global variables2 to a workspace where they will be stored in the Globals package of the Library.

All information provided in this section is valid for both types of boxes.

About Instance Boxes and Global Variables

Properties

Creating a Slots Box

A slots box is always created from a given object box, and has the same reference. To create a slots box :

  1. Cmd click in a patch editor,

  2. type a class name

  3. validate while keeping SHIFT pressed.

Morphology

The structure and morphology of a slots box is similar to those of the corresponding factory box. The slots box also has a "self", and a number of parametric slots.

For instance, the slots box created out of a chord instance has the same inputs and outputs : "self", "midicents", "velocity", "duration", "midi channel". It also has the same icon.

Behaviour
  • The outputs of slots return the values of the object's corresponding slots.
  • The parametric inputs of slots can take other values. When slots is evaluated, these values will affect the corresponding slots of the object.

Using the Slots Box to Modify an Instance

Using "slots" allows to read and modify the parameters of an object without creating new instances out of new factory boxes :

Constraint

The "self" input of slots must be connected to the "self" output of an object, so that the slots of the object can be read and/or modified.

Reading Values

To read the value(s) of an instance's slot :

  1. connect the instance to the "self" input of slots,

  2. evaluate the corresponding output of slots.

Modifying the Values of an Object

To modify the value(s) of an instance's slot :

  1. connect the instance to the "self" input of slots,

  2. enter new values in the relevant input of slots,

  3. evaluate slots,

  4. reopen the instance editor.

Note that the reference of the object hasn't changed, despite the fact the object's content has changed.

Applying Slots to Factory Boxes

The same procedures can apply to factory boxes.

  1. Lock the factory box before evaluating slots : otherwise, it will be reset to its default values.

  2. Select the factory box and press m to refresh the miniview.

Modifying an Object from Within an Abstraction

Once an object belongs to an abstraction, its slots can't be accessed from the abstraction. It is sometimes wiser not to generate useless new instances :

  • for optimization purposes
  • to keep the reference of the object one operates upon.
Procedure

To modify an instance from the inside of an abstraction :

  1. Create a slots box and drop it in the abstraction and duplicate it.

  2. Connect the input of the abstraction to the "self" input of slots.

  3. Connect the slot you want to modify to the relevant box(es).

  4. Connect the output of the program to the relevant input of the duplicate.

  5. Connect the self output of the first slots box to the self input of the second slots box.

  6. Connect the self output of the second slots box the the output of the abstraction.

  7. Evaluate the factory box connected to the outside of the abstraction.

Consequences

When the initial instance is refreshed, it will also be modified, since both instance have the same reference.

  1. Instance

    An actual object created at runtime, out of a given class. In OM, more specifically, an object created when evaluating a factory box. An instance can be saved as a global variable.

    SHIFT click on an outlet – especially the first outlet representing the self, the whole object – of a factory box to materialize an instance.

  2. Global variable

    An instance of OM object that has been saved in order to be used in other programs. Global variables are visible from the Library window and stored as .omi files in the Globals folder of the workspace.

previous pagenext page
About...(c) Ircam - Centre PompidouMade with Scenari