Csound objects

This arti­cle is the con­tin­u­a­tion of Csound check in which we intro­duced the cre­ation of Csound para­me­ters mon­i­tored by per­for­mance con­trols. Musical phras­es were made of sim­ple notes trans­lat­ed to Csound events in a straight­for­ward man­ner. We are now con­sid­er­ing the cre­ation of Csound scores based on sound-objects con­tain­ing Csound instruc­tions — which may be called “Csound objects”.

Csound object “e” in sound-object pro­to­types file “-mi.tryCsoundObjects”

Csound objects con­tain a Csound score with spe­cif­ic tem­po and dura­tion. For instance, in object “e” shown above, the tem­po (line “t” of the score) is 120 beats/min. The total dura­tion is 2 beats, there­fore 1000 ms. Beware that, to cal­cu­late the total dura­tion of this sound-object, dura­tions of ‘E3’ and ‘G3’ (0.667 sec) should­n’t be added to those of ‘C3’ and ‘D3’, due to start dates.

The dura­tion of a Csound object is inde­pen­dent on the one set by MIDI events which may coex­ist in the sound-object pro­to­type. In most sit­u­a­tions, note sequences and dura­tions are iden­ti­cal in the MIDI stream and the Csound score. This makes it pos­si­ble to play almost the same items via MIDI and Csound. Nonetheless, as we will see, Csound is open to con­trols inac­ces­si­ble to MIDI.

Computations can eas­i­ly be ver­i­fied in ref­er­ence to the Csound instru­ments file “‑cs.tryCsoundObjects” sup­plied in sam­ple set bp3-ctests-main.zip — down­load­able from GitHub along with Bol Processor BP3’s inter­face: php-frontend-master.zip. Items can be pro­duced with gram­mar “‑gr.tryCsoundObjects” using alpha­bet “‑ho.tryCsoundObjects” asso­ci­at­ed with the sound-object pro­to­types file “‑mi.tryCsoundObjects”.

Score of sound-object “a”

Let us start with sound-object “a” whose score is shown on the image. The score is giv­en for a tem­po of 120 beats/min, yield­ing a total dura­tion of 2 beats ( = 1.5 + 0.5) or 1000 ms.

The first event (note ‘F0’) is repeat­ed 2 times with iden­ti­cal dates, a mean­ing­less detail for ver­i­fy­ing that Csound can han­dle this abnor­mal case.

Events i1 and i2, call­ing instru­ments 1 and 2, describe tonal posi­tions in the octave point pitch-class for­mat: octave num­ber + semi­tones above C. We notice that “5.05” has been wrong­ly labelled ‘G5’. Yet this will have no inci­dence on the com­pu­ta­tion as Bol Processor will auto­mat­i­cal­ly fix it to ‘F1’. It will also rename notes as per the con­ven­tion set in the set­tings: English, French or Indian.

Pitch for­mat in instru­ment 3

Event i3, call­ing instru­ment 3, defines pitch as fre­quen­cy (in Hz). It is assumed that 643.5 Hz is ‘D#5′ because the dia­pa­son is ‘A4’ = 440 Hz. This tun­ing is defined in the set­tings (page “-se.tryCsoundObjects”). Bol Processor may change the name of this note accord­ing to the diapason.

Changes of the dia­pa­son are tak­en care by BP3 when pro­duc­ing Csound scores, but this was not yet the case with BP2. The fol­low­ing exam­ples have been pro­duced with the stan­dard ‘A4’ = 440 Hz, yield­ing iden­ti­cal results with BP2 and BP3. Refer to page Csound tun­ing in BP3 to exam­ine dif­fer­ent cases. 

Producing object “a” at a tem­po of 60 beats/min yields the fol­low­ing Csound score:

a

Pianoroll of object “a”

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

Note that this score is more com­plete than the one con­tained in sound-object “a”. The rea­son is that the sound-object pro­to­types file “-mi.tryCsoundObjects” is linked to a Csound instru­ments file “-cs.tryCsoundObjects” (see pic­ture below).

Mention of the relat­ed Csound instru­ments file is nec­es­sary to bind it to the sound-objects pro­to­types file.

Instrument 1 of the Csound instru­ments file is designed to han­dle 10 argu­ments where­as the score of “i1” events in “a” con­tains only 4. The 6 miss­ing argu­ments are added with default val­ues of the para­me­ters they rep­re­sent. Here, for instance ‘90’ is the default vol­ume. Zeros rep­re­sent default pitch­bend or func­tion table indexes.

Note that “5.05” has been prop­er­ly fixed to “F1”. This is only rel­e­vant for human read­ers because Csound ignores any text fol­low­ing a semicolon.

You can­not con­vert to sound this and oth­er exam­ples with the sup­plied Csound orches­tra “default.orc” because it han­dles only instru­ment 1. Examples on this page are for visu­al inspec­tion only.

Object graph­ic of f {a b, c}

In the fol­low­ing exam­ple, we need to look at the graph­ic dis­play to under­stand why events of “a” are 160ms delayed com­pared with “b”. Object “b” has a piv­ot set from the start date at 20% of its dura­tion. This can be ver­i­fied in “-mi.tryCsoundObjects”.

Even though the object graph­ic and the pianoroll of this item indi­cate that “b” should start at a neg­a­tive date (-160ms), the Csound score is shift­ed to dis­play only pos­i­tive or null dates.

{a, b} c

Pianoroll of {a b, c}

i3 0.000 0.800 461.34 1.000 ; A4
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#5
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

Remark on piv­ots and relo­ca­tion: sound-object “b” is dis­played with its piv­ot shown as a com­plete arrow, unlike oth­er sound-objects in this set which only have a red tri­an­gle. This means that it is not relo­cat­able. Relocation would be per­formed if these sound-objects had topo­log­i­cal prop­er­ties such as pro­hibit­ing the cov­er­ing of their beginning/end, allow­ing trun­ca­tion of beginning/end to a cer­tain degree, break­ing the tem­po etc. A constraint-satisfaction algo­rithm is run on every pro­duc­tion to pro­duce a solu­tion min­i­miz­ing breach­es of con­straints. This is best illus­trat­ed by “-gr.koto3″ (read arti­cle).

Sequence “b midiobject”

Let us now look at a phrase con­tain­ing “mid­iob­ject”, a sound-object with both a MIDI stream and a Csound score. The MIDI stream is ignored in the con­struc­tion of the score. The time res­o­lu­tion (10 ms) also has no effect on the accu­ra­cy of tim­ings in Csound scores.

b mid­iob­ject

i3 0.000 0.800 461.34 1.000 ; A4
i4 0.100 0.200 6.03 1.050 ; C2
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 “mid­iob­ject” has been defined at a tem­po of 60 beats/min for a dura­tion of 2 beats, dura­tions of notes E3, C3, D3, G3 are unchanged.

Expression {a b a, c midiobject}

Let us now look at a poly­met­ric struc­ture in which the first line con­tains 3 sound-objects and the sec­ond line 2 sound-objects. The struc­ture will be forced to a sym­bol­ic dura­tion of 3 beats — the dura­tion of “a b a” — and the sec­ond line will arrange objects as “two in three” with sym­bol­ic dura­tions 1.5 beats.

This is clear on the pic­ture, look­ing at the piv­ots of sound-objects, if one is not con­fused by the phys­i­cal dura­tion of sound-objects. Sound-object pro­to­type “b” has a dura­tion of 0.8 beats, result­ing in a phys­i­cal dura­tion of 800 ms.

PIanoroll of {a b a, c midiobject}

On the sec­ond line, the sym­bol­ic dura­tion of each object is 1.5 beats. Consequently, sound-object “c”, whose pro­to­type has a phys­i­cal dura­tion of 500 ms, is set to phys­i­cal dura­tion = 500 * 1.5 = 750 ms. Object “c” appears as sequence “C5 D5 E5 F5” with total phys­i­cal dura­tion of 4 * 188 ms = 752 ms. These dura­tions are reflect­ed in the Csound score below.

{a b a, c midiobject}

i1 0.000 0.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 0.000 0.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 0.000 0.188 9.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; C5
i2 0.187 0.188 9.02 0.000 0.000 62.000 62.000 0.000 0.000 0.000 ; D5
i2 0.374 0.188 9.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; E5
i2 0.561 0.188 9.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F5
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
i3 0.840 0.800 461.34 1.000 ; A4
i4 0.940 0.200 6.03 1.050 ; C2
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.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i1 2.000 0.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
i2 2.750 0.250 5.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F1
i3 2.750 0.100 643.50 1.000 ; D#5
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

Combined objects and notes

In the fol­low­ing exam­ple, we com­bine sound-objects (con­tain­ing Csound scores) with sim­ple notes that will be con­vert­ed to Csound events. These notes are played on (default) MIDI chan­nel 1 which is assigned to instru­ment 1.

a C4 D4 b c

Combined objects and notes on pianoroll. Notes in brown colour are the ones avail­able on both MIDI and Csound out­puts. Notes in green are exclu­sive­ly Csound.

i1 0.000 0.250 4.05 90.000 90.000 0.000 0.000 0.000 0.000 ; F0
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
i1 1.000 1.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 ; C4
i3 2.840 0.800 461.34 1.000 ; A4
i4 2.940 0.200 6.03 1.050 ; C2
i1 2.000 1.000 8.02 90.000 90.000 0.000 0.000 0.000 0.000 ; D4
i2 4.000 0.125 9.00 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; C5
i2 4.125 0.125 9.02 0.000 0.000 62.000 62.000 0.000 0.000 0.000 ; D5
i2 4.250 0.125 9.04 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; E5
i2 4.375 0.125 9.05 0.000 0.000 90.000 90.000 0.000 0.000 0.000 ; F5

This com­bi­na­tion is high­light­ed in the pianoroll. Notes exist­ing in both the MIDI stream and the Csound score are dis­played in brown where­as notes exist­ing only in the Csound out­put are dis­played in green.

Pitchbend map­ping by instru­ment 2

Let us apply a con­tin­u­ous con­trol of pitch­bend over a sound-object con­tain­ing four Csound state­ments, using instru­ment 2 which is map­ping MIDI pitch­bend range [0..16384] to a range of [-200..+200], both on log­a­rith­mic scales. (This map­ping is there­fore linear.)

In the Bol Processor score, using mapped val­ues in _pitchbend() con­trols is pos­si­ble owing to a _pitchrange(200) instruc­tion in the begin­ning of the sequence.

The result­ing Csound score makes it clear that pitch­bend is meant to vary con­tin­u­ous­ly over each Csound event : 0 to 24.997, 24.997 to 49.994 etc. Csound will fur­ther inter­po­late val­ues using its GEN 07 (lin­ear inter­po­la­tion) gen­er­a­tor.

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

i2 0.000 0.125 9.00 0.000 24.997 90.000 90.000 0.000 0.000 0.000 ; C5
i2 0.125 0.125 9.02 24.997 49.994 62.000 62.000 0.000 0.000 0.000 ; D5
i2 0.250 0.125 9.04 49.994 74.991 90.000 90.000 0.000 0.000 0.000 ; E5
i2 0.375 0.125 9.05 74.991 99.988 90.000 90.000 0.000 0.000 0.000 ; F5

Volume con­trol is pos­si­ble on instru­ments 1 and 2, yet not on instru­ment 3. Therefore its effect will be applied only to par­tic­u­lar events of sound-object “a”:

_volumecont _volume(30) a _volume(127)

i1 0.000 0.250 4.05 30.000 54.250 0.000 0.000 0.000 0.000 ; F0
i1 0.000 0.250 4.05 30.000 54.250 0.000 0.000 0.000 0.000 ; F0
i2 0.750 0.250 5.05 0.000 0.000 102.750 127.000 0.000 0.000 0.000 ; F1
i3 0.750 0.100 643.50 1.000 ; D#5

Csound score of sound-object “d”

In the fol­low­ing exam­ple, a con­tin­u­ous pitch­bend cor­rec­tion can­not be applied because instru­ment 5, called by “d”, does not have a pitch­bend para­me­ter. However, the +100 cents val­ue will be applied to the pitch para­me­ter itself.

The Csound score of sound-object “d” is lim­it­ed to 1 note at 440 Hz (with ref­er­ence to instru­ment 5). This note had been labelled ‘A4’ on the pro­to­type, but we should remem­ber that with a dia­pa­son of 435 Hz it will be a lit­tle high­er than ‘A4’. The raise is 1200 * log2(440/435) = 24 cents. Therefore, in the per­for­mance it will be set to 124 cents above 435 Hz, yield­ing 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 fol­low­ing exam­ple, a con­ti­nous pitch­bend cor­rec­tion results in var­i­ous adjust­ments of pitch­ben­der para­me­ters on the instru­ments called by sound-objects “a”, “b” and “c”. Simple notes ‘C4’ and ‘D4’ call instru­ment 1 because it is the one assigned to the (default) chan­nel 1. Volume is also adjust­ed continuously.

Note that we also apply neg­a­tive val­ues to the pitch­bend para­me­ter, expect­ing that the Csound orches­tra will do the extrapolation.

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

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#5
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 ; A4
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
i2 4.375 0.125 9.05 94.488 99.988 122.150 127.000 0.000 0.000 0.000 ; F5

Settings of the “blurb” parameter

Let us check an arbi­trary para­me­ter “burb” affect­ing argu­ments 9, 10 and 11 of instru­ment 2.

This para­me­ter is designed as addi­tive with respect to its com­bi­na­tions. The default val­ue is ‘0’.

In sound-object “e”, the third event ‘D3’ is required to set ‘blurb’ to start val­ue 10 and to end val­ue 30.

Csound score of sound-object “e”

These val­ues are added to the ones inter­po­lat­ed over the con­tin­u­ous ‘blurb’ vari­a­tion: 25.6 + (100 - 25.6) * 0.5 = 62.8 and 100 at dates 0.5 and 1 sec. This yields a start val­ue of 62.8 + 10 = 72.8 and an end val­ue 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 vari­a­tion of “blurb” gets more com­plex, Bol Processor will han­dle it
via func­tion 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 ini­tial val­ues on argu­ments 9 and 10. These val­ues are added to the ones deter­mined by vari­a­tions of the “blurb” para­me­ter, there­by yield­ing 40 for argu­ment 9 (the start val­ue of “blurb”) and 70 for argu­ment 10 (the end val­ue). The same com­pu­ta­tion is applied to its attached table f103. Consequently, the first and last val­ues of a func­tion table always reflect the start and end val­ues of the para­me­ter. This allows Csound instru­ments to oper­ate in a con­sis­tent man­ner, either inter­po­lat­ing start and end val­ues or pick­ing up (and inter­po­lat­ing) val­ues in the attached func­tion table.

The “oops” para­me­ter in instru­ment 6

Bol Processor com­bines Csound para­me­ters either addi­tive­ly or mul­ti­plica­tive­ly. For pre­de­fined para­me­ters mapped to MIDI the com­bi­na­tion mode is pre­set: all para­me­ters, except vol­ume, are com­bined addi­tive­ly. For addi­tion­al (non-MIDI) para­me­ters, the com­pos­er may decide on both the default val­ue and the com­bi­na­tion mode.

For instance, instru­ment 6 deals with a “oops” para­me­ter com­bin­ing mul­ti­plica­tive­ly. Sound-object “f” con­tains calls to this instru­ment with val­ues of “oops” that are not the default ones.

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

Parameter “oops” varies from 0 to 4 over 1500 ms. At the onsets of ‘D3’ and ‘E3’ its val­ues are 4 * (500 / 1500) = 1.33 and 4 * (1000 / 1500) = 2.66 respectively.

The start val­ue of “oops” in ‘C3’ is 0 * 0.5 = 0, and its end val­ue 1.5 * 1.33 = 2 as shown on the score.

The start val­ue for ‘D3’ will be O, and for ‘E3’ it will be 0.25 * 2.66 = 0.665. The val­ue at the end of D3 is 4.7 * 2.66 = 12.5. At the end of D3 the val­ue is 2.5 * 4 = 10.


These exam­ples had been designed to check all fea­tures of the Csound inter­face dur­ing its imple­men­ta­tion in Bol Processor. We expect more to come as both envi­ron­ments keep on explor­ing new con­cepts and build­ing tools for musicians.

We apol­o­gize for a yet-to-exist cor­pus of real musi­cal pieces con­struct­ed with Bol Processor and Csound. A first exam­ple of high musi­cal qual­i­ty has been com­posed in 1996 : read and lis­ten to Sarasvati vina!

Leave a Reply

Your email address will not be published. Required fields are marked *