Bol Processor BP2 -- a 'QuickStart' 17. Csound on BP2 -- a primer BP2 Reference Manual Title Page Index Contents

17. Csound on BP2 -- a primer

17.1 What is Csound, how does it relate to BP2?

Csound is a program for the design and transformation of digitised sounds. A public domain software currently developed at the MIT, it can be compiled to run on various platforms, notably Unix, NeXT and MacOS. The current PowerPC version may be retrieved from < ftp://notam.uio.no/pub/mac/audio/csound.ppc.sea.hqx>. The Csound front page is < http://www.leeds.ac.uk/music/Man/c_front.html>.

Unlike hardware sound processors, Csound puts no limitation to the number of instruments and the complexity of their processes. Indeed, a sophisticated orchestra file would request a great deal of computation time, but it remains workable on small computers whenever speed is not critical.

With recent hardware enhancements (multiprocessing, RISC...) Csound has become fast enough for real-time synthesis, making it possible to adjust various sound parameters interactively. In other words, musicians can explore sound spaces rather than rely on speculations as to what a certain formula would yield. This shift from theory to practice is giving Csound a second life at a time computer users feel allergic to batch-processing techniques and dream of immediate feed-back and interactive systems.

Csound works with two input files, the "orchestra file" and the "score" file, both in comprehensive text format. This makes it easy to musicians to share a broad library of sound design "recipes", a sample of which is supplied with the software itself.

BP2 may create a piece of music in the real-time MIDI environment and then enhances it with Csound. Csound and BP2 are similar and complementary in their text-oriented, programming approach, with respective emphasis on sound and musical structures. None of these programs make assumptions on the musical system even though they optionally accept practical conventions such as "octave point pitch-class" representation in Csound, or "simple notes" in BP2.

A Csound instrument is the procedural representation of computational processes at the lowest level; conversely, a BP2 sound-object is a declarative representation of elementary events and properties at a more abstract level.

While Csound is quite user-friendly for the description of instruments (the "orchestra file"), it does not offer any in-built facility for the design of event lists (the "score" file). Score files are usually typed or produced with higher-level algorithms such as the ones programmed with Cscore, a utility supplied on the same site. But not every musician is a C programmer... A convenient way of generating Csound scores is to convert them from MIDI files, but this limitates Csound parameters to the very few ones implemented in MIDI. BP2 handles any number of parameters (with arbitrary names) that may be assigned any position among Csound instrument arguments.

(Subject to confirmation by Csound folks ) BP2 is to-date the most advanced program for the creation of Csound score files. BP2's input may be comprehensive text scores (with an alphabet of simple notes and sound-objects) or music production processes such as grammars or scripts. BP2 attempts to take full advantage of the versatility of Csound, by-passing the limitations of MIDI.

In the following examples (except §17.5) we are using imaginary orchestra files and proposing a visual, rather than sonic, verification. The reason is that we intend to demonstrate a great variety of parameter formats.

17.2 Producing Csound scores with BP2

First select the "Csound" option in the "Output" menu. This option is saved with the settings of the current project or data. If the "MIDI" option is still active, musical items will be played on MIDI and then the user will be prompted to go for a Csound score. If "MIDI" is inactive Csound scores are immediately saved to a file. (See more options Fig.33.)

If Csound is running on a Unix or Windows machine it is a good idea to change the file format to "DOS" or "Unix". The dialog for MIDI and Csound file saving options is visible after typing cmd-option space ("Settings" in the "Windows" menu).

On the top "Settings" dialog, checking "Trace Csound" requests BP2 to display a copy of the score in the "Trace" window. A good idea for a first check-up.

BP2 creates a Csound score of musical items selected in a text window (a "BP2 score") or produced by a grammar. The components of these musical items are sound-objects and/or simple notes. A sound-object contains a sequence of elementary events that may be described as a MIDI stream, a Csound score, or both.

In the latter case, BP2 checks that the durations of the MIDI and Csound sequences are identical. It makes sense to have both descriptions generate similar sounds on MIDI and Csound, so that MIDI is used for an immediate check and Csound for the final material.

In both cases BP2 needs information about the parameter locations and ranges for each instrument of the Csound orchestra file. Unfortunately, reading the orchestra file would not yield the required information unless it is prepared in a comprehensive way. (Csound designers might think of new instructions in Csound orchestra files that would make this information directly accessible :-) This partial description of Csound instruments is entered in the "Csound instruments" dialog and saved to a "-cs.<name>" file.

Version 2.9.3 of BP2 inserts function tables into the score when necessary, thus enabling arbitrary variations of continuous parameters within a single Csound event (a score line).

17.3 Try Csound with simple notes

Select the "Data" window and type cmd-o to load "-da.tryCsound" in the examples folder. On top of the "Data window" the instruction

-cs.tryCsound

tells BP2 to immediately load the "-cs.tryCsound" file describing the orchestra. Since no "-mi.<name>" is attached, musical items will contain only simple notes, and Csound scores will be based on the conversion of MIDI messages.

Select for instance the sequence of simple notes

A4 G4 C5 A4

and type cmd-p ("Play selection"). This item is played on MIDI and immediately saved to a Csound score file containing:

t 0.000 60.000
i2 0.000 1.000 440.00 90.000 0.000 0.000 0.000 ; A4
i2 1.000 1.000 392.00 90.000 0.000 0.000 0.000 ; G4
i2 2.000 1.000 523.25 90.000 0.000 0.000 0.000 ; C5
i2 3.000 1.000 440.00 90.000 0.000 0.000 0.000 ; A4
s

Each line starts with "i2" meaning that instrument 2 is used. BP2 found this value in the settings of instrument 2:

Assign as default to channel 1

and MIDI channel 1 is the one used by default.

On each score line, the "2" of "i2" is the value of argument 1, the leftmost one. The next two arguments are always assigned to the on-setting date and duration of the event, measured in beats. Then comes argument 4, which in this example is assigned to pitch, here in cycles per second. Argument 5 is the volume (range 0..127) set to 90 by default. Arguments 6, 7 and 8 are used for another parameter not demonstrated here.

Instrument 2 does not accept any other parameter. Therefore, velocity, pressure, modulation, etc., assignments are ignored.

17.4 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.

17.5 Checking the Csound output

A Csound orchestra file named "BP2test.orc" is supplied. It works with any Csound score produced by BP2 in the absence of a Csound instrument description file (-cs.<name> file).

Below is the listing of the default orchestra file.

; This is a simple orchestra file for BP2's default Csound score output
; It follows the new specfications handled by BP2 version 2.7.2 and above.
; (See "Csound tables")

; It contains one single instrument: an oscillator using wave-table 1
; Argument p2 is the start date, p3 the duration (as per the standard)
; Argument p4 is the pitch in octave point pitch-class format
; Volume (range 0..127) is supplied by performance control _volume()
; to arguments p5 (beginning value) and p6 (end value), or via the table
; whose index is supplied by p7.
; Pitchbend is supplied in cents to arguments p8 (beginning value)
; and p9 (end value), or via the table whose index is supplied by p10.

sr = 22050
kr = 2205
ksmps = 10
nchnls = 1

instr 1

ik1 = 32767. / 127.
ik2 = log(2.) / 1200.

ifvol = p7
ifcents = p10

kvol line p5, p3, p6
if (ifvol <= 0) goto volumelin
ilenvol = ftlen(ifvol)
kndxvol line 0, p3, ilenvol
kvol tablei kndxvol, ifvol

volumelin: kcents line p8, p3, p9
if (ifcents <= 0) goto pitchbendlin
ilencents = ftlen(ifcents)
kndxcents line 0, p3, ilencents
kcents tablei kndxcents, ifcents

pitchbendlin: kpitch = cpspch(p4) * exp(kcents * ik2)
kamp = kvol * ik1

a1 oscil kamp, kpitch, 1
out a1
endin

This code should not look esoteric to Csound users. The unique instrument in this orchestra is an oscillator controlled in volume by arguments 5 and 6 (start and end respectively) and in pitch by argument p4 (octave point pitch-class format). Pitchbend corrections are given in cents by arguments 8 and 9 (start and end respectively). In addition, arguments 7 and 10 may contain the references of function tables when complicated variations are described.

We are confident that Csound users will pick up the idea and develop their own instruments taking advantage of BP2 features such as panoramic control, and any additional control they think useful. We hope that convincing examples will be shared between users.

Type cmd-n ("New Project") to flush the current Csound orchestra description and use the default instrument exclusively. Then load "-da.Csoundtest" in the "Data" window.

_volumecont _pitchcont _pitchrange(200) _volume(30) C5 _volume(127) D5 _pitchbend(100) E5 F5 _pitchbend(0)

Select this item and type cmd-p ("Play selection"). Save the resulting score as "BP2test.sco":

; Csound score

f1 0 256 10 1 ; This table may be changed

t 0.000 60.000
i1 0.000 1.000 9.00 30.000 127.000 0.000 0.000 0.000 0.000 ; C5
i1 1.000 1.000 9.02 127.000 127.000 0.000 0.000 0.000 0.000 ; D5
i1 2.000 1.000 9.04 127.000 127.000 0.000 100.000 50.000 0.000 ; E5
i1 3.000 1.000 9.05 127.000 127.000 0.000 50.000 0.000 0.000 ; F5
s
e
; this score was created by Bol Processor BP2 (version BP2.7.2)

To close the score file, type cmd-option space (window "Settings") and uncheck "Write csound scores". Now you may open the score with Csound. (If the computer does not have enough memory, first quit BP2.)

Tell Csound to create a sound file using "BP2test.orc" and "BP2test.sco". Listen to the result. (Nothing great. It just works.)

If you are not happy with the buzz you may try to change the waveform in table 1, as explained in §17.6. Apart from being extremely dull, a sine-wave oscillator may yield weird results when several notes are superimposed. Since BP2 provides Csound with events timed within 1ms accuracy, phasing effects modify considerably the perceived balance of mixed sounds.

Beware of computation overflows occuring at the time Csound processes the score file. These are displayed at computation time. It is wise to use _volume(x) with a proper value of 'x' in range 0..127 so that saturation is avoided. A simple method consists in dividing the maximum volume (127) by the estimated number of simultaneous voices, and use the result as a maximum volume for each voice. Use control parameters _volume(K1), _volume(K2)... to avoid repeating numeric data (see §1.9).

17.6 Csound function tables describing waveforms

Most Csound instruments need tables to produce wave-forms, ramps, etc. These tables are stored by BP2 along with the -cs.<name> file and may be accessed clicking the top left button "Tables..." on the Csound instrument dialog (see Fig.34). Default table "f1" is written following the syntax of Csound:

f1 0 256 10 1

It contains 256 points and uses GEN10 (the harmonic oscillator) with only the first partial, yielding a sine-wave. This is the default table used by BP2.

Csound waveform descriptions are automatically inserted in the beginning of Csound score files. They are not displayed in the "Trace" window even when "Trace Csound" is active. Do not use indexes beyond 100 as these are reserved to function tables automatically produced by BP2 (see §17.12 infra).

17.7 Sound-objects containing Csound scores

Sound-objects contain sequences of elementary events which may be described as a MIDI stream, a Csound score or both.

When BP2 is instructed to produce MIDI real-time or a MIDI file, it uses the MIDI stream of sound-objects and ignores their Csound definitions. Conversely, when asked to write the performance as a Csound score, it uses the Csound score of each sound-object. If the sound-object has no score, BP2 converts its MIDI stream to a Csound score, using the current or default Csound instrument description, as shown in the preceding section.

To produce Csound scores it is wiser to design Csound scores in sound-object prototypes rather than rely on a conversion from MIDI which may leave out relevant parameters.

A demo of the use of sound-objects containing Csound scores is given in "-da.tryCsoundObjects". Type cmd-e ("Edit prototypes") to load the attached "-mi.tryCsoundObjects" sound-object prototype file. Then click button "Csound" to display the Csound score of prototype 'a' (see Fig.36).


Fig.36 The Csound score of a sound-object prototype

The score contains four events invoking instruments 1, 2 and 3. Note that this score is incomplete because it contains only the compulsory arguments for setting time, duration and pitch. BP2 will complete missing arguments with their default values.

To compile this score, BP2 requires the description of instruments supplied by the "-cs.tryCsoundObjects" Csound instrument file. This file has been loaded automatically for two reasons:

To avoid inconsistencies it is sufficient to state the name only once, preferably in the sound-object prototype file.

On the graphics Csound events are marked with red lines whereas MIDI events show as black lines. Objects 'a', 'b' and 'c' in this file contain only Csound scores (as told by radio buttons on Fig.36), whereas the sound-object prototype 'midiobject' also contains a MIDI stream. The MIDI stream and the Csound score of an object may contain similar events as to pitch and timing, but each of them may also contain additional information that is specific to the representation: Csound score lines contain parameters that have no equivalent in the MIDI stream, and conversely a few MIDI messages may not be reflected in a Csound score.

BP2 checks that the Csound score and the MIDI stream, if not empty, represent sequences of events with identical durations. If this is not the case a message is displayed although the user is not forced to correct the mismatch. In this case, the longest duration is taken as the nominal duration of the sound-object prototype.

17.8 Creating a Csound score in a sound-object prototype

There are three ways of creating a Csound score describing the sequence of events in a sound-object prototype.

The third method is a practical way of converting BP2 projects from MIDI to Csound. First of all, a Csound instrument file such as "-cs.tryCsoundObjects" must be loaded so that the conversion makes use of the proper instruments. Then, for each sound-object prototype, click the button "Convert to Csound". If necessary, the MIDI stream may be deleted afterwards: click "Edit/record MIDI stream" and "CLEAR".

Needless to say, sound-objects containing a Csound score may be granted the same properties: pivot, continuity, periodicity (§2.5) etc., as the ones containing a MIDI stream. Thus, Csound users can benefit of advanced features of BP2 as to timing, constraint satisfaction, etc.

17.9 Performing musical items in the Csound environment

For instance we request BP2 to perform

{a,b} c

with sound-object prototypes a, b, c containing the following Csound scores:

Score for a

t 0 120
i1 0 0.5 4.05 ; F0
i1 0 0.5 4.05 ; F0
i2 1.5 0.5 5.05 ; G5
i3 1.5 0.2 643.5 1 ; D#5
e

Score for b

t 0 60
i3 0 0.8 461.34 1; A4
i4 0.1 0.2 6.03 1.05 ; C2
e

Score for c

t 0 120
i2 0 0.2500 9.00 0 0 90 90 ; C5
i2 0.2500 0.2500 9.02 0 0 62 62 ; D5
i2 0.500 0.2500 9.04 0 0 90 90 ; E5
i2 0.7500 0.2500 9.05 0 0 90 90; F5
e

Properties of these sound-objects are the default ones except for 'b' which has its pivot delayed 20% of its duration

The final score (see below) is a combination of the prototype scores shown above. It reads:

t 0.000 60.000
i3 0.000 0.800 461.34 1.000 ; A5
i4 0.100 0.200 6.03 1.050 ; C2
i1 0.160 0.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 0.160 0.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 0.910 0.250 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 0.910 0.100 643.50 1.000 ; D#6
i2 1.160 0.125 9.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; C5
i2 1.285 0.125 9.02 0.000 0.000 62.000 62.000 0.000 0.000 0.000 ; D5
i2 1.410 0.125 9.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; E5
i2 1.535 0.125 9.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F5
s

BP2 appends note names as remarks to events that invoke a pitch-sensitive instrument: 'A5', 'C2'...

Note the changes on timings in the score lines borrowed from sound-object prototypes 'a' and 'c'. These objects have been performed at tempo mm = 60 while their own reference tempo was mm = 120. Since Csound represents time in numbers of beats, their relative durations have been divided by 2.

It may look abnormal that all on-setting dates (except for the first two events) have been delayed by 0.160 beat. The explanation lies in the time setting of the musical item recalling the particular pivot location of sound-object 'b' (see Fig.37).



Fig.37 The time setting of "{a,b} c"



17.10 Performance controls and Csound scores

Other examples in "-da.tryCsoundObjects" demonstrate modifications of Csound argument values caused by performance controls. Try for instance:

_pitchrange(200) _pitchcont _volumecont _volume(30) _pitchbend(0) a C4 D4 b c _pitchbend(100) _volume(127)

containing sound-objects 'a', 'b', 'c' and simple notes 'C4' and 'D4'. Simple notes are set on the default MIDI channel 1 which is also assigned instrument 1 as shown in "-cs.tryCsoundObjects".

The graphic score is shown Fig.38.



Fig.38 The time setting of "a C4 D4 b c"



The different instruments called to perform the resulting sequence of events have various ways of dealing with pitchbend and volume controls. For instance, instruments 3 and 4 do not control pitchbend continuously but they take the current value as argument 5 converted to frequency ratios in particular ranges. Instruments 1 and 2 accept continuous pitchbend controls expressed in cents. Volume is only taken in consideration by instruments 1 and 2.

The output score looks clumsy because of the diverse argument formats used by instruments for this demo.

t 0.000 60.000
i1 0.000 0.250 4.05 30.000 34.850 0.000 -10.000 -4.500 0.000 ;F0
i1 0.000 0.250 4.05 30.000 34.850 0.000 -10.000 -4.500 0.000 ;F0
i2 0.750 0.250 5.05 6.499 11.999 44.550 49.400 0.000 0.000 0.000 ;F1
i3 0.750 0.100 643.50 1.005 ;D#6
i1 1.000 1.000 8.00 49.400 68.800 0.000 12.000 34.000 0.000 ;C4
i3 2.840 0.800 461.34 1.069 ;A5
i4 2.940 0.200 6.03 1.151 ;C2
i1 2.000 1.000 8.02 68.800 88.200 0.000 34.000 56.000 0.000 ;D4
i2 4.000 0.125 9.00 77.990 83.490 107.600 112.450 0.000 0.000 0.000 ;C5
i2 4.125 0.125 9.02 83.490 88.989 77.466 80.807 0.000 0.000 0.000 ;D5
i2 4.250 0.125 9.04 88.989 94.488 117.300 122.150 0.000 0.000 0.000 ;E5
s

Incidentally, this example shows that BP2 does not necessarily produce a Csound score sorted on the on-setting dates of events. This is not a limitation since Csound sorts out dates after reading the score. BP2 does the same before compiling the Csound scores of its own sound-object prototypes.



17.11 Combining argument values

Let us have a closer look at the Csound score of sound-object prototype 'c'.

t 0 120
i2 0 0.2500 9.00 0 0 90 90 ; C5
i2 0.2500 0.2500 9.02 0 0 62 62 ; D5
i2 0.500 0.2500 9.04 0 0 90 90 ; E5
i2 0.7500 0.2500 9.05 0 0 90 90; F5
e

The last two arguments represent volume. Let p0 be the value in a particular place of a score line. (For instance, p0 = 62 on the second event.) If the volume is not explicitly controlled, then p0 is copied to the output score. However, if a "_volume(x)" instruction precedes the sound-object, the output value p1 is calculated as follows:

p1 = p0 * (x / default)

where 'default' is the default volume, i.e. 90 in BP2.

For other controls such as pitchbend, modulation, channel pressure and panoramic, a different formula is used:

p1 = p0 + x - default

where 'default' takes the following values:

These calculations are performed in the MIDI parameter range. If the parameter is mapped to a different range in the Csound domain, p0 is first converted to the MIDI range (using the reverse mapping), the formula is applied, and then the result is mapped back to the Csound range.

17.12 Tabulated functions

In § 17.10 we demonstrated continuous changes of pitchbend and volume ranging over several sound-objects and simple notes. Changes were simple in that their variations could be described as two straight lines. Therefore the only useful information required by the Csound instruments were the start and end values of each parameter.

The situation is often more complex. Parameters may change following arbitrary definitions between the on-setting and the off-setting of a Csound event (a line of the score). BP2 handles this case automatically and builds a function table tied to the event which it inserts before the score line.

In "-da.tryCsound", try for instance:

_ins(1) _pitchrange(200) _pitchbend(0) _pitchcont C4 _ _pitchbend(20)_ _ _pitchbend(165) _ _ D4 _ _ _ _pitchbend(150)

which yields the Csound score:

t 0.000 60.000
f101 0.000 256 -7 0.000 85 20.000 85 165.000 171 160.000
i1 0.000 6.000 8.00 90.000 90.000 0.000 0.000 160.000 101.000 ; C4
i1 6.000 4.000 8.02 90.000 90.000 0.000 160.000 150.000 0.000 ; D4
s

Here the variation of pitchbend on 'D4' is simple and requires only the start/end values (bold on the score). However, the pitchbend variation on 'C4' requires four values: 0, 20, 165 and 160, which BP2 stores in the 'f101' function table linked to 'C4'. The table index '101' appears as the last argument in event 'C4'. When it is 0 (the case with 'D4') no function table is attached.

In "-da.tryCsoundInstruments" a few examples demonstrate BP2's ability to combine calculated parameter values with predefined ones contained in the Csound score of a sound-object. See for instance a complex variation of 'blurb' on sound-object 'e' which contains 4 lines of Csound score.

_cont(blurb) _value(blurb,12) e _value(blurb,110) _ _value(blurb,130) _ _ _value(blurb,80) _ _ _value(blurb,-20) _ _value(blurb,-10) _ _ _ _value(blurb,40)

t 0.000 60.000
f101 0.000 256 -7 12.000 76 110.000 76 130.000 180 96.750
i2 0.000 3.330 7.04 8191.500 8191.500 64.000 64.000 12.000 96.750 101.000 ; E3
f102 0.000 256 -7 12.000 51 110.000 51 130.000 102 80.000 154 30.000
i2 0.000 5.000 7.00 8191.500 8191.500 64.000 64.000 12.000 30.000 102.000 ; C3
f103 5.000 256 -7 40.000 51 -6.000 51 8.000 205 70.000 ; table shifted
i2 5.000 5.000 7.02 8191.500 8191.500 64.000 64.000 40.000 70.000 103.000 ; D3
f104 6.660 256 -7 -13.400 26 -10.000 230 39.917
i2 6.660 3.335 7.07 8191.500 8191.500 64.000 64.000 -13.400 39.917 104.000 ; G3
s

BP2 created function tables attached to each event. But there is more than that. In the Csound score of 'e', event 'D3' had non-zero initial values on arguments 9 and 10. These values have been added to the ones determined by variations of the 'blurb' parameter, thus yielding 40 for argument 9 (the start value of 'blurb') and 70 for argument 10 (the end value). The same modification is reported in table 'f103', and all values in the table changed accordingly.

The first and last values of a function table always reflect the start and end values of the parameter it describes variations of. This allows Csound instruments to operate consistently, either interpolating start and end values, or looking at the attached function table.

17.13 Function tables in sound-object scores

The current version of BP2 does not accept function tables in sound-object scores. This feature will be developed shortly. Function tables in sound-objects should be combined with the ones created by parameter variations in the performance.

17.14 A diagram of the cooperation between BP2 and Csound



Fig.38 BP2 and Csound: two complimentary environments...


Bol Processor BP2 -- a 'QuickStart' 17. Csound on BP2 -- a primer BP2 Reference Manual Title Page Index Contents