Sarasvati vina

Sarasvati vīna. Source: Wikipedia

The fol­low­ing is an exam­ple of suc­cess­ful com­bi­ina­tion of Bol Processor and Csound. Both music cre­ation soft­ware pack­ages are still in devel­op­ment after four decades… Csound was orig­i­nal­ly writ­ten by Barry Vercoe at MIT in 1985, while Bol Processor dates back to 1981.

Short musi­cal phras­es were com­posed in 1995 by Srikumar Karaikudi Subramanian, an accom­plished prac­ti­tion­er of Carnatic music with deep under­stand­ing of math­e­mat­ics and physics — read his blog, PhD the­sis (2013) and list of patents.

Listen to the result:

"Pallavi" of song "Maayaatiita Svaruupini, Nannu brovave" in raga "maya­maalava­gaula". (The fade­out is post-produced.)

The mak­ing of this exam­ple requires a 33-millisecond wave­form sam­ple of Sarasvati vīna (vina-wave-table.aif) and a gram­mar (-gr.vina3) asso­ci­at­ed with a Csound instru­ment descrip­tion (-cs.Vina). All this is han­dled by the Bol Processor in both BP2 and BP3 ver­sions. This process pro­duces a Csound score which Csound con­verts into a sound file using a Csound orches­tra file (new-vina.orc).

The demo was ini­tial­ly devel­oped on Bol Processor BP2, the stand­alone appli­ca­tion still avail­able for Mac com­put­ers. In October 2020, it was repeat­ed on BP3, the multi-platform ver­sion, to check the valid­i­ty of Csound pro­ce­dures in the new environment.

The grammar

The gram­mar "-gr.vina3" is avail­able with all the nec­es­sary ingre­di­ents in the exam­ple set bp3-ctests-main.zip shared on GitHub. Follow the instruc­tions on the Bol Processor ‘BP3’ and its PHP inter­face page to install BP3 and learn its basic oper­a­tion. Download and install Csound as instructed.

The gram­mar "-gr.vina3" is shown below.

-se.Vina3
-cs.Vina
-to.Vina

// "Pallavi" of song "Maayaatiita Svaruupini, Nannu brovave" in raga "maya­maalava­gaula"
// scale - C, C#, E, F, G , G#, B
// Note phrase vari­a­tions giv­en.

// Terms:
// Spuritam - Quick (dis­crete) two note suc­ces­sion.
// Taalam - Measure of time (played on vina using the 3 sym­pa­thet­ic strings tuned to C-G-C).
// Gamaka - Smooth motion between two pitch­es (usu­al­ly pull of string).
// Pallavi - Theme of com­po­si­tion

ORD

gram#1[1] S --> _ins(Vina) _scale(just intonation,0) {Taalam4 Taalam4, Pallavi Pallavi} Taalam

gram#1[2] Pallavi --> {Maa Yaa Tii • Ta {2, Sva Ruu Pi}•{2, Ni} {1, Nan Nu}• Bro {2, Va Ve}}
gram#1[3] Maa --> C3
gram#1[4] Yaa --> LongSpuritam C3 Slide1
gram#1[5] Tii --> {1, StartSlidePull C3 Slide1 _ _ Slide1 Pull0 _ Slide4 • Pull1 _ Pull0 •Pull0 Pull1 - StopSlidePull }
gram#1[6] Ta --> F3
gram#1[7] Sva --> {3, G3}
gram#1[9] Ruu --> {3, StartSlidePull G3 SlideBack2 _ SlideBack3 _ SlideBack2 _ SlideBack3 Pull0 _ Pull1 - StopSlidePull}
gram#1[10] Pi --> {2, F3}
gram#1[11] Ni --> G3
gram#1[12] Nan --> G3
gram#1[13] Nu --> {1, StartPull Pull1 G3 Pull0 _ Pull1 - StopPull}
gram#1[14] Bro --> {1, StartSlide F3 Slide2 _ _ _ StopSlide} /slideVa/
gram#1[15] Bro --> {1, GamakaHold F3 Pull2} /pullVa/
gram#1[16] /slideVa/ Va --> StartSlide G3 SlideBack2 StopSlide
gram#1[17] /pullVa/ Va --> StartPull Pull2 F3 Pull0 StopPull
gram#1[18] Ve --> {3, Ve1 Ve2 Ve3}
gram#1[19] Ve1 --> {5, GamakaOscil E3 Pull1}
gram#1[20] Ve2 --> StartSlide C#3 SlideBack1 _ StopSlide
gram#1[21] Ve3 --> StartPull B2 Pull1 StopPull

RND
gram#2[1] Taalam4 --> Taalam Taalam Taalam Taalam
gram#2[2] Taalam --> {3, C3, G3, C4}

SUB1

gram#3[1] LongSpuritam ?1 ?2 --> {1, StartSlide ?1 _ Slide0 _ ?2 }
gram#3[2] GamakaOscil ?1 ?2 --> {StartPull ?1 ?2 Pull0 _ ?2 _ Pull0 _ ?2 StopPull}
gram#3[3] GamakaHold ?1 ?2 --> {1, StartPull ?1 ?2 _ _ _ StopPull}

SUB1

gram#4[1] StartSlidePull --> StartSlide StartPull
gram#4[2] StopSlidePull --> StopSlide StopPull

SUB1

// Lowest lev­el struc­tures

gram#5[1] Pull0 --> _pitchbend(0)
gram#5[2] Pull1 --> _pitchbend(100)
gram#5[3] Pull2 --> _pitchbend(200)

gram#5[4] Slide0 --> _value(slide, 0)
gram#5[5] SlideBack1 --> _value(slide, -101)
gram#5[6] SlideBack2 --> _value(slide, -201)
gram#5[7] SlideBack3 --> _value(slide, -301)
gram#5[8] Slide1 --> _value(slide, 101)
gram#5[9] Slide2 --> _value(slide, 201)
gram#5[10] Slide4 --> _value(slide, 401)

gram#5[11] StartSlide --> _cont(slide) _value(slide, 0)
gram#5[12] StopSlide --> _fixed(slide)
gram#5[13] StartPull --> _pitchcont _pitchrange(500) _pitchbend(0)
gram#5[14] StopPull --> _pitchfixed

This gram­mar is exem­plary for its use of vari­ables that rep­re­sent "musi­cal ges­tures" before their sound rep­re­sen­ta­tion. For exam­ple, "Pull0", "Pull1" and "Pulll2" are dif­fer­ent ways of pulling the string to raise its pitch. This is reflect­ed by chang­ing the val­ue of a pitch­ben­der, which is a MIDI stan­dard and has been repro­duced in the Csound orchestra.

Another ges­ture is named "slide", which is the move­ment from one fret to the next one. It also affects the fre­quen­cy of the note, but in a dis­con­tin­u­ous way, because the move­ment is a rapid change.

A more sophis­ti­cat­ed mod­el might include the strength of the pluck­ing of a note, which could be mapped to a para­me­ter sim­i­lar to the veloc­i­ty para­me­ter in MIDI.

The Csound score

Once the gram­mar is open in the BP3/PHP inter­face envi­ron­ment, click­ing on "Produce item(s)" will (by default) cre­ate a Csound score named "vina3.sco", as shown below.

; Csound score
f1 0 256 1 "vina-wave-table.aiff" 0 4 0

t 0.000 60.000
i1 0.000 1.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
f101 1.000 512 -7 0.000 256 -101.000 128 101.000 128 101.000
i1 1.000 1.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 101.000 101.000 ; C3
f102 2.000 256 -7 0.000 76 0.000 25 100.000 51 0.000 51 0.000 53 100.000
f103 2.000 256 -7 0.000 25 101.000 51 101.000 25 401.000 155 0.000

i1 2.000 0.833 7.00 90.000 90.000 0.000 0.000 100.000 102.000 0.000 0.000 103.000 ; C3
i1 0.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 0.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 0.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
i1 3.000 1.000 7.05 90.000 90.000 0.000 0.000 0.000 0.000 401.000 401.000 0.000 ; F3
i1 4.000 0.750 7.07 90.000 90.000 0.000 0.000 0.000 0.000 401.000 401.000 0.000 ; G3
f104 4.750 1024 -7 0.000 877 0.000 147 100.000
f105 4.750 1024 -7 0.000 146 -201.000 146 -301.000 146 -201.000 438 -301.000 148 0.000
i1 4.750 0.656 7.07 90.000 90.000 0.000 0.000 100.000 104.000 0.000 0.000 105.000 ; G3
i1 3.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 3.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 3.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
i1 5.500 0.500 7.05 90.000 90.000 0.000 0.000 0.000 0.000 -345.444 -345.444 0.000 ; F3
i1 6.000 2.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 -345.444 -345.444 0.000 ; G3
i1 8.000 0.500 7.07 90.000 90.000 0.000 0.000 0.000 0.000 -345.444 -345.444 0.000 ; G3
f106 8.500 256 -7 100.000 128 0.000 128 100.000
i1 8.500 0.333 7.07 90.000 90.000 0.000 100.000 100.000 106.000 -345.444 -345.444 0.000 ; G3
i1 6.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 6.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 6.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
f107 9.000 512 -7 0.000 128 201.000 384 201.000
i1 9.000 1.000 7.05 90.000 90.000 0.000 0.000 0.000 0.000 0.000 201.000 107.000 ; F3
f108 10.000 1024 -7 0.000 256 -201.000 768 -201.000
i1 10.000 0.500 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 -201.000 108.000 ; G3
f109 10.500 1024 -7 0.000 204 100.000 204 0.000 204 100.000 204 0.000 208 100.000
i1 10.500 0.937 7.04 90.000 90.000 0.000 0.000 100.000 109.000 -201.000 -201.000 0.000 ; E3
f110 11.437 512 -7 0.000 256 -101.000 256 0.000
i1 11.437 0.375 7.01 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 110.000 ; C#3
i1 9.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 9.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 9.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
i1 11.812 0.188 6.11 90.000 90.000 0.000 0.000 33.333 0.000 -101.000 -101.000 0.000 ; B2
i1 12.000 1.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 -101.000 -101.000 0.000 ; C3
f111 13.000 512 -7 0.000 256 -101.000 128 101.000 128 101.000
i1 13.000 1.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 101.000 111.000 ; C3
f112 14.000 256 -7 0.000 76 0.000 25 100.000 51 0.000 51 0.000 53 100.000
f113 14.000 256 -7 0.000 25 101.000 51 101.000 25 401.000 155 0.000

i1 14.000 0.833 7.00 90.000 90.000 0.000 0.000 100.000 112.000 0.000 0.000 113.000 ; C3
i1 12.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 12.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 12.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
i1 15.000 1.000 7.05 90.000 90.000 0.000 0.000 0.000 0.000 401.000 401.000 0.000 ; F3
i1 16.000 0.750 7.07 90.000 90.000 0.000 0.000 0.000 0.000 401.000 401.000 0.000 ; G3
f114 16.750 512 -7 0.000 472 0.000 40 100.000
f115 16.750 512 -7 0.000 236 -201.000 236 -301.000 40 0.000

i1 16.750 0.468 7.07 90.000 90.000 0.000 0.000 100.000 114.000 0.000 0.000 115.000 ; G3
i1 15.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 15.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 15.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
i1 17.500 0.500 7.05 90.000 90.000 0.000 0.000 0.000 0.000 -351.000 -351.000 0.000 ; F3
i1 18.000 2.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 -351.000 -351.000 0.000 ; G3
i1 20.000 0.500 7.07 90.000 90.000 0.000 0.000 0.000 0.000 -351.000 -351.000 0.000 ; G3
f116 20.500 256 -7 100.000 128 0.000 128 100.000
i1 20.500 0.333 7.07 90.000 90.000 0.000 100.000 100.000 116.000 -351.000 -351.000 0.000 ; G3
i1 18.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 18.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 18.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
f117 21.000 512 -7 0.000 128 201.000 384 201.000
i1 21.000 1.000 7.05 90.000 90.000 0.000 0.000 0.000 0.000 0.000 201.000 117.000 ; F3
f118 22.000 1024 -7 200.000 256 0.000 768 0.000
i1 22.000 0.500 7.05 90.000 90.000 0.000 200.000 0.000 118.000 0.000 0.000 0.000 ; F3
f119 22.500 1024 -7 0.000 204 100.000 204 0.000 204 100.000 204 0.000 208 100.000
i1 22.500 0.937 7.04 90.000 90.000 0.000 0.000 100.000 119.000 0.000 0.000 0.000 ; E3
f120 23.437 512 -7 0.000 256 -101.000 256 0.000
i1 23.437 0.375 7.01 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 120.000 ; C#3
i1 21.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 21.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 21.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
i1 23.812 0.188 6.11 90.000 90.000 0.000 0.000 33.333 0.000 -101.000 -101.000 0.000 ; B2
i1 24.000 3.000 7.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C3
i1 24.000 3.000 7.07 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; G3
i1 24.000 3.000 8.00 90.000 90.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ; C4
s
e


Settings of "slide" in "vina"

Note that the first line of this score — table "f1" — con­tains the link to the sam­pled wave­form "vina-wave-table.aiff" and the Csound orches­tra file "new-vina.orc" locat­ed in the same fold­er. The val­ue "1" in the fourth argu­ment indi­cates that data from a sound file will be trans­ferred into a func­tion table (see doc­u­men­ta­tion).

Lines start­ing with "i1" are note instruc­tions sub­mit­ted to the instru­ment "vina" to pro­duce notes 'C3', 'G3', 'F4' etc. The sec­ond and third argu­ments are the start time and dura­tion respec­tive­ly (see doc­u­men­ta­tion). The fourth argu­ment is the pitch, expressed as "octave.note": for exam­ple, "7.05" means the 7th note of octave 7, which is F3. The pitch could also be giv­en in Herz with respect to 'A4' = 440Hz — see Csound tun­ing in BP3.

Instructions "f102", "f103" etc. describe tables used for the inter­po­la­tion of pitch­bend and "slide" para­me­ters asso­ci­at­ed with the "vina" instru­ment. In the "slide" para­me­ter set­tings, the table index is the 13th argu­ment. In fact, the 13th para­me­ter of the "i1" instruc­tions con­tains "101", "103" etc. In each of these tables, the fourth argu­ment indi­cates the GEN rou­tine that Csound will use for its inter­po­la­tion. The val­ue "-7" means "GENO7" (lin­ear inter­po­la­tion) with no post-normalization (see doc­u­men­ta­tion).

Pitchbender set­tings of instru­ment "vina"

Instructions "f102", "f104" etc. are tables for inter­po­lat­ing pitch­ben­der val­ues. These are ref­er­enced in the 10th argu­ment of "i1" events, as shown in the pic­ture. We see that the range of MIDI val­ues [0 .. 16383] is mapped to the [-500 .. +500] inter­val used by the Csound instru­ment, both being log­a­rith­mic scales. The cen­tral map­ping of 8191.50 to 0 is used to con­struct this inter­po­la­tion with a qua­drat­ic regres­sion. See the Csound argu­ment map­ping page for a detailed explanation.

For exam­ple, in this event:

i1 4.750 0.656 7.07 90.000 90.000 0.000 0.000 100.000 104.000 0.000 0.000 105.000 ; G3

table "f104" (10th argu­ment) is invoked to inter­po­late pitch­bend val­ues between 0.000 and 100.000 (the 8th and 9th argu­ments). In event:

i1 21.000 1.000 7.05 90.000 90.000 0.000 0.000 0.000 0.000 0.000 201.000 117.000 ; F3

table "f117" (13th argu­ment) is used to inter­po­late the "slide" para­me­ter between 0.000 and 201.000 (the 11th and 13th argu­ments). However, in the orches­tra file "new-vina.orc", this para­me­ter is not treat­ed as con­tin­u­ous because it rep­re­sents a quick move from one fret to the next. Therefore, the _cont(slide) instruc­tion is irrel­e­vant for this ver­sion of the gram­mar. It could be delet­ed or replaced by _step(slide).

Making the sound file

Open a Unix con­sole and go to the fold­er con­tain­ing "vina3.sco" and "new-vina.orc".

Type :

csound -o Vina3.aif new-vina.orc out.sco

Running Csound on a con­sole: the ter­mi­na­tion of a suc­cess­ful process

If the oper­a­tion is suc­cess­ful — as con­firmed by mes­sages on the con­sole — the desired sound file "Vina3.aif" has been created.

WAV for­mat, 24-bit res­o­lu­tion etc. are also avail­able with Csound. Just type "csound" to see some options, or "csound --help" to see the full list.

By default, Csound dis­plays mes­sages that mim­ic the graph­i­cal rep­re­sen­ta­tion of all tables used in the score. This option can be turned off.

This whole process of con­vert­ing a Csound score into a sound file has been made auto­mat­ic on the Bol Processor BP3 inter­face. If Csound is installed and respond­ing, it will be called to do the con­ver­sion. The sound file it is instruct­ed to cre­ate is in WAV for­mat, because this for­mat (unlike AIFF) is recog­nised by the 

Microtonal intonation

An impor­tant fea­ture of this exam­ple is the choice of a micro­ton­al scale to replace the equal tem­pered 12 tone scale com­mon­ly used on elec­tron­ic or mod­ern key­board instru­ments. The scale is defined in the tonal resource "-to.Vina" and is set by the instruc­tion _scale(just intonation,0).

In BP3 it is pos­si­ble to define micro­ton­al scales and use them either in the MIDI or the Csound envi­ron­ment. (Read the MIDI micro­tonal­i­ty page.) Csound uses func­tion tables, which are auto­mat­i­cal­ly super­im­posed on the Csound score. For exam­ple, a "just into­na­tion" scale can be defined as follows:

f2 0 128 -51 12 2 264 60 1 1.066 1.125 1.2 1.25 1.333 1.42 1.5 1.6 1.666 1.777 1.875

Numbers in red indi­cate fre­quen­cy ratios. For exam­ple, the size of the fifth (C - G) is 1.333 = 4/3, which makes it "per­fect". Listen to both inter­pre­ta­tions in just into­na­tion and equal temperament:

Just into­na­tion
Equal-tempered inter­vals

Discussion

This detailed inter­pre­ta­tion of a musi­cal phrase in Carnatic music was just an ear­ly demon­stra­tion of Bol Processor + Csound fea­tures. In 2013, Srikumar Karaikudi Subramanian sub­mit­ted his PhD the­sis to the National University of Singapore enti­tled Modeling Gamakās of Carnatic Music as a Synthesizer for Sparse Prescriptive Notation. He went on to devel­op the Pāṭāntarā sys­tem of high-quality Carnatic music notation.

Apart from using a sam­ple of the real Sarasvati vīna sound to cre­ate the musi­cal piece, is it worth using the Csound envi­ron­ment instead of MIDI on the Bol Processor? After all, any MIDI sam­pler could han­dle the wave­form and pro­duce the same sound as Csound…

We do not have a MIDI sam­pler to repro­duce the sound of a Sarasvati vīna, but "-gr.vina3" can be played on a MIDI device, either in real time or via a MIDI file. The fol­low­ing is a ren­der­ing on PianoTeq:

(Dreadful) ren­der­ing of -gr.vina3 on a MIDI device. Sorry Srikumar! 😀

Listening to this ver­sion, it is clear that the pitch­bend instruc­tions have been par­tial­ly inter­pret­ed, while the "slide" para­me­ter spe­cif­ic to the "vina" Csound instru­ment has been ignored. This con­firms that Csound offers the pos­si­bil­i­ty of enrich­ing the descrip­tion of any piece of music with per­for­mance para­me­ters that do not belong to the stan­dard MIDI cat­e­gories: pitch­bend, mod­u­la­tion, pres­sure, etc.

We have doc­u­ment­ed all the fea­tures of the Csound imple­men­ta­tion on the Csound check­up and Csound objects page, show­ing exam­ples that can be checked with BP3. More details on the han­dling of con­tin­u­ous para­me­ters can be found on the page Continuous para­me­ters in Csound scores.

A call for participation

We invite musi­cians who are famil­iar with Csound to cre­ate exam­ples of the full use of Csound on Bol Processor. This will increase our con­fi­dence that none of the imple­ment­ed Csound fea­tures are incom­plete or erroneous.

 The devel­op­ment of Csound beyond our ini­tial work on the sub­ject (in 1995) is expect­ed to stim­u­late new ideas for more advanced inte­gra­tion in future ver­sions of BP3.

Leave a Reply

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