Continuous parameters in Csound scores

The following are simple examples explaining the design of Csound scores containing instructions to control parameters that can vary continuously. We will use simple notes (no sound-object) and no Csound instrument file, so that all scores can easily converted into sound files using the "default.orc" orchestra file supplied with BP3.

Consider the following grammar with the metronome set to 60 beats per minute:

S --> _pitchcont _pitchrange(200) C5 _pitchbend(0) D5 _ _pitchbend(120) _ _pitchbend(-150) _ _ _pitchbend(0) E5

The graphic display does not show pitchbend controls:

Pianoroll and object display of "C5 D5 E5"

The _pitchcont instruction at the beginning instructs the interpreter to interpolate pitchbend values throughout whole sequence. This process can be interrupted with _pitchstep.

The _pitchrange(200) instruction indicates that the pitch may vary between -200 and +200 units, which are mapped to the MIDI standard values 0 and +16383 (both logarithmic). This is the range required by "default.orc", which counts intervals in cents. There are 1200 cents in an octave. So, _pitchbend(100) would raise the following note by one semitone.

Note: No pitchbend value is assigned to 'C5'. The default value is '0'. Notes 'D5' and 'E5' are preceded by _pitchbend(0), which assigns a '0' value. All pitchbend variations are assigned during the prolongation of 'D5'. How is this done?

The MIDI output is deceptive. Pitchbend assignments are not taken into account in this format:

"C5 D5 E5" in the MIDI output

However, the Csound output has taken all parameters into account:

"C5 D5 E5" (with pitchbend assignments) in the Csound output

How does Csound process this phrase? Let us look at the Csound score:

t 0.000 60.000
i1 0.000 1.000 9.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C5
f101 1.000 256 -7 0.000 102 120.000 51 -150.000 103 0.000
i1 1.000 5.000 9.02 90.000 90.000 0.000 0.000 0.000 101.000 ; D5
i1 6.000 1.000 9.04 90.000 90.000 0.000 0.000 0.000 0.000 ; E5
s
e

A table (Function Table Statement, see documentation) labelled f101 has been created by Bol Processor and inserted above 'D5' to specify variations of the pitchbend parameter. This table is called by the 10th argument of line 'D5'. Arguments 8 and 9 contain the start and end values of pitchbend according to "default.orc". These are 0 for all three notes.

The second argument of the table is the duration of its validity, here 1.000 seconds. The third argument (256) is its size — always a power of 2. The fourth argument "-7" specifies the GEN routine that Csound will use for its interpolation (see documentation). By default, GEN07 (linear interpolation) is used.

Numbers highlighted in red indicate the values of pitchbend during the variation: 0, 120, -150, 0. Numbers in black indicate the time intervals between two values. Note that 102 + 51 + 103 = 256.

All continuous parameters are handled in the same way by the Bol Processor when creating Csound scores. This includes standard MIDI controls (volume, pressure, modulation, panoramic, pitchbend) and any additional parameters defined in the Csound instrument file. See for example the pages Sound-objects, Csound-objects and Sarasvati Vina.

Note

There is a workaround for playing the same piece with the correct pitchbend changes in MIDI. Change the rule to:

S --> _pitchcont _pitchrange(200) {C5 D5 _ _ _ _ E5, - _pitchbend(0) - _ _pitchbend(120) - _pitchbend(-150) - _ _pitchbend(0) -}

This is the same piece in a polymetric structure, with a line of silences '-' placed in the right places to receive pitchbend modifications. As pitchbend modifies all sounds on the current MIDI channel it will also modify 'D5' during its prolongation. The following is a MIDI rendering on PianoTeq — at a higher speed, so that 'D5' remains audible:

C5 D5 E5 in the MIDI format with pitchbend effects on D5

Csound tuning in BP3

This page deals with the Bol Processor BP3 using an updated version of the Csound orchestra file "default.orc". Changes to the diapason ('A4' frequency) in the settings now affect the production of Csound scores.

In the revised Csound orchestra file, a few lines have been added to change the value of icps (oscillator frequency) according to that of the p4 argument:

if (p4 < 15.0) then
icps = cpspch(p4)
else icps = p4
endif

By default, this instrument receives the pitch value (argument p4) in the octave point pitch-class format — see documentation. In this case, the frequency depends only on the diapason set up in the Csound orchestra, or 440 Hz by default, i.e. cpspch(8.09) = 440.

To "tune" the Csound instrument to the diapason selected for the project in the Bol Processor BP3, if the base frequency is not exactly 440 Hz, p4 will contain the actual frequency of the note (cps format) instead of its octave point pitch-class value. The orchestra file "default.orc" can decide which format is used because (1) no note is ever sent above the 14th octave and (2) frequencies are never lower than 15 Hz. So, the value of p4 automatically makes the decision in "default.orc".

Let us try for example:

S --> A4 B4 C5

If the diapason is 440 Hz, we get the standard Csound score output:

i1 0.000 1.000 8.09 90.000 90.000 0.000 0.000 0.000 0.000 ; A4
i1 1.000 1.000 8.11 90.000 90.000 0.000 0.000 0.000 0.000 ; B4
i1 2.000 1.000 9.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C5

On the first line, 'A4' is set to 8.09 in the octave point pitch-class format.

Once we set the diapason to 435 Hz the Csound score will become:

i1 0.000 1.000 435.00 90.000 90.000 0.000 0.000 0.000 0.000 ; A4
i1 1.000 1.000 488.27 90.000 90.000 0.000 0.000 0.000 0.000 ; B4
i1 2.000 1.000 517.31 90.000 90.000 0.000 0.000 0.000 0.000 ; C5

This score shows the actual frequencies of the notes, for example 'A4' = 435 Hz. This sequence of notes will sound slightly lower than the previous one.

If the diapason is radically different from 440 Hz, the names of the notes will not change. Only the frequencies will be change accordingly. See for example the Csound score created with 'A4' = 300 Hz:

i1 0.000 1.000 300.00 90.000 90.000 0.000 0.000 0.000 0.000 ; A4
i1 1.000 1.000 336.74 90.000 90.000 0.000 0.000 0.000 0.000 ; B4
i1 2.000 1.000 356.76 90.000 90.000 0.000 0.000 0.000 0.000 ; C5

Let us now examine the changes in diapason when dealing with Csound objects. Take for example the object "a" in "-gr.tryCsoundObjects". The Csound score of its prototype (as shown in "-so.tryCsoundObjects") is a mix of 3 instruments:

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

Instruments i1 and i2 use the octave point pitch-class format, while instrument i3 uses the direct cps format. This score has been created with 'A4' = 440 Hz which explains why 643.5 Hz is labelled D#5. The labelling of the notes is of minor importance as it will be revised when the performance Csound score is created.

When 'A4' = 440 Hz the Csound score of a performance of "a" exactly reflects the score in its prototype:

t 0.000 60.000
i1 0.000 0.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 0.750 0.250 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 0.750 0.100 643.50 1.000 ; D#5
s
e

If the diapason is set to 500 Hz the Csound score of the performance will be:

t 0.000 60.000
i1 0.000 0.250 24.80 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 0.750 0.250 49.61 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 0.750 0.100 643.50 1.000 ; C#5
s
e

Pianorolls with A4 = 440 Hz (left) and 500 Hz (right)

All pitches are now given in the cps format. The pitches of notes F0 and F1 would be changed in the sound output. However, the pitch of instrument i3 would remain at 643.50 Hz as set in the sound-object's prototype. As a result of the change in reference, the name of the note produced by i3 would now be 'C#5'. This change is reflected in the pianorolls (see image).

Important…

This automatic pitch format selection does not work if you try to send a frequency lower than 15 Hz, as it would be the case for 'F0' in the previous example if the diapason was set to 300 Hz. This should never happen, however, as 15 Hz is below the range of audible sounds.

At the opposite end, octaves beyond 14 are way beyond the musical range since 'C15' is already more than 535 KHz…

This might have an incidence on Csound scores being used for producing anything else than music, although in this case the use of the octave point pitch-class format is very unlikely.

Changing middle C key number

"Middle C", or 'C4' in the English convention, is the key in the middle of a piano keyboard. By convention, its MIDI key number is 60, but this value can be changed in the settings.

For example, setting 'C4' to key #48 will cause all notes on a MIDI device to be one octave (12 semitones) lower . This does not change the Csound sound output. Playing "A4 B4 C5" with 'C4' other than 60 will produce the same sound output and the same Csound score, but in the cps pitch format:

t 0.000 120.000
i1 0.000 1.000 440.00 90.000 90.000 0.000 0.000 0.000 0.000 ; A4
i1 1.000 1.000 493.88 90.000 90.000 0.000 0.000 0.000 0.000 ; B4
i1 2.000 1.000 523.25 90.000 90.000 0.000 0.000 0.000 0.000 ; C5
s
e

When applied to Csound objects, changing 'C4' to a key number other than 60 will not change the note names or their actual frequencies, but it will use the cps pitch format. For example, playing "a" will result in the following Csound score:

t 0.000 60.000
i1 0.000 0.250 21.83 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 0.750 0.250 43.65 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 0.750 0.100 643.50 1.000 ; D#5
s
e

Csound objects

This article is a continuation of Csound check in which we introduced the creation of Csound parameters monitored by performance controls. Musical phrases were created from simple notes translated into Csound events in a straightforward manner. We now consider the creation of Csound scores based on sound-objects containing Csound instructions — which may be called "Csound objects".

Csound object "e" in the sound-object prototypes file "-so.tryCsoundObjects"

Csound objects contain a Csound score with a specific tempo and duration. For example, in object "e" shown above, the tempo (line "t" of the score) is 120 beats/min. The total duration is 2 beats, or 1000 ms. Note that to calculate the total duration of this sound-object, the durations of 'E3' and 'G3' (0.667 sec) shouldn't be added to those of 'C3' and 'D3', because of the start dates.

The duration of a Csound object is independent of the duration set by MIDI events that may coexist in the sound-object prototype. In most situations, note sequences and durations are identical in the MIDI stream and the Csound score. This makes it possible to play almost the same items via MIDI and Csound. However, as we will see, Csound is open to controls that are not available in MIDI.

Items are found in "‑da.tryCsoundObjects". They can also be created with the grammar "‑gr.tryCsoundObjects" using the alphabet "‑al.tryCsoundObjects" associated with the sound-object prototype file "‑so.tryCsoundObjects".

Calculations can be easily verified given the C-sound resource file "‑cs.tryCsoundObjects". This resource provides access to six Csound instruments, which should be programmed in the relevant Csound orchestra file. Unfortunately, only 'Instrument_1' has been programmed. Attempting to convert the Csound score to a sound file using the other instruments will therefore produce an error message from Csound. On this page, we will focus on visually checking Csound scores.

Let us start with sound-object 'a' whose Csound score is shown below. The score is given for a tempo of 60 beats per minute, giving a total duration of 2 beats ( = 1.5 + 0.5) or 2000 ms.

t 0.000 60
i1 0.000 0.5 4.05 ; F0
i1 0.000 0.5 4.05 ; F0
i2 1.500 0.5 5.05 ; F1
i3 1.500 0.2 643.5 1 ; D#5

The first event (note 'F0') is repeated 2 times with identical timing, a meaningless detail to check that Csound and the Bol Processor can handle this abnormal case.

Events i1 and i2, calling instruments 1 and 2, describe tonal positions in the octave point pitch-class format: octave number + semitones above C. We notice that "5.05" has been mislabelled as 'G5'. This will have no effect on the computation, as the Bol Processor will automatically correct it to 'F1'. It will also rename notes according to the convention set in the settings: English, French or Indian.

Pitch format in instrument 3

Event i3, calling instrument 3, defines pitch as frequency (in Hz). It was assumed that 643.5 Hz is 'D#5' because the diapason is 'A4' = 440 Hz. However, a precise calculation yields 'E5' minus 41 cents.

The tuning of A4 is defined in the settings (page "-se.tryCsoundObjects"). Bol Processor will change the name of this note according to the diapason.

Changes of the diapason are taken into account by BP3 when generating Csound scores, but this was not yet the case with BP2. The following examples have been produced with the default 'A4' = 440 Hz, giving identical results with BP2 and BP3. See the page Csound tuning in BP3 page to examine different cases.

Producing object "a" at a tempo of 60 beats per minute results in the following Csound score:

t 0.000 60
i1 0.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 0.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 1.500 0.500 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 1.500 0.200 643.500 1.000 ; E5 -41 cents

Note that this score is more complete than the one contained in sound-object "a". This is because the "-so.tryCsoundObjects" sound-object prototype file is linked to a Csound resource file named "-cs.tryCsoundObjects":

'Instrument_1' of the Csound resource file is designed to handle 10 arguments while the score of "i1" events in "a" only contains 4. The 6 missing arguments are filled with default values of the parameters they represent. Here, for example, '90' is the default volume. Zeros represent default pitchbend or function table indexes.

You cannot convert this and other examples to sound with the supplied Csound orchestra "0-default.orc", because it only handles instrument 1. All examples on this page are for visual inspection only.

Object graphic of f {a b, c}

In the following example, we need to look at the graph to understand why the events of "a" are delayed by 160ms with respect to "b". Object "b" has a pivot set at 20% of its duration from the start date. This can be checked in "-so.tryCsoundObjects".

Although the object graphic and the pianoroll for this item indicate that "b" should start on a negative date (-160ms), the Csound score is shifted to display only positive or null dates.

{a, b} c

i1 0.160 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 0.160 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i3 0.800 0.800 461.340 1.000 ; A#4 -18 cents
i4 0.800 0.200 6.03 1.050 ; C2 + 35 cents
i2 1.160 0.250 9.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; C5
i2 1.410 0.250 9.02 0.000 0.000 62.000 62.000 0.000 0.000 0.000 ; D5
i2 1.660 0.500 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 1.660 0.200 643.500 1.000 ; E5 -41 cents
i2 1.660 0.250 9.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; E5
i2 1.910 0.250 9.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F5

Note on pivots and relocation: sound-object "b" has its pivot shown as a full arrow, unlike other sound-objects in this set which only have a red triangle. This means that it is not relocatable. Relocation would be performed if these sound-objects had topological properties such as prohibiting the covering of their beginning/end, allowing truncation of beginning/end to a certain degree, breaking the tempo etc. A time-setting algorithm is run on each production to produce a solution that minimises the number of constraints violated. This is explained on the sound-objects page.

 

Sequence "b midiobject"

Let us now look at a phrase containing "midiobject", a sound-object with both a MIDI stream and a Csound score. The MIDI stream is ignored when constructing the score. The time resolution (10 ms) also has no effect on the accuracy of timings in the Csound score.

b midiobject

i3 0.800 0.800 461.340 1.000 ; A#4 -18 cents
i4 0.800 0.200 6.03 1.050 ; C2 + 35 cents
i1 1.160 0.666 7.04 90.000 90.000 0.000 0.000 0.000 0.000 ; E3
i1 1.160 1.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C3
i1 2.160 1.000 7.02 90.000 90.000 0.000 0.000 0.000 0.000 ; D3
i1 2.493 0.667 7.07 90.000 90.000 0.000 0.000 0.000 0.000 ; G3

Since the score of "midiobject" has been defined with a tempo of 60 beats/min for a duration of 2 beats, the durations of the notes E3, C3, D3, G3 are unchanged.

Expression {a b a, c midiobject}

Now consider a polymetric structure in which the first line contains 3 sound-objects and the second line contains 2 sound-objects. The structure will be forced to a symbolic duration of 3 beats — the duration of "a b a" — and the second line will arrange the objects as "two in three" with symbolic durations of 1.5 beats.

This is clear on the picture, looking at the pivots of sound-objects, if one does not get confused by the physical duration of the sound-objects. The sound-object prototype "b" has a duration of 0.8 beats, resulting in a physical duration of 800 ms.

PIanoroll of {a b a, c midiobject}

On the second line, the symbolic duration of each object is 1.5 beats. Consequently, the sound-object "c", whose prototype has a physical duration of 1000 ms, is set to physical duration = 1000 * 1.5 = 1500 ms. The sound-object "midiobject", whose prototype duration is 2000 ms, is set to physical duration 2000 * 1.5 = 3000 ms.

These durations are reflected in the Csound score below.

{a b a, c midiobject}

i1 0.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 0.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 0.000 0.375 9.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; C5
i2 0.375 0.375 9.02 0.000 0.000 62.000 62.000 0.000 0.000 0.000 ; D5
i2 0.750 0.375 9.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; E5
i3 0.840 0.800 461.340 1.000 ; A#4 -18 cents
i4 0.940 0.200 6.030 1.050 ; C2 + 36 cents
i2 1.125 0.375 9.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F5
i2 1.500 0.500 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 1.500 0.200 643.500 1.000 ; E5 -42 cents
i1 1.500 0.999 7.04 90.000 90.000 0.000 0.000 0.000 0.000 ; E3
i1 1.500 1.500 7.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C3
i1 2.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 2.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 3.000 1.500 7.02 90.000 90.000 0.000 0.000 0.000 0.000 ; D3
i1 3.499 1.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 ; G3
i2 3.500 0.500 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 3.500 0.200 643.500 1.000 ; E5 -42 cents

The examples on the rest of this page may not match the configurations produced in 'da.tryCsoundObjects' exactly, because some sound-object parameters were modified after the page was written.

Combined objects and notes

In the following example, we combine sound-objects (containing Csound scores) with simple notes that are converted to Csound events. These notes are played on (default) MIDI channel 1, which is assigned to instrument 1.

 

a C4 D4 b c

Combined objects and notes on pianoroll. Notes in brown colour are those available on both MIDI and Csound outputs. Notes in green are exclusively Csound.

i1 0.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 0.000 0.500 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 1.500 0.500 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 1.500 0.200 643.500 1.000 ; E5 -42 cents
i1 1.000 1.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C4
i1 1.840 1.000 8.02 90.000 90.000 0.000 0.000 0.000 0.000 ; D4
i3 2.840 0.800 461.340 1.000 ; A#4 -18 cents
i4 2.940 0.200 6.030 1.050 ; C2 + 36 cents
i2 4.000 0.250 9.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; C5
i2 4.250 0.250 9.02 0.000 0.000 62.000 62.000 0.000 0.000 0.000 ; D5
i2 4.500 0.250 9.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; E5
i2 4.750 0.250 9.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F5

This combination is highlighted in the pianoroll. Notes that are present in both the MIDI stream and the Csound score are displayed in brown, while notes that are present only in the Csound output are displayed in green.

Pitchbend mapping by instrument 2

Let us apply a continuous pitchbend control to a sound-object containing four Csound instructions, using instrument 2, which maps the MIDI pitchbend range [0..16384] to a range of [-200..+200], both on logarithmic scales. (This mapping is therefore linear.)

In the Bol Processor score, the use of mapped values in _pitchbend() controls is possible, thanks to a _pitchrange(200) instruction at the beginning of the sequence.

The resulting Csound score makes it clear that the pitchbend should vary continuously over each Csound event : 0 to 24.997, 24.997 to 49.994 etc. Csound will further interpolate the values using its GEN 07 (linear interpolation) generator.

_pitchrange(200) _pitchcont _pitchbend(0) c _pitchbend(100)

i2 0.000 0.250 9.00 0.000 24.998 90.000 90.000 0.000 0.000 0.000 ; C5 -> 0 to + 25 cents
i2 0.250 0.250 9.02 24.998 49.997 62.000 62.000 0.000 0.000 0.000 ; D5 -> + 25 to + 50 cents
i2 0.500 0.250 9.04 49.997 74.995 90.000 90.000 0.000 0.000 0.000 ; E5 -> + 50 to + 75 cents
i2 0.750 0.250 9.05 74.995 99.994 90.000 90.000 0.000 0.000 0.000 ; F5 -> + 75 to + 100 cents

Volume control is possible on instruments 1 and 2, but not on instrument 3. Therefore its effect is only applied to certain events of sound-object "a":

_volumecont _volume(30) a _volume(127)

i1 0.000 0.500 4.05 30.000 54.250 0.000 0.000 0.000 0.000 ; F0
i1 0.000 0.500 4.05 30.000 54.250 0.000 0.000 0.000 0.000 ; F0
i2 1.500 0.500 5.05 0.000 0.000 102.750 127.000 0.000 0.000 0.000 ; F1
i3 1.500 0.200 643.500 1.000 ; E5 -42 cents

Csound score of sound-object "d"

In the following example, a continuous pitchbend correction cannot be applied because instrument 5, called by "d", does not have a pitchbend parameter. However, the value of +100 cents is applied to the pitch parameter itself.

The Csound score of sound-object "d" is limited to 1 note at 440 Hz (with reference to instrument 5). This note was labelled 'A4' on the prototype, but we should remember that with a diapason of 435 Hz it will be slightly higher than 'A4'. The increase is 1200 * log2(440/435) = 24 cents. So, in the performance it will be set to 124 cents above 435 Hz, giving 435 * 2^(124/1200) = 467 Hz. As shown below:

_pitchrange(200) _pitchcont _pitchbend(100) d _pitchbend(0)

i5 0.000 0.500 466.16 ; A4

In the following example, a continuous pitchbend correction results in different adjustments of the pitchbend parameters of the instruments called by sound-objects "a", "b" and "c". Simple notes 'C4' and 'D4' call instrument 1 because it is the one assigned to the (default) channel 1. The volume is also adjusted continuously.

Note that we also apply negative values to the pitchbend parameter, expecting the Csound orchestra to do the extrapolation.

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

i1 0.000 0.500 4.05 30.000 34.850 0.000 -9.988 -4.488 0.000 ; F0 -> -10 to -5 cents
i1 0.000 0.500 4.05 30.000 34.850 0.000 -9.988 -4.488 0.000 ; F0 -> -10 to -5 cents
i2 1.500 0.500 5.05 6.512 12.011 44.550 49.400 0.000 0.000 0.000 ; F1 -> + 6 to + 12 cents
i3 1.500 0.200 643.500 1.005 ; E5 -42 -> + 6 cents
i1 1.000 1.000 8.00 49.400 68.800 0.000 12.013 34.014 0.000 ; C4 -> + 12 to + 34 cents
i1 1.840 1.000 8.02 68.800 88.200 0.000 34.014 56.016 0.000 ; D4 -> + 34 to + 56 cents
i3 2.840 0.800 461.340 1.069 ; A#4 -18 -> + 56 cents
i4 2.940 0.200 6.030 1.151 ; C2 + 36 -> + 59 cents
i2 4.000 0.250 9.00 77.995 83.495 107.600 112.450 0.000 0.000 0.000 ; C5 -> + 78 to + 83 cents
i2 4.250 0.250 9.02 83.495 88.995 77.466 80.807 0.000 0.000 0.000 ; D5 -> + 83 to + 89 cents
i2 4.500 0.250 9.04 88.995 94.494 117.300 122.150 0.000 0.000 0.000 ; E5 -> + 89 to + 94 cents
i2 4.750 0.250 9.05 94.494 99.994 122.150 127.000 0.000 0.000 0.000 ; F5 -> + 94 to + 100 cents

D4 starts at 1.840 instead of 2.000. This is because of the forced continuity of "b".

Settings of the "blurb" parameter

Let us check an arbitrary parameter "burb" which affects arguments 9, 10 and 11 of instrument 2.

This parameter is designed as additive in its combinations. The default value is '0'.

In sound-object "e", the third event 'D3' is required to set 'blurb' to a start value of 10 and to an end value of 30.

Csound score of sound-object "e"

These values are added to those interpolated over the continuous 'blurb' variation: 25.6 + (100 - 25.6) * 0.5 = 62.8 and 100 at dates 0.5 and 1 sec. This gives an initial value of 62.8 + 10 = 72.8 and a final value of 100 + 30 = 130.

_cont(blurb) _value(blurb,25.6) e _value(blurb,100)

i2 0.000 0.333 7.04 8191.500 8191.500 64.000 64.000 25.600 50.375 0.000 ; E3
i2 0.000 0.500 7.00 8191.500 8191.500 64.000 64.000 25.600 62.800 0.000 ; C3
i2 0.500 0.500 7.02 8191.500 8191.500 64.000 64.000 72.800 130.000 0.000 ; D3
i2 0.666 0.334 7.07 8191.500 8191.500 64.000 64.000 75.150 99.963 0.000 ; G3

If the variation of "blurb" becomes more complex, the Bol Processor will handle it
through function tables.

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

f101 0.000 256 -7 12.000 76 110.000 76 130.000 104 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 52 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 154 70.000
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

In the Csound score of "e", event 'D3' has non-zero initial values on arguments 9 and 10. These values are added to those determined by variations of the "blurb" parameter, thereby giving 40 for argument 9 (the initial value of "blurb") and 70 for argument 10 (the final value). The same calculation is applied to the attached table f103. Consequently, the first and last values of a function table always reflect the initial and final values of the parameter. This allows Csound instruments to operate in a consistent manner, either interpolating the initial and final values, or picking up (and interpolating) the values in the attached function table.

The "oops" parameter in instrument 6

The Bol Processor combines Csound parameters either additively or multiplicatively. For predefined MIDI-mapped parameters, the combination mode is preset: all parameters, except volume, are combined additively. For additional (non-MIDI) parameters, the composer can choose both the default value and the combination mode.

For example, instrument 6 deals with an "oops" parameter that combines multiplicatively. Sound-object "f" contains calls to this instrument with values of "oops" other than the default.

f

i6 0.000 0.500 7.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 0.500 1.500 0.000 0.000 0.000 0.000 ; C3
i6 0.500 0.500 7.02 0.000 0.000 90.000 90.000 0.000 0.000 0.000 0.000 4.700 0.000 0.000 0.000 0.000 ; D3
i6 1.000 0.500 7.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 0.250 2.500 0.000 0.000 0.000 0.000 ; E3

_cont(oops) _value(oops,0) f _value(oops,4)

i6 0.000 0.500 7.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 0.000 2.000 0.000 0.000 0.000 0.000 ; C3
i6 0.500 0.500 7.02 0.000 0.000 90.000 90.000 0.000 0.000 0.000 0.000 12.533 0.000 0.000 0.000 0.000 ; D3
i6 1.000 0.500 7.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 0.667 10.000 0.000 0.000 0.000 0.000 ; E3

Sound-object f for mm = 60 beats/min

The "oops" parameter varies from 0 to 4 over 1500 ms. At the start of 'D3' and 'E3', its values are 4 * (500 / 1500) = 1.33 and 4 * (1000 / 1500) = 2.66 respectively.

The initial value of "oops" in 'C3' is 0 * 0.5 = 0, and its final value 1.5 * 1.33 = 2, as shown on the score.

The initial value for 'D3' will be O, and for 'E3' it will be 0.25 * 2.66 = 0.665. The value at the end of 'D3' is 4.7 * 2.66 = 12.5. The value at the end of D3 is 2.5 * 4 = 10.


These examples have been designed to test all the features of the Csound interface as it is implemented in Bol Processor. We expect more to come as both environments continue to explore new concepts and build tools for musicians.

We apologise for the lack of a corpus of real musical pieces created with Bol Processor and Csound. A first example of high musical quality was composed in 1996: read and listen to Sarasvati vina!

Csound checkup

Csound in the Bol Processor (BP2, BP3) environment

This article and the next one on Csound objects are reserved for Csound geeks interested in creating Csound scores with Bol Processor. They are complementary but they can be studied independently.

The examples in this section are not intended to be auditory. Rather, the idea was to produce short Csound scores that could be used to illustrate the treatment of parameters in a variety of contexts.

The calculations in this article can be easily checked against the Csound instrument file "‑cs.chekAllCsound" included in the bp3-ctests-main.zip example set.

All items can be produced with the grammar "‑gr.checkAllCsound".

Let us start with a simple example:

A4 G4 C5 A4

This produces the following Csound score:

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

Instrument 2 is used because it's the one assigned to channel 1 by default in the Csound instrument file "-cs.checkAllCsound".
This score will not produce any sound with the "default.orc" orchestra file because it does not contain a definition for instrument 2.
Argument 4 is the pitch (in Herz) related to the diapason (frequency of A4) set in "-se.checkAllCsound".
Argument 5 is the MIDI value of the volume, default 90 according to the settings.
Arguments 6 and 7 can be used for the 'blurb' parameter (see infra).
Argument 8 is not not used, its value remains 0.

No treatment of MIDI pitchbend in instrument 2

Instrument 2 does not use the pitchbend value as a parameter, but changes the pitch parameter (in Hz) accordingly. In the following example, G4, which is 200 cents higher, will be played 2 semitones higher, at the same pitch as A4 (440 Hz).

_pitchrange(200) A4 _pitchbend(200) G4 _pitchbend(0) C5 A5

i2 0.000 1.000 440.00 90.000 0.000 0.000 0.000 ; A4
i2 1.000 1.000 440.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 880.00 90.000 0.000 0.000 0.000 ; A5

Volume mapping in instrument 3

Now we will force the instrument to 3. Note that many new parameters are displayed.
The default volume is 90 on the MIDI scale. This is converted to 16.98 (log scale) using the volume mapping defined in instrument 3.
As instrument 3 accepts pitchbend corrections (arguments 5 and 6), pitchbend = 16383 (+2 semitones) is applied to G4 instead of changing its frequency.

_ins(3) _pitchrange(200) A4 _pitchbend(200) G4 _pitchbend(0) C5 A5

i3 0.000 1.000 440.00 8191.500 8191.500 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 392.00 16383.000 16383.000 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; G4
i3 2.000 1.000 523.25 8191.500 8191.500 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; C5
i3 3.000 1.000 880.00 8191.500 8191.500 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; A5

Arguments 5 and 6 represent the start and end values of the pitchbend. This makes it possible to tell Csound to calculate a portamento (see infra).

Mapping of modulation in instrument 3

Playing simple notes on channel 2 calls up instrument 3, which has volume and modulation control parameters. Here the modulation range (0 to 12431) is mapped to 0 to 3035.097 (arguments 11 and 12).

chan(2) _modcont _mod(0) C4 D4__ E4 _mod(12431)

i3 0.000 1.000 261.63 8191.500 8191.500 16.981 16.981 0.000 0.000 0.000 607.019 0.000 ; C4
i3 1.000 3.000 293.66 8191.500 8191.500 16.981 16.981 0.000 0.000 607.019 2428.078 0.000 ; D4
i3 4.000 1.000 329.63 8191.500 8191.500 16.981 16.981 0.000 0.000 2428.078 3035.097 0.000 ; E4

Another way to do the same without tempering with channels is to use instrument 3.

ins(3) _modcont _mod(0) C4 D4__ E4 _mod(12431)

Note that instrument specifications override the assignments of The_default instrument, which are made on the basis of the MIDI channel. For instance, in the following example, because of the _ins(1) statement, _chan(2) does not set the instrument index to 3, so _mod() is ignored:

ins(1) _chan(2) _modcont _mod(0) C4 D4__ E4 _mod(12431)

i1 0.000 1.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C4
i1 1.000 3.000 8.02 90.000 90.000 0.000 0.000 0.000 0.000 ; D4
i1 4.000 1.000 8.04 90.000 90.000 0.000 0.000 0.000 0.000 ; E4

Polymetric structure {C5 D5 E5 F5, G5 D5 C6}

Let us consider a polymetric structure in which the same note (D5) has two consecutive NoteOn's.

In MIDI, a NoteOff is inserted before the second NoteOn of "D5". In Csound the same
instrument is called twice. In both versions the break between successive occurrences of "D5" is audible.

_ins(The_default) {_volume(30) C5 D5 E5 F5,_volume(20) G5 D5 C6}

i1 0.000 1.000 9.00 30.000 30.000 0.000 0.000 0.000 0.000 ; C5
i1 0.000 1.333 9.07 20.000 20.000 0.000 0.000 0.000 0.000 ; G5
i1 1.000 1.000 9.02 30.000 30.000 0.000 0.000 0.000 0.000 ; D5
i1 1.333 1.333 9.02 20.000 20.000 0.000 0.000 0.000 0.000 ; D5 striked again
i1 2.000 1.000 9.04 30.000 30.000 0.000 0.000 0.000 0.000 ; E5
i1 3.000 1.000 9.05 30.000 30.000 0.000 0.000 0.000 0.000 ; F5
i1 2.666 1.334 10.00 20.000 20.000 0.000 0.000 0.000 0.000 ; C6

Note that this example would sound strange without the volume controls: we would get a silence during the time the two D5' are superimposed, simply because they are sine waves with equal amplitudes and opposite phases!

Let us look at the same note played at different volumes in stepwise variations. Notice that instrument 3 is now specified by its name "Harpsichord". (Don't look for it in an orchestra file!)

_ins(Harpsichord) _volume(0) A4 _volume(32) A4 _volume(64) A4 _volume(80) A4_volume(127) A4

i3 0.000 1.000 440.00 8191.500 8191.500 -24.000 -24.000 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 440.00 8191.500 8191.500 -2.763 -2.763 0.000 0.000 0.000 0.000 0.000 ; A4
i3 2.000 1.000 440.00 8191.500 8191.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; A4
i3 3.000 1.000 440.00 8191.500 8191.500 13.204 13.204 0.000 0.000 0.000 0.000 0.000 ; A4
i3 4.000 1.000 440.00 8191.500 8191.500 24.000 24.000 0.000 0.000 0.000 0.000 0.000 ; A4

The following illustration shows the volume decreasing continuously from 127 (i.e. +24 after mapping) to 0 (i.e. -24 after mapping). Instrument 3 has two parameters (7 and 8) that take the start and end volumes respectively, and these values are interpolated by Csound (using scheme GEN07) to produce a continuous change.

_ins(Harpsichord) _volumecont _volume(127) A4 _volume(0)

i3 0.000 1.000 440.00 8191.500 8191.500 24.000 -24.000 0.000 0.000 0.000 0.000 0.000 ; A4

Now we will look at similar continuous changes over several notes invoking the same instrument.

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

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

The same, but step by step:

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

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

Changing the volume continuously on the first two notes, then the volume stays unchanged:

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

i3 0.000 1.000 440.00 8191.500 8191.500 24.000 4.549 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 392.00 8191.500 8191.500 4.549 -7.372 0.000 0.000 0.000 0.000 0.000 ; G4
i3 2.000 1.000 523.25 8191.500 8191.500 -7.372 -7.372 0.000 0.000 0.000 0.000 0.000 ; C5
i3 3.000 1.000 880.00 8191.500 8191.500 -7.372 -7.372 0.000 0.000 0.000 0.000 0.000 ; A5

Continuous pitchbend variation over an entire phrase:

_ins(Harpsichord) _pitchcont _pitchbend(16383) A4 G4 C5 A5 A4 G4 C5 A5 _pitchbend(0)

i3 0.000 1.000 440.00 16383.000 14335.125 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 392.00 14335.125 12287.250 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; G4
i3 2.000 1.000 523.25 12287.250 10239.375 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; C5
i3 3.000 1.000 880.00 10239.375 8191.500 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; A5
i3 4.000 1.000 440.00 8191.500 6143.625 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; A4
i3 5.000 1.000 392.00 6143.625 4095.750 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; G4
i3 6.000 1.000 523.25 4095.750 2047.875 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; C5
i3 7.000 1.000 880.00 2047.875 0.000 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; A5

Here, pitchbend and volume vary simultaneously:

_ins(Harpsichord) _volumecont _volume(0) _pitchcont _pitchrange(200) _pitchbend(200) A4 G4 C5 A5 A4 G4 C5 A5 _pitchbend(-200) _volume(127)

i3 0.000 1.000 440.00 16383.000 14335.125 -24.000 -5.547 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 392.00 14335.125 12287.250 -5.547 -2.794 0.000 0.000 0.000 0.000 0.000 ; G4
i3 2.000 1.000 523.25 12287.250 10239.375 -2.794 -1.179 0.000 0.000 0.000 0.000 0.000 ; C5
i3 3.000 1.000 880.00 10239.375 8191.500 -1.179 -0.031 0.000 0.000 0.000 0.000 0.000 ; A5
i3 4.000 1.000 440.00 8191.500 6143.625 -0.031 12.899 0.000 0.000 0.000 0.000 0.000 ; A4
i3 5.000 1.000 392.00 6143.625 4095.750 12.899 18.431 0.000 0.000 0.000 0.000 0.000 ; G4
i3 6.000 1.000 523.25 4095.750 2047.875 18.431 21.688 0.000 0.000 0.000 0.000 0.000 ; C5
i3 7.000 1.000 880.00 2047.875 0.000 21.688 24.000 0.000 0.000 0.000 0.000 0.000 ; A5

So far we have seen how instruments interpolate between single start and end values.
Instrument 1, here called "The_default", i.e. the one defined in "default.orc", is able to vary pitchbend and volume in a more sophisticated way, using a function table.

BP3 automatically creates function tables when required and when the instrument specification (here "-cs.checkAllCsound") provides slots (arguments) for entering function table indexes.

Let us look at a simple example with pitchbend. Both of the following notations result in the same score.
You will hear the production of this score with the demo orchestra "default.orc". (Doesn't sound great!)

ins(The_default) _pitchcont _pitchbend(0) D4__ _pitchbend(16383) E4_ _pitchbend(0)__

ins(The_default) _pitchrange(200) _pitchcont _pitchbend(-200) D4__ pitchbend(+200) E4_ pitchbend(-200)__

i1 0.000 3.000 8.02 90.000 90.000 0.000 -200.000 200.000 0.000 ; D4
f101 3.000 256 -7 200.000 102 -200.000 154 -200.000
i1 3.000 5.000 8.04 90.000 90.000 0.000 200.000 -200.000 101.000 ; E4

Note that GENO7 is used. GENO8 (cubic spline interpolation) could be considered, but it has the disadvantage of forcing the first derivative to zero at the start and end points. GEN07 is also much faster.

Here, C4 needs a 4-point table, because of _pitchcont whereas D4 only needs linear interpolation?

ins(1) _pitchrange(200) _pitchbend(0) _pitchcont C4_ _pitchbend(20) __ _pitchbend(165) __ D4 _ _ _ _pitchbend(150)

f101 0.000 256 -7 0.000 85 20.000 85 165.000 86 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

Here, the initial portamento on a silence '-' is only provided by the
MIDI output. Csound ignores silence:

ins(1) _pitchrange(200) _pitchbend(0) _pitchcont - ___ C4 ___ _pitchbend(200) __ D4 ___ _pitchbend(150)

f101 4.000 256 -7 100.000 170 200.000 86 183.333
i1 4.000 6.000 8.00 90.000 90.000 0.000 100.000 183.333 101.000 ; C4
i1 10.000 4.000 8.02 90.000 90.000 0.000 183.333 150.000 0.000 ; D4

ins(1) _pitchrange(200) _pitchbend(0) _pitchcont - _ _pitchbend(20) __ C4 ___ _pitchbend(200) __ D4 ___ _pitchbend(150)

f101 4.000 256 -7 80.000 170 200.000 86 183.333
i1 4.000 6.000 8.00 90.000 90.000 0.000 80.000 183.333 101.000 ; C4
i1 10.000 4.000 8.02 90.000 90.000 0.000 183.333 150.000 0.000 ; D4

ins(1) _pitchcont _pitchrange(200) _pitchbend(0) - ___ C4 ___ _pitchbend(200) __ D4 ___ _pitchbend(150

f101 4.000 256 -7 100.000 170 200.000 86 183.333
i1 4.000 6.000 8.00 90.000 90.000 0.000 100.000 183.333 101.000 ; C4
i1 10.000 4.000 8.02 90.000 90.000 0.000 183.333 150.000 0.000 ; D4

Here the section between brackets { } follows an independent portamento

ins(1) _pitchcont _pitchrange(200) _pitchbend(0) - ___ {C4 ___ _pitchbend(200) __ } D4 ___ _pitchbend(150)

f101 4.000 256 -7 42.857 170 200.000 86 200.000
i1 4.000 6.000 8.00 90.000 90.000 0.000 42.857 200.000 101.000 ; C4
i1 10.000 4.000 8.02 90.000 90.000 0.000 107.143 150.000 0.000 ; D4

A polymetric structure. E4 retains the initial pitchbend value of C4.

ins(1) _pitchcont _pitchrange(200) _pitchbend(0) - ___ {C4 ___ _ pitchbend(200) __ , E4} D4 ___ _pitchbend(150)

f101 4.000 256 -7 42.857 170 200.000 86 200.000
i1 4.000 6.000 8.00 90.000 90.000 0.000 42.857 200.000 101.000 ; C4
i1 4.000 6.000 8.04 90.000 90.000 0.000 42.857 107.143 0.000 ; E4
i1 10.000 4.000 8.02 90.000 90.000 0.000 107.143 150.000 0.000 ; D4

Here, E4 has its own independent movement, which would be impossible with MIDI.

ins(1) _pitchcont _pitchrange(200) _pitchbend(0) - ___ {C4 ___ _ pitchbend(200) __ ,E4_ _pitchbend(180) _ _pitchbend(60) _ } D4 ____ _pitchbend(150)

f101 4.000 256 -7 42.857 170 200.000 86 200.000
i1 4.000 6.000 8.00 90.000 90.000 0.000 42.857 200.000 101.000 ; C4
f102 4.000 256 -7 42.857 128 180.000 64 60.000 64 60.000
i1 4.000 6.000 8.04 90.000 90.000 0.000 42.857 60.000 102.000 ; E4
i1 10.000 4.000 8.02 90.000 90.000 0.000 107.143 150.000 0.000 ; D4

Don't forget to set _pitchrange(200) on channel 2, otherwise _pitchbend(180) will be used as the MIDI value (range 0..16383). Note again that channel 2 will not call instrument 3 because instrument 1 has already been specified.

ins(1) _pitchcont _pitchrange(200) _pitchbend(0) - ___ {C4 ___ _ pitchbend(200) __ , _chan(2) _pitchrange(200) E4_ _pitchbend(180) __ } D4 ___ _pitchbend(150)

f101 4.000 256 -7 42.857 170 200.000 86 200.000
i1 4.000 6.000 8.00 90.000 90.000 0.000 42.857 200.000 101.000 ; C4
f102 4.000 256 -7 42.857 128 180.000 128 180.000
i1 4.000 6.000 8.04 90.000 90.000 0.000 42.857 180.000 102.000 ; E4
i1 10.000 4.000 8.02 90.000 90.000 0.000 107.143 150.000 0.000 ; D4

In the above example, if you forget to set the instrument to 1, instruments will be assigned based on MIDI channels. This results in:

pitchcont _pitchrange(200) _pitchbend(0) - ___ {C4 ___ _ pitchbend(200) __ , _chan(2) _pitchrange(200) E4_ _pitchbend(180) __ } D4 ___ _pitchbend(150)

i2 4.000 6.000 268.18 90.000 0.000 0.000 0.000 ; C4
i3 4.000 6.000 329.63 9946.821 15563.850 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; E4
i2 10.000 4.000 312.41 90.000 0.000 0.000 0.000 ; D4

Let us now try an arbitrary parameter 'blurb' (which has no MIDI equivalent)
on the two instruments 'Harpsichord' and 'Flute'.

_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

Instrument "Flute" can handle function tables for 'blurb'.

ins(Flute) _cont(blurb) _value(blurb,544.5) C4__ _value(blurb,120) __ _value(blurb,-37)___ _value(blurb,0)

f101 0.000 256 -7 544.500 96 120.000 64 -37.000 96 0.000
i2 0.000 8.000 261.63 90.000 544.500 0.000 101.000 ; C4

Note that if the 'arbitrary' parameter is called 'volume', it will be MIDI volume, here remapped to the range -24..+24

_ins(Harpsichord) _cont(volume) _value(volume,127) A4 B4 _value(volume,0)

i3 0.000 1.000 440.00 8191.500 8191.500 24.000 -0.031 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 493.88 8191.500 8191.500 -0.031 -24.000 0.000 0.000 0.000 0.000 0.000 ; B4

The same applies to 'pitchbend', 'pressure', 'panoramic' and 'modulation' (all case sensitive). In instrument 3, MIDI modulation is remapped to the range 0..4000.

_ins(Harpsichord) _cont(modulation) _value(modulation,0) A4 B4 C5 D5 _value(modulation,16383)

i3 0.000 1.000 440.00 8191.500 8191.500 16.981 16.981 0.000 0.000 0.000 1000.000 0.000 ; A4
i3 1.000 1.000 493.88 8191.500 8191.500 16.981 16.981 0.000 0.000 1000.000 2000.000 0.000 ; B4
i3 2.000 1.000 523.25 8191.500 8191.500 16.981 16.981 0.000 0.000 2000.000 3000.000 0.000 ; C5
i3 3.000 1.000 587.33 8191.500 8191.500 16.981 16.981 0.000 0.000 3000.000 4000.000 0.000 ; D5

Now the two have been combined:

_ins(Harpsichord) _cont(volume) _cont(modulation) _value(volume,127) _value(modulation,0) A4 B4 C5 D5 _value(volume,0) _value(modulation,16383)

i3 0.000 1.000 440.00 8191.500 8191.500 24.000 18.431 0.000 0.000 0.000 1000.000 0.000 ; A4
i3 1.000 1.000 493.88 8191.500 8191.500 18.431 -0.031 0.000 0.000 1000.000 2000.000 0.000 ; B4
i3 2.000 1.000 523.25 8191.500 8191.500 -0.031 -2.794 0.000 0.000 2000.000 3000.000 0.000 ; C5
i3 3.000 1.000 587.33 8191.500 8191.500 -2.794 -24.000 0.000 0.000 3000.000 4000.000 0.000 ; D5

Note that if the additional parameter is unknown to the instrument, it will simply be ignored. No warning will be given. For example:

_ins(Harpsichord) _cont(gasp) _value(gasp,0) A4 B4 _value(gasp,1000)

i3 0.000 1.000 440.00 8191.500 8191.500 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; A4
i3 1.000 1.000 493.88 8191.500 8191.500 16.981 16.981 0.000 0.000 0.000 0.000 0.000 ; B4

The 'Splashmachine' instrument handles the 'splash' parameter which is instructed to create function tables with GEN08 (cubic spline) instead of GEN07.

ins(Splashmachine) _cont(splash) _value(splash,544.5) C4__ _value(splash,120) __ _value(splash,-37)___ _value(splash,130)

f101 0.000 256 -8 544.500 96 120.000 64 -37.000 96 130.000
i4 0.000 8.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 544.500 130.000 101.000 ; C4

The same instrument also uses GENO8 for the pitchbend.

_ins(Splashmachine) _cont(pitchbend) _pitchrange(200) _value(pitchbend,120) C4__ _value(pitchbend,34) __ _value(pitchbend,55)___ _value(pitchbend,-160)

This can be written more simply:

_ins(Splashmachine) _cont(pitchbend) _pitchrange(200) _pitchbend(120) C4__ _pitchbend(34) __ _pitchbend(55)___ _pitchbend(-160)

f101 0.000 256 -8 120.000 96 34.000 64 55.000 96 -160.000
i4 0.000 8.000 8.00 90.000 90.000 0.000 120.000 -160.000 101.000 0.000 0.000 0.000 ; C4

All these examples produce identical results with BP2.9.8 and its current version BP3.

Want to know more? Read the page Csound objects!

Csound argument mapping

Performing a quadratic mapping using 3 points: how can we make sure that the function will be monotonous?

This is part of document “Check of Bol Processor ‘BP3’ with PHP interface” on the “Bol Processor” website.

The algorithm is implemented in function Findabc() of "CsoundMaths.c".


When three pairs of input/output values are supplied, BP2 attempts to define a quadratic mapping from the input (x) to output (y).

This is an example of a successful mapping: 

BP2 expects the mapping function to be monotonous, i.e. the three values (x1, x2, x3) supplied as the input and the ones supplied as the output (y1, y2, y3) must be strictly ordered. Even in this case a proper quadratic mapping may not be possible. See for instance: 

Here the quadratic function is not monotonous even though the input values are ordered properly. In this case, BP2 replaces the incorrect part (the one containing an extremum) with a linear function, and changes the other part to make the curve tangent to the linear part. This yields the graph shown below: 


« Translate