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

CONSTANTS AND VARIABLES

constants are floating point numbers, such as 1, 3.14159, or -73.45. They are available continuously and do not change in value.

variables are named cells containing numbers. They are available continuously and may be updated at one of the four update rates (setup only, I-rate, K-rate, or A-rate). I- and K-rate variables are scalars (i.e. they take on only one value at any given time) and are primarily used to store and recall controlling data, that is, data that changes at the note rate (for I-variables) or at the control rate (for K-variables). I- and K-variables are therefore useful for storing note parameter values, pitches, durations, slow-moving frequencies, vibratos, etc. A-variables, on the other hand, are arrays or vectors of information. Though renewed on the same perf-time control pass as K-variables, these array cells represent a finer resolution of time by dividing the control period into sample periods (see ksmps ). A-variables are used to store and recall data changing at the audio sampling rate (e.g. output signals of oscillators, filters, etc.).

A further distinction is that between local and global variables. local variables are private to a particular instrument, and cannot be read from or written into by any other instrument. Their values are preserved, and they may carry information from pass to pass (e.g. from initialization time to performance time) within a single instrument. Local variable names begin with the letter p, i, k, or a. The same local variable name may appear in two or more different instrument blocks without conflict.

global variables are cells that are accessible by all instruments. The names are either like local names preceded by the letter g, or are special reserved symbols. Global variables are used for broadcasting general values, for communicating between instruments (semaphores), or for sending sound from one instrument to another (e.g. mixing prior to reverberation).

Given these distinctions, there are eight forms of local and global variables :

type                     when renewable    Local      Global

reserved symbols         permanent          --        rsymbol
score parameter fields   I-time            pnumber     --
v-set symbols            I-time            vnumber    gvnumber
init variables           I-time            iname      giname
midi controllers         any time          cnumber    --
control signals          P-time, K-rate    kname      gkname
audio signals            P-time, A-rate    aname      ganame
spectral data types      K-rate            wname      --
 

 where rsymbol is a special reserved symbol (e.g.  sr, kr), number is a positive integer referring to a score pfield or sequence number, and name is a string of letters and/or digits with local or global meaning.  As might be apparent, score parameters are local I-variables whose values are copied from the invoking score statement just prior to the Init pass through an instrument, while midi controllers are variables which can be updated asynchronously from a midi file or midi device.
 


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