Sarasvati vina

Sarasvati vīna. Source: Wikipedia

The fol­low­ing is an exam­ple of suc­cess­ful asso­ci­a­tion of Bol Processor with Csound. Both soft­ware pack­ages for music com­po­si­tion are still in devel­op­ment after almost 4 decades… Csound was orig­i­nal­ly writ­ten by Barry Vercoe at MIT in 1985, where­as Bol Processor dates back to 1981.

Short musi­cal phras­es have been com­posed in 1995 by Srikumar Karaikudi Subramanian, an accom­plished prac­ti­tion­er of Carnatic music with deep under­stand­ing of maths 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 mine.)

The man­u­fac­ture 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 these are han­dled by Bol Processor in both BP2 and BP3 ver­sions. This process pro­duces a Csound score which Csound con­verts to a sound file using a Csound orches­tra file (new-vina.orc).

The demo had been ini­tial­ly designed on Bol Processor BP2, the stand­alone appli­ca­tion still avail­able for Mac com­put­ers. In October 2020 it was reit­er­at­ed on BP3, the mul­ti­plat­form ver­sion under devel­op­ment, to check the valid­i­ty of Csound pro­ce­dures in the new environment.

The grammar

Grammar “-gr.vina3″ is avail­able with all required ingre­di­ents in the sam­ple set bp3-ctests-main.zip shared on GitHub. Follow instruc­tions on Bol Processor ‘BP3’ and its PHP inter­face to install BP3 and learn its basic oper­a­tion. Download and install Csound from its dis­tri­b­u­tion page.

Grammar “-gr.vina3″ is shown below.

-se.Vina3
-cs.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 --> {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 inter­est­ing for its usage of vari­ables rep­re­sent­ing “musi­cal ges­tures” ahead of their sound ren­der­ing. Thus, “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 stan­dard of MIDI and has been repro­duced in the Csound orchestra.

Another ges­ture is named “slide”, here mean­ing the move­ment of one fret to the next one. It also has an effect on the fre­quen­cy of the note, although in a dis­con­tin­u­ous man­ner because the move­ment is a rapid change.

A more sophis­ti­cat­ed mod­el could include the strength of pluck­ing a note which may be mapped to a para­me­ter resem­bling 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 “Produce item(s)” cre­ates (by default) a Csound score named “vina3.sco” 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 — tablef1″ — con­tains the link to the “vina-wave-table.aiff” sam­pled wave­form and the Csound orches­tra file “new-vina.orc” locat­ed in the same fold­er. Value “1” in the fourth argu­ment indi­cates that data is trans­fered from a sound­file into a func­tion table (see doc­u­men­ta­tion).

Lines start­ing with “i1″ are note state­ments sub­mit­ted to the “vina” instru­ment to pro­duce notes ‘C3’, ‘G3’, ‘F4’ etc. The sec­ond and third argu­ments are the start­ing 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 instance, “7.05” means the 7th note of octave 7, which is F3. Pitch could also be spec­i­fied in Herz with respect to ‘A4′ = 440Hz — see Csound tun­ing in BP3.

Statements “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 set­tings of the “slide” para­me­ter, the table index is the 13th argu­ment. In effect, the 13th para­me­ter of instruc­tions “i1” 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. Value “-7” means “GENO7″ (lin­ear inter­po­la­tion) with no post-normalization (read doc­u­men­ta­tion).

Pitchbender set­tings of instru­ment “vina”

Statements “f102″, “f104″ etc. are tables for the inter­po­la­tion of pitch­ben­der val­ues. These are referred in the 10th argu­ment of “i1″ events, as shown on the pic­ture. We see that the range of MIDI val­ues [0 .. 16383] is mapped to [-500 .. +500] 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 for con­struct­ing this inter­po­la­tion with a qua­drat­ic regres­sion. Read page Csound argu­ment map­ping 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 for inter­po­lat­ing 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 invoked to inter­po­late the “slide” para­me­ter between 0.000 and 201.000 (the 11th and 13th argu­ments). However, in the “new-vina.orc” orches­tra file, this para­me­ter is not treat­ed as con­tin­u­ous because it rep­re­sents a quick move from a fret to the next one. Therefore, instruc­tion _cont(slide) is irrel­e­vant to this ver­sion of the gram­mar. It could be delet­ed or replaced with _step(slide).

Making the sound file

Open a con­sole and reach 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. Type a plain “csound” to see a few options or “csound --help” to see the com­plete list.

By default, Csound dis­plays mes­sages imi­tat­ing the graph­ic ren­der­ing of all tables used in the score. This option can be disabled.

This whole process of con­vert­ing a Csound score to a sound file has been ren­dered auto­mat­ic on the inter­face of Bol Processor BP3. If Csound has been installed and is respon­sive, it is called to do the con­ver­sion. The sound file it is instruct­ed to cre­ate is in the WAV for­mat because this for­mat (unlike AIFF) is rec­og­nized by the <audio> tag in HTML5. Therefore, sound files cre­at­ed in this way are direct­ly acces­si­ble to lis­ten­ing on the inter­face’s page. 

Microtonal intonation

An impor­tant fea­ture of this exam­ple is the choice of a micro­ton­al scale in replace­ment of the equal-tempered 12-tone scale com­mon­ly used on elec­tron­ic or mod­ern key­board instru­ments. In BP3 it is pos­si­ble to define micro­ton­al scales using Csound func­tion tables which are auto­mat­i­cal­ly insert­ed on top of the Csound score. For instance, a “just into­na­tion” scale may 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 denote fre­quen­cy ratios. Thus, for instance, 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-tempered tunings:

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

Discussion

This detailed inter­pre­ta­tion of a musi­cal phrase in Carnatic music is just an ear­ly show of Bol Processor + Csound fea­tures. In 2013, Srikumar Karaikudi Subramanian sub­mit­ted his the­sis Modeling Gamakās of Carnatic Music as a Synthesizer for Sparse Prescriptive Notation to the National University of Singapore. He then devel­oped the Pāṭāntarā sys­tem of high qual­i­ty Carnatic music notation.

Apart from using a sam­ple of real Sarasvati vīna sound to cre­ate the musi­cal piece, is it worth opt­ing for the Csound envi­ron­ment in replace­ment of MIDI on the Bol Processor? After all, any MIDI sam­pler could han­dle the wave­form and ren­der 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 instruct­ed to pro­duce a MIDI file and play it on a MIDI device. 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 makes it clear that pitch­bend instruc­tions have been part­ly inter­pret­ed where­as the “slide” para­me­ter spe­cif­ic to the “vina” Csound instru­ment was ignored. This con­firms that Csound brings the pos­si­bil­i­ty of enhanc­ing the descrip­tion of any piece of music with per­for­mance para­me­ters that do not belong to stan­dard MIDI cat­e­gories: pitch­bend, mod­u­la­tion, pres­sure etc.

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

A call for participation

We invite musi­cians con­ver­sant with Csound to design exam­ples of the full usage of Csound on Bol Processor. This will increase our con­fi­dence that none of the imple­ment­ed Csound fea­tures is incom­plete or faulty.

A set of exam­ples expos­ing all pos­si­ble ways of con­trol­ling Csound para­me­ters in the Bol Processor envi­ron­ment is avail­able on this page.

 Development of Csound beyond our ini­tial work on the top­ic (in 1995) is expect­ed to trig­ger new ideas for a 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 *