Recherche Google
OpenMusic 6 – User ManualAdvanced Visual Programming > Iterations: OMLOOP > Evaluators
previous pagenext page

Evaluators : Eachtime, Finally

OMLoop has two evaluators :

  • Finally : receives and returns the results of the loop.
  • EachTime : produces the result at each step of the iteration.

Getting Results : Finally

Finally represents the output of OMLoop . It is evaluated when the iterative process is over and returns its final result(s) .

If nothing is connected to it, the evaluation of OMLoop returns "nil".

Example

The following example uses an iterator : listloop. at each step of a loop, listloop enumerates an element of a list, then the following element, and so on, until the list is exhausted.

  1. Here, there are four iterations during which listloop takes the successive values from the list.

  2. At the end of this process, finally returns the current value listloop, that is, the last value of the list.

  3. This value is the result of OMLoop.

Finally Inputs : OMLoop Outputs

Finally has one default input : "patch". It can be added as many optional inputs as necessary : "oppatch".

Optional inputs can be used as additional outputs for OMLoop to return data to external elements in a higher-level program.

Multiple Outputs

When an OMLoop has several outputs, it is advised to set it on "evaluate-once" mode to avoid useless multiple evaluations. When the OMLoop is evaluated, the result displayed by the Listener is that of the first output.

Executing Operations : EachTime

EachTime triggers successive evaluations inside the OMLoop. It is not visible from the outside.

EachTime can apply to any type of operation, but the results won't be returned to other boxes or displayed, unless the user adds relevant connections.

Inputs

EachTime has one default input, and can be added a number of optional inputs. Each input calls upstream boxes , so that several tasks can be performed at each step of the iteration.

Using EachTime

Here, EachTime evaluates om+ at each step of the loop. Yet, the Listener only displays the result of Finally when OMLoop is evaluated.

Yet, EachTime plays a very important part in an iteration, since it is the only means to evaluate and keep track of the results yielded at each step of the program. This is one of the main specificities and interests of OMLoop.

The results of the operations called by EachTime can actually be displayed and returned to other boxes, inside and outside the OMLoop module.

Example

In this new example, print is evaluated at each step.

  1. When listloop returns an item in the (A B C D) list, EachTime evaluates print.

  2. The current value of listloop is printed.

  3. At the end of the list, finally returns the last value of listloop.

Collecting the Results of EachTime

The results of the operations called by EachTime can be collected and returned to Finally with accumulators.

Example

We want to gather the results of each loop of the iteration in a list and return this list to other boxes on the outside of the module.

To do so, we use an accumulator : collect .

Collect stores the results of each loop in a list.

  1. At each step, eachtimes calls :

    • print, which print the item returned by listloop
    • collect, which stores a new value.
  2. At the end, finally gets all the collected values and returns them as the result of the OMLoop.

Note  : the editable-text-box displays the value of the OMLoop output.

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