Share via


Condition Script Editor

Windows Media Encoder SDK banner art

The Condition Script Editor window, shown in the figure below, is used to design conditions for Conditional Regions and Articulations. Open it by clicking Edit in the Articulations List Properties window or in the Region area of the DLS Designer Window.

A condition is a logical statement consisting of queries, values, and operators. A query is the name of a property whose value you wish to test. An operator defines the relationship between two things; for example, between a query and a value.

In order for the condition to be true, the statement in the condition must be true. Statements can be complex, requiring several different things to be true, or any one thing to be true.

For example, if x is 2, all the following statements are true:

  • (x is greater than 1)
  • (x is greater than 5) or (x is greater than 1)
  • (x is greater than 1) and (x is greater than 0)
  • ((x is greater than 1) and (x is greater than 5)) or (x is greater than 0)

Note the use of parentheses in the last example. The statement is divided into two parts divided by "or", and only one part has to be true for the whole statement to be true. Because (x is greater than 5) is false, the first part of the statement is false. However, (x is greater than 0) is true, and therefore the whole statement is true.

In Condition Script Editor, queries that can be either true or false do not require explicit comparisons. For example, the following statement:

SupportsDLS1

is equivalent to:

SupportsDLS = 1

Similarly, the following statement, where "!" means "not":

! SupportsDLS1

is equivalent to:

SupportsDLS = 0

Note that there are no true and false values as such; if you want to make the Boolean evaluation explicit, you must use 0 or 1.

Shortcut menus simplify the entry of correct syntax at the text cursor in the editing window. Right-click anywhere in the window to open the shortcut menu, and select either Queries or Operators to display a submenu.

The following figure shows the Queries menu.

Queries menu

This figure shows the Operators menu.

Operators menu

Use of the bitwise operators is not recommended in conditions, unless you are using a specific value that is required by the manufacturer of a synthesizer. These operators compare the bits in queries and values, and are not equivalent to the logical AND and OR operators.

Combine queries in a condition by placing the logical AND and OR operators between them. For example, you can right-click the window to enter the GMInHardware query, then right-click again to enter the && (Logical AND) operator, then right-click again to enter the SupportsDLS2 query. Click OK to close the window. The condition, enclosed in parentheses, is added to the Condition list as follows:

(GMInHardware && SupportsDLS2)

This condition requires a General MIDI hardware synthesizer that supports DLS2.

After you create conditions, you can test them by selecting different playback environments in the DLS Conditions Toolbar. When you select a playback environment and play segments or other files, you can hear the use of the regions in the DLS instruments that correspond to the environment.