Describing a Csound instrument

Look at the "Csound instruments" dialog accessible from the "Output" menu. Instrument 3, which (for fun) we named a "Harpsichord", is shown Fig.34.


Fig.34 Describing a Csound instrument in the BP2 environment

This instrument assigns pitch to argument 4 but it uses the "cps (Hz)" frequency representation. Further, it assigns pitchbend to arguments 5 and 6. Why two arguments? Since pitchbend may vary continuously, it is smart to supply the values at the on-setting and off-setting dates so that Csound may do something with it. There is an empty square to the right of these arguments, just after the question mark. It may contain another argument index for passing on tabulated functions to Csound when movements become more complex. (Since BP2 does it automatically, you don't have to bother about understanding Csound function tables.)

In MIDI a NoteOn starts a process, a NoteOff terminates it, and between the two the sound generation may be modified in real time by control messages. But in a Csound event all arguments are supplied in advance. Therefore, it is the task of the instrument procedure to modify its own parameters. If only start and end values of the control parameter are supplied, Csound has no other option than perform a simple interpolation. However, with sound-objects additional information may be passed on to Csound (see §17.11).

Arguments 7 and 8 of this bizarre harpsichord are used similarly for continuous volume control. In addition, MIDI values in range 0..127 are mapped to the range -24..24, which is declared a "logarithmic" scale. Here we assumed that "Harpsichord" would takes decibels as a volume input value. Since performance control _volume(x) uses the MIDI range 0..127, a remapping is automatically done by BP2 on the basis of three supplied pairs of values.

A similar mapping is applied to modulation (arguments 11 and 12) and panoramic (argument 13) parameters. Since the latter has only one argument it cannot be used in continuous variation with this instrument.

Csound argument mapping is explained in BP2 reference manual (§9.1). All you need to know is that the first line contains three input values and the second one the three corresponding output values. BP2 manages to find a proper quadratic and/or linear interpolation matching these points. Error messages are displayed in rare cases when the mapping is impossible.

The input, output, or both input and output scales of the mapping may be declared as "logarithmic" for a more meaningful conversion.

Let us for instance produce a Csound score for the musical item:

_ins(Harpsichord) _volumecont _volume(127) A4 G4 C5 A5 A4 G4 C5 A5 _volume(0)

which specifically invokes instrument 3, using its name, and allows the volume to vary continuously from 127 to 0. The Csound score is:

t 0.000 60.000
i3 0.000 1.000 440.00 8191.500 8191.500 24.000 21.688 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 392.00 8191.500 8191.500 21.688 18.431 0.000 0.000 0.000 0.000 0.000 ; G4
i3 2.000 1.000 523.25 8191.500 8191.500 18.431 12.899 0.000 0.000 0.000 0.000 0.000 ; C5
i3 3.000 1.000 880.00 8191.500 8191.500 12.899 -0.031 0.000 0.000 0.000 0.000 0.000 ; A5
i3 4.000 1.000 440.00 8191.500 8191.500 -0.031 -1.179 0.000 0.000 0.000 0.000 0.000 ; A4
i3 5.000 1.000 392.00 8191.500 8191.500 -1.179 -2.794 0.000 0.000 0.000 0.000 0.000 ; G4
i3 6.000 1.000 523.25 8191.500 8191.500 -2.794 -5.547 0.000 0.000 0.000 0.000 0.000 ; C5
i3 7.000 1.000 880.00 8191.500 8191.500 -5.547 -24.000 0.000 0.000 0.000 0.000 0.000 ; A5
s

The column of argument 4 (pitch) is self-explanatory. Arguments 5 and 6 contain the constant default value of pitchbend (8191.5). Arguments 7 and 8 are the ones showing the volume decreasing from +24 to -24. Arguments 11, 12 and 13 keep their default values. Arguments 9 and 10 are used by another parameter (see 'blurb' infra) here set to 0.

Important

If you use the "cps (Hz)" frequency representation, do not forget to "tune" BP2 in case the diapason frequency is not 440Hz. (See §4.8.)

So far we demonstrated that parameters mapped to MIDI controls, i.e. pitchbend, modulation, volume, panoramic and pressure, can be controlled continuously and mapped to Csound parameters. More parameters, specific to Csound, may be defined in the dialog accessed clicking the "MORE..." button (see Fig.34). There is room for six additional parameters in each Csound instrument, a total 250 in the entire orchestra.


Fig.35 Description of additional Csound instrument parameters
Each additional parameter has a default value which is not necessarily zero. Values found on Csound scores may be combined additively (ADDval) or multiplicatively (MULTval). Tables describing fine variations of the parameter may use arbitrary Csound generators. GEN07 (linear interpolation) is assigned by default, but GEN08 (cubic spline) may be prefered in some cases.

Additional parameters are given arbitrary names. They are controlled by instructions "_value(param,x)", "_step(param)", "_cont(param)" and "_fixed(param)". An example in "-da.tryCsound" demonstrates the control of an arbitrary parameter labelled 'blurb' which is recognized by both instruments "Harpsichord" (3) and "Flute" (2).

_ins(Harpsichord) _cont(blurb) _value(blurb,123.42) C4 D4 _ins(Flute) E4 F4 _value(blurb,-211) _step(blurb) G4 A4 _value(blurb,-34) _fixed(blurb) B4 C5

i3 0.000 1.000 261.63 8191.500 8191.500 16.981 16.981 123.420 39.815 0.000 0.000 0.000 ; C4
i3 1.000 1.000 293.66 8191.500 8191.500 16.981 16.981 39.815 -43.790 0.000 0.000 0.000 ; D4
i2 2.000 1.000 329.63 90.000 -43.790 -127.395 0.000 ; E4
i2 3.000 1.000 349.23 90.000 -127.395 -211.000 0.000 ; F4
i2 4.000 1.000 392.00 90.000 -211.000 -211.000 0.000 ; G4
i2 5.000 1.000 440.00 90.000 -122.500 -122.500 0.000 ; A4
i2 6.000 1.000 493.88 90.000 -34.000 -34.000 0.000 ; B4
i2 7.000 1.000 523.25 90.000 -34.000 -34.000 0.000 ; C5

Additional parameters take any values in floating-point format, but they cannot be remapped before being sent to Csound instruments (see reference manual §9.1 regarding remapping). The use of control parameters K1, K2... is not licit in the current version of BP2.