Recherche Google
OpenMusic 6 – User ManualOM Objects > OM Basic Objects > Dialog Items > Pop Up Box
previous pagenext page

Selecting and Triggering Actions : Pop Up Box

Features

The pop-up box resembles the items-list boxes :

  1. it allows to select items of a list in a pop-up menu interface

  2. it triggers a computation corresponding to a selected item.

Inputs and Outputs

The pop-up box has two inputs and outputs :

  • "items" : a list of menu items
  • first output : returns the number corresponding the selected item.
  • " action" : an action to perform, represented by a lambda function or lambda patch
  • second output : returns the name of the menu item "corresponding" to the action.

For instance, "piano" can mean "play a piano sound".

Setting the Menu
  • To display the box's interface, evaluate the box and press m .

  • To choose an item in the pop up box :

  1. edit the menu item names via the standard procedure – edit the first input, select the box and evaluate.

  2. If necessary, press i to refresh the displaying of the pop up menu.

  3. To preserve the size of the box, press b to lock it.

  4. Click on the desired item.

Selected Item Value
  • The first output returns the number corresponding to the selected item. Note that the first menu item is equal to 0.
  • The second output returns the value of the selected item as text.

Uses

Tip : Selecting Files

The pop-up box can be useful for selecting files in a folder.

  1. The infile and outfile boxes are designed to return a directory pathname to the files contained in the in-files and outfiles folder of the current workspace.

  2. Connect the output of the box to the first output of the pop up box : the menu items stand for the files contained in the folder.

You can possibly type the directory pathname directly in the first input of the pop up box.

Using a directory to initialize the menu contents.
Using a directory to initialize the menu contents.
Selecting an Argument and Triggering an Operation

The second input of the menu can be used for selecting an argument and triggering an operation. This input must be connected to a function or a box on "lambda" mode with one input or argument.

This lambda function is called when an item is selected. The value of this item is the number returned by the first output. It is the argument of the function.

To set or modify the function associated with the menu, connect a box or function to the second input of the menu box, then evaluate the menubox .

The value of the selected item – a number between 0 and 2 – is printed in the listener at selection.
The value of the selected item – a number between 0 and 2 – is printed in the listener at selection.

A Musical Application : Choosing and Listening to a Sound

  • The first input of a pop up box is connected to a text-edit-view box that contains a list of midi channel names . When the first output of the pop up box is evaluated, it returns a number that refers to a midi channel.
  • The second input of the pop up box is connected to a lambda patch that is designed to play a corresponding sound when a sample is selected.

In the lambda patch, the sequence function evaluates two values successively :

  1. program-out picks a midi channel according to value of its first input .

  2. player plays a note with the chosen midi sound.

The action programmed in the patch is executed when an item is selected in the pop up box.

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