QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next

Pfield Macros

Scot has a macro text substitution facility which operates only on the pfield specification text within brackets. It allows control values to be specified symbolically rather than numerically. Macro definitions appear inside brackets in the orchestra section. A single bracketed list of macro definitions preceding the first instrument declaration defines macros which apply to all instruments. An additional bracketed list of definitions may follow each instrument to specify macros that apply to that particular instrument.

     orchestra {
          [ pp=2000 p=4000 mp=7000 mf=10000 f=20000 ff=30000
            modi = 11: w = 1 x = 2 y = 3 z = 4
            vib = "10:1 " novib = "10:0 1"
          ]
     violin = 1     [ pizz = " 20:1" arco = " 20:0" ]
     serpent = 3    [ ff = 25000 sfz = 'f sffz = 'ff]
     }
     score {
      $violin = 4c[mf modi z.y novib] d e a['f vib3] /
               8 b[pizz]c 4d[f] 2c[ff arco] /
      $serpent =, 4.c[mp modi y.x] 8b 2c /
               'g[f ], c[ff] /
     } 

As can be seen from this example, a macro definition consists of the macro name, which is a string of alphabetic characters, followed by an equal sign, followed by the macro value. As usual, spaces, tabs, and newlines may be used freely. The macro value may contain arbitrary characters, and may be quoted if spacing characters need to be included.

When a macro name is encountered in bracketed pfield lists in a score section, that name is replaced with the macro text with no additional punctuation supplied. The macro text may itself invoke other macros, although it is a serious error for a macro to contain itself, directly or indirectly. Since macro names are identified as strings of alphabetic characters, and no additional spaces are provided when a macro is expanded, macros may easily perform such concatenations as found in the first serpent note above, where the integer and fractional parts of a single pfield are constructed. Also, a macro may do no more than define a symbolic pfield, as in the definition of modi. The primary intention of macros is in fact not only to reduce the number of characters required, but also to enable symbolic definitions of parameter numbers and parameter values. For instance, a particular instrument's interpretation of the dynamic ff can be changed merely by changing a macro value, rather than changing all occurrences of that particular value in the score.


QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next

HTML Csound Manual - © Jean Piché & Peter J. Nix, 1994-97