G-Area and I-Blocks
Like Csound score files, nGen files contain two main
data areas -- the global area (g-area) and the instrument
block (i-block). Anything not in an i-block is in the
g-area. The g-area is used for global declarations (any global
level statements or functions such as tempo statements or macro
definitions, etc.) and the i-block for anything relevant to
the particular note-list being generated. An obligatory feature of
the i-block is the use of "p-fields" (parameter fields). P-fields are
analogous to those used in a Csound score file; however, while
Csound parses an event at a time, nGen (like
Score11) parses by the p-field -- the entire "score" for p2 is
read then the entire "score" for p3, etc.. This allows for shortcuts
to be used while specifying what will happen to the data throughout the
duration of the current i-block. For example, you could specify that
the p-field is to "move" over the duration of the entire i-block from a
specific starting value to a specific ending value using exponential
interpolation. In this manner, you only have to specify the staring
and ending value perhaps having several thousand values calculated by the
program!
P-fields and MIDI files
If you are going to be creating MIDI files, only 4 p-fields apply:
- p2: always the start time of the event (as usual).
- p3: always the duration of the event (as usual).
- p4: For MIDI this should always be amplitude (0-32767). The value
in p4 will be scaled to the range 0-127 automatically. If you happen
to use 0-127 it will still be scaled, so stick with 0-32767 always.
While this may seem strange, it exists so that Csound files will
always convert to MIDI.
- p5: For MIDI this should always be pitch. Again these values
will be converted to MIDI code automatically. For example, C4 (stored
internally by the program as 60), will convert to 48.
All p-fields above p5 will be ignored when creating MIDI files.
I-Block Header
Each i-block must contain a header in the following format:
i<number> = <# of p-fields> <start time> <X>
{
...p-field data...
}
where:
- <number> = the instrument number
- <# of p-fields> = the number of p-fields used in
the instrument.
This is identical to Csound where P1 is the instrument number.
The highest P# used in your instrument will be the number of
p-fields in your i-block.
- <start time> = the global start time for the instrument
(in beats).
- <X> = the duration of the instrument. If X is a
positive real number, it denotes the number of beats for
the duration of the i-block's material. If X is a negative
integer, it denotes the number of events that will be
calculated. IMPORTANT: If the data in any p-field is less
than that specified in the instrument header's duration (total time or
number of events), the last value in the p-field will be repeated
until the end of the note-list. If this is not desired see
the <> delimiters. If you have
included too much data in a particular p-field for the duration
of the i-block, it will be truncated (a warning message will be printed
when this occurs).
I-Block Body
Each i-block must also contain a body, after the header; the body is
enclosed in {}s. There are only two obligatory p-fields in the
i-block's body: P2 (start times) and P3 (durations). The current
limit on the number of p-fields that can be contained within a single
i-block is 256 (but this may be significantly more than Csound
can realistically accept). The only limitation on the size of an
expanded i-block or the number of i-blocks in a file is machine specific
memory.