| mp4-sa-> the mp4-sa book->the SAOL language |
IntroductionMPEG-4 Structured Audio (MP4-SA) is an ISO/IEC standard (edited by Eric Scheirer) that specifies sound not as audio data, but as a computer program that generates audio when run. For an introduction to MP4-SA see this short example or read the introductory tutorial presented in Part I of the book. In Part II of the book, we focus on the SAOL language.
In the first chapter we describe the
atomic units of SAOL expressions. We cover the lexical rules for
numbers and names, and the declaration of signal variables and
instr parameters. We describe the uated and the
The exact semantics of the switch operator depend on the width of its
subexpression operands. If its operands all have scalar width, the
operator has short circuit semantics. The first subexpressions is
always evaluated, and depending on its logical value, either the
second or the third subexpression is evaluated (but never both).
However, if at least one subexpression has width greater than 1,
all three subexpressions are evaluated, and then the operator
logic happens on an element-by-element basis.
Apart from the short-circuit behavior, width semantics are identical
to arithmetic operators.
The switch operand concludes our tour of the SAOL operators. The C
operators that are missing from SAOL are those that target integer
data types, such as bit shifts, bit-wise logic, and modulo. In
addition, SAOL expressions may not have embedded assignments to
variables within them, unlike C expressions.
|
The Switch Operatorop1 ? op2 : op3 |a| using Switch(a >= 0) ? a : -a Illegal in SAOL Expressions+ // unary plus % // not a floating point op ^ // & // << // >> // ~ // = // assignment not embeddable ++ // illegal in assignment too! -- // += // -= // *= // /= // %= // <<= // >>= // &= // ^= // |= // |
Assignment StatementIn this chapter, we describe the three SAOL statements that are the core tools for expressing algorithms. We begin with the assignment statement that sets a signal variable to a new value. The panel on the right shows the syntax of the assignment statement. The lval is the instr parameter or signal variable that receives the new value. The expr is the expression that is evaluated to generate the value to assign. An lval may be a scalar or array variable, and so assignment statements also have rules regarding width semantics. If the lval has scalar width (i.e. it is a scalar, an array of width 1, or an indexed array), the expression must also have scalar width. Indexed array lvals follow the rate, width, and indexing rules for indexed arrays in expressions. If the lval is an unindexed array of width N, the expression must either have width N or scalar width (in which case each element of the lval takes on the scalar value). See the right panel for examples showing the width semantics of assignment statements. If the lval and expr both have width greater than one, SAOL leaves the sequence order of expression evaluation and assignment undefined. One implementation may evaluate the expression for all array elements before doing the assignment; a second implementation may evaluate and assign array elements member by member, in an arbitrary order. This implementation detail matters to the SAOL programmer, because it is possible to write assignment statements whose answer depends on the sequence of operations, by using indexed versions of the lval variable in the expr. Reliable SAOL programs break up this sort of assignment statement into several simpler statements. Assignment statements have two rate rules:
These rules underpin the SAOL multi-pass compute model described in the tutorial in Part I. The first rule establishes the convention for setting the rate of variable assignments. The second rule forces information to flow from slower-rate variables to faster-rate variables. SAOL also has a null variant of the assignment statement, in which an expression is computed but not assigned to an lval. T |