Input filters (also see output formatting)

Input filters are used to enter data in a special format (e.g., note names, decibels, rhythms as reciprocal duration codes, etc.).  The default method of input stores data internally as real numbers (floats), however, in some situations you might want to input in a special method that will then be translated and stored internally as real numbers.  For example, in a certain situation, it might be desirable to specify note names (c4, gs2, etc.) rather than Hertz, octave-point-pitch-class, or octave-point-decimal. In this case you could use the "no" (notes) input filter.

Input filters can occur anywhere within a p-field and can be canceled by specifying "re" (the default input -- real numbers).  Below is a list of the available input methods.  These can be initiated at any point within a p-field and are active for the remainder of the p-field or until a new input filter occurs.

For specific information on how "pitches" are stored internally see the note below (this affects the NO/NOX, and OP/OPX input/output filters  and the OD and HZ output filters).

db (DeciBels)

All data after the "db" input filter is interpreted as decibels.  0 dB is silence and maxamp (32767) is roughly 90 dB.

N.B. The algorithm used is identical to that in the Csound Canonical source code.

in (Integers)

This new input mode forces any stored data (including those made by DDFs) to round to the nearest integer (although these are still stored internally as floats rounded to the nearest integer).

        p6(xx) se(T 1. *[0 1 2 3 4 5 6 7 8 9 10 11])   ;PCs
        p7(xx) in rw(T 1. [1 7] .25 4)                 ;Octave #s
        p5(op)    ex(T 1. i[p25*12+p24])               ;Pitches (PCs+OCs)

In the above example, p5 and p7 are used as scratch p-fields in order to control pitch-classes and octave numbers independently (they are processed before p5 and are not output to the printed note-list but can be drawn from in subsequent p-fields with the "ex" DDF). The "random window" data in p7 would be floating-point data between 1 and 7; the "in" input mode forces the generated values to be rounded to the nearest whole- number (e.g., 1.15 becomes 1.00) when stored in the note-list.

no (Notes)

Allows for note-name octave-number input (e.g. c4, ef3, fss2, df3, en).

Format: <note-name><accidentals><octave-number>]

Note Names: c,d,e,f,g,a,b or C,D,E,F,G,A,B

Octave-Number: c4 = middle C (stored internally as 60)
If octave numbers are omitted the program defaults to the previously used octave value (if none is specified "4" is the default).

Accidentals are parsed recursively (you may have any number chained) and may consist of any combination of the following:


Using the ":" command will cause a new event to be created in which the current p-field value will be different (i.e., a new note) but all other p-fields will be copies of the original.  Thus:
creates an original event with c4, then makes two new copies with the same start time (and identical previous and subsequent p-fields).

nox (Extended Notes)

The NOX input mode is exactly like the NO input mode except that it additionally allows for the input of quarter tones with '+' and '-'.  For example:
p5 nox c+4, f-5, gff+

op (Octave-Point-Pitch-Class)

Allows for octave.pitch-class input (e.g., 8.00 = C4).  See the Csound manual for more details.  As in Csound, the fractional (pitch-class) part may consist of an additional decimal place (e.g., 8.005) allowing for a tuning deviation of 10 parts per semitone (so you can have up to 100 semitones/octave!).

opx (Extended Octave-Point-Pitch-Class)

The OPX input mode is exactly like the OP input mode except that it won't round the numbers to the nearest equal tempered pitch code (useful in DDFs)

re (Real Numbers/Floats) (Default Input filter)

Real numbers are the default input filter.  In fact, the only time you really need to literally specify "re" is when you want to cancel an existing input method within the current p-field.

rh (Rhythm)

Allows for reciprocal duration code input.  Using rh, rhythms can be entered using a special method of rhythmic representation called reciprocal duration code (see Brinkman, Pascal Programming for Music Research,  1989 Chicago UP).  In this coding system a rhythmic value is represented as a fraction of a measure of 4/4 and specified by the denominator of that fraction (e.g., 1/4 of a measure [quarter note] = 4; 1/2 of a measure [half note] = 2; 16 = a sixteenth-note; 5 = a quarter-note quintuplet, 28 = a sixteenth-note septuplet; etc.) .  Additionally, the rdc value may be altered using the following: Example
p2 rh 4. 8x3 2.,8 8
The above example consists of a dotted-quarter followed by three eighths, a dotted-half tied to an eighth, then a single eighth.

A Note on the Internal Representation of "Pitches"

(This affects the NO/NX, and OP/OPX input filters and the OD, OP, and HZ output filters):  The NO/NOX and OP/OPX input modes interpret and store their values as internal real-number codes.  48.0 is C4 (middle C), 49.0 is C-sharp4, etc..  Since the codes are stored as real-numbers, fractional values are also valid for these input/output modes.  For example, in the NOX input mode The chord fs+4:a+:f+5 would translate internally to 54.5:57.5:65.5.

Why differentiate between NO/NOX and OP/OPX?  The answer pertains mainly to the DDFs (Dynamic Data Functions -- specifically MO, RA, and RW): Suppose that you enter the following:

  p5(od) no  mo(T*.33 1. c4 c6) 
         nox mo(T*.33 1. c4 c6) 
         no  mo(T*.34 1. c4 c6)
You'll note the following output:

i1    0.000  0.250  5000    48.000 
i1    0.250  0.250  5000    51.000 
i1    0.500  0.250  5000    55.000 
i1    0.750  0.250  5000    58.000 
i1    1.000  0.250  5000    62.000 
i1    1.250  0.250  5000    65.000 
i1    1.500  0.250  5000    69.000 
i1    1.750  0.250  5000    72.000 
i1    2.000  0.250  5000    48.000  ;NOX COMMAND PRODUCES 
i1    2.250  0.250  5000    51.429  ;fractional values! 
i1    2.500  0.250  5000    54.857  ; 
i1    2.750  0.250  5000    58.286  ; 
i1    3.000  0.250  5000    61.714  ; 
i1    3.250  0.250  5000    65.143  ; 
i1    3.500  0.250  5000    68.571  ; 
i1    3.750  0.250  5000    72.000  ; 
i1    4.000  0.250  5000    48.000 
i1    4.250  0.250  5000    51.000 
i1    4.500  0.250  5000    55.000 
i1    4.750  0.250  5000    58.000 
i1    5.000  0.250  5000    62.000 
i1    5.250  0.250  5000    65.000 
i1    5.500  0.250  5000    69.000 
i1    5.750  0.250  5000    72.000 
(N.B. P5 would normally be converted to OP, HZ, or OD for Csound)

In this example, there are three MO commands.  The first and last use NO, which rounds to the nearest equal tempered pitch code, while the middle uses the NX command and generates fractional values.  If you will be using the DDFs to create a stream of values, I would suggest always using the NO or OP command for pitch input when you want equal tempered tuning.  The NOX, and OPX commands will not round.

A Note on NO and Random Deviation (RD)

When RD is turned-on affecting the NO or OP input modes, all deviation is added before rounding to the nearest pitch code.