Showing posts with label spec. Show all posts
Showing posts with label spec. Show all posts

Wednesday, 23 March 2022

Spec for translating Unicode to MusicXML part 3

The remaining ornaments (accents above the text) are a series of notes relative to the reciting note. 

In principle any melisma could be coded. Those for the Haïk-Vantoura deciphering key never require more than triplets and eighth notes.

Slur numbers cycling from '1' to '5' for this single line of music conform to the MusicXML spec.

Note that ornaments do not have any absolute pitches. They are all relative to the current reciting note.
Examples are in the music support files here. Also there are many of Haïk-Vantoura's original documents and books available here. There are other parts to my implementation defined several years ago, e.g. mode here

This is a difficult process because the ornaments are varied in names, hard to remember in Unicode, and not easily identifiable in the MusicXML. Triplets can be identified by searching for <time-modification>. Other eighth notes by <duration>3. Note that the note class is not a fixed duration when performing. All the performances in their raw form are recitative - though there will be strong rhythmic identities depending on the syllable pulses or narrative word rhythms in the language itself.

There are additional issues for an automated transcription app in the data that may be provided in a copy and paste from various sites: e.g. the coding sequence of vowels and cantillation, (these can be done wrongly) and various characters that are irrelevant to the music that may need to be replaced before parsing. It is possible to identify and display ketiv and qere but not really useful for the music. I coded this but eventually suppressed the feature.

Input requires at minimum, a line of text in Hebrew, a mode (can be determined from the book, one of the 21, or one of the 3, and for Job only, chapter, and for the narrator, verse#.) The mode can default or can be specified in some form. These could be handled with user settings.

Ornament Full name

 ֙

qad qadma
<note><pitch><step>[reciting note]</step>
<octave>[reciting note]</octave></pitch>
<duration>3</duration>
<voice>1</voice>
<type>eighth</type>
<notations><slur type="start" number="1"/></notations>
<lyric number="1"><syllabic>[begin|middle|end]</syllabic><text>him</text></lyric>
</note>
<note><pitch><step>[reciting note + 1]</step>
<octave>[of reciting note + 1]</octave></pitch>
<duration>3</duration>
<voice>1</voice>
<type>eighth</type>
<notations><slur type="stop" number="1"/></notations>
</note>

֨ 

pas pashta
<note><pitch><step>[reciting note] + 1</step>
<octave>[of reciting note + 1]</octave></pitch>
<duration>3</duration>
<voice>1</voice>
<type>eighth</type>
<notations><slur type="start" number="1"/></notations>
<lyric number="1"><syllabic>[begin|middle|end]</syllabic><text>[text]</text></lyric>
</note>
<note><pitch><step>[reciting note]</step>
<octave>[reciting note]</octave></pitch>
<duration>3</duration>
<voice>1</voice>
<type>eighth</type>
<notations><slur type="stop" number="1"/></notations>
</note>

֜ 

ger geresh
<note><pitch><step>[reciting note]</step>
<octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="start" number="4"/></notations>
<lyric number="1"><syllabic>[begin|middle|end]</syllabic>
<text>[text]</text></lyric>
</note>
<note><pitch><step>[reciting note]+2</step>
<octave>5</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="stop" number="4"/></notations>
</note>

֝֗ 

ger-rev revia-mugrash
Example from psalm 1 measure 10
<direction placement="above"><direction-type>
<words font-size="12"> &#1500;&#1461;&#1437;&#1510;&#1460;&#1431;&#1497;&#1501;
</words></direction-type></direction>
<note><pitch><step>A</step>
<octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="start" number="4"/></notations>
<lyric number="1"><syllabic>begin</syllabic>
<text>lei</text></lyric>
</note>
<note><pitch><step>F</step>
<alter>1</alter><octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="stop" number="4"/></notations>
</note>
<note><pitch><step>E</step>
<octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="start" number="5"/></notations>
<lyric number="1"><syllabic>end</syllabic>
<text>tsim</text></lyric>
</note>
<note><pitch><step>F</step>
<alter>1</alter><octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="stop" number="5"/></notations>
</note> 

 ֗

rev revia
Example from Genesis 2:5 (prose -0-1; in poetry -1-0)
<note><pitch><step>B</step>
<octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="start" number="5"/></notations>
<lyric number="1"><syllabic>end</syllabic><text>deh</text></lyric>
</note>
<note><pitch><step>A</step>
<octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="stop" number="5"/></notations>
</note>   

֞ 

tar tarsin
+2+0+2 example of a triplet (Gen 2:8) - reciting note is e - all other triplets are similarly coded.
Given the mode, e.g. 'C4 D4 E4 F4 G4#A4 B4 C5 D5 E5 F5 '
ascend and descend the scale to get note and octave with a loop.
<note><pitch><step>G</step>
<alter>1</alter><octave>4</octave></pitch><duration>2</duration>
<voice>1</voice><type>eighth</type>
<time-modification><actual-notes>3</actual-notes>
<normal-notes>2</normal-notes></time-modification>
<notations><slur type="start" number="4"/>
<tuplet number="4" type = "start" bracket="no" show-number="none" /></notations>
<lyric number="1"><syllabic>end</syllabic><text>ta</text></lyric>
</note>

<note><pitch><step>E</step>
<octave>4</octave></pitch><duration>2</duration>
<voice>1</voice><type>eighth</type>
<time-modification><actual-notes>3</actual-notes>
<normal-notes>2</normal-notes></time-modification>
</note>

<note><pitch><step>G</step>
<alter>1</alter><octave>4</octave></pitch><duration>2</duration>
<voice>1</voice><type>eighth</type>
<time-modification><actual-notes>3</actual-notes>
<normal-notes>2</normal-notes></time-modification>
<notations><slur type="stop" number="4"/>
<tuplet number="4" type = "stop" bracket="no" show-number="none" /></notations>
</note>

֡ 

paz pazer
+2+1

 ֔

z-q zaqef-qatan
-1

 ֕

z-g zaqef-gadol
-1-2

֒ 

seg segol
-1-0-1 

֘ 

zar zarqa, tsinnor
-1+1-0 - indicates that the ornament resolves to the original reciting note

 ֩

t-q telisha qetana
+1+2+3

 ֠

t-g telisha gedolah
+3+2+1

 ֟

qar qarne farah
+1+2+3+3+2+1 pair of triplets all on the same syllable

 ֓

shl shalshalet
-3-2-1

 ֬

ill illuy
+4

 ֫

ole ole
+3+0 poetry only. Ole-veyored is a combination of over and under accents - as cadence
Two accents in sequence - example from Psalm 1 measure 4-5 רְשָׁ֫עִ֥ים  
<measure number="4">
...
<direction placement="above"><direction-type>
<words font-size="12"> &#1512;&#1456;&#1513;&#1473;&#1464;&#1451;&#1506;&#1460;&#1445;&#1497;&#1501;
</words></direction-type></direction>
<note><pitch><step>D</step><alter>1</alter><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice>
<type>quarter</type>
<lyric number="1"><syllabic>begin</syllabic><text>re</text></lyric>
</note>
<note><pitch><step>G</step>
<octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="start" number="3"/></notations>
<lyric number="1"><syllabic>middle</syllabic><text>sha</text></lyric>
</note>
<note><pitch><step>D</step>
<alter>1</alter><octave>4</octave></pitch><duration>3</duration>
<voice>1</voice><type>eighth</type>
<notations><slur type="stop" number="3"/></notations>
</note>
<barline location="right">
<bar-style>dotted</bar-style>
</barline>
</measure>
<measure number="5">
<note><pitch><step>F</step><alter>1</alter><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice>
<type>quarter</type>
<lyric number="1"><syllabic>end</syllabic><text>im</text></lyric>
</note>

Tuesday, 22 March 2022

Spec for translating Unicode to MusicXML part 2

 Now it's time to deal with each of the te'amim and see their xml output. We have seen 4 examples in the first post here

The silluq translates to this (All the Unicode is here.) The silluq is the pattern for all the changes in reciting note.

<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>6</duration>
<voice>1</voice>
<type>quarter</type>
<lyric number="1">
<syllabic>[begin|middle|end]</syllabic>
<text>[syllable of text here]</text>
</lyric>
</note>

The only problem with the silluq is that Unicode does not distinguish silluq from gaya or metheg. These last two, if you can identify them, should be ignored. Because they were invented by the copying process over the last 1000 years as a pronunciation guide for some initial closed syllables. They are not music. This is the only sign that is subject to fuzzy logic. Even Delitzsch says that no one knows the rules for metheg. Lambdin more or less agrees. Gesenius is fantastically complex. But none of these Hebrew teachers was a musician who knew what the signs below the text represented - so they didn't know what they were looking at. The Unicode designers followed the confusion.

The Accents of the Hebrew Bible relating to the Music
Below the text
Recitation Accent name XML output where different from above
c

 ֧

darga
<step>C</step><octave>4</octave>
d

 ֢ ֛

galgal (prose), tevir (poetry)
<step>D</step><octave>4</octave>
e

 ֽ

silluq see above for the pattern for all signs below the text
f

֥ 

merkha
<step>F</step><octave>4</octave>
g

 ֭

tifha, (d’khi)
<step>G</step><octave>4</octave>
A

 ֑

atnah
<step>A</step><octave>5</octave>
B

֣ 

munah
<step>E</step><octave>5</octave>
C

 ֚

mahpakh, (yetiv)
<step>C</step><octave>5</octave>
dm

 ֦

double merkha, kefulah == merkha above
The ornaments above the text require that the program 'follow' the music and shape the ornament. A good example is the qadma - I will say more about the parameters in the next post.

 ֙


<note><pitch><step>[reciting note]</step>
<octave>[reciting note]</octave></pitch>
<duration>3</duration>
<voice>1</voice>
<type>eighth</type>
<notations><slur type="start" number="1"/></notations>
<lyric number="1"><syllabic>[begin|middle|end]</syllabic>
<text>him</text></lyric>
</note>
<note><pitch><step>[reciting note + 1]</step>
<octave>[of reciting note + 1]</octave></pitch>
<duration>3</duration>
<voice>1</voice>
<type>eighth</type>
<notations><slur type="stop" number="1"/></notations>
</note>
The resulting music is like this:
The third syllable with qadma

Monday, 21 March 2022

A spec for transcribing Unicode to MusicXML

 How easy can I make this?

I will work from output back to input. Here's the required output for the first four notes of Genesis.

This is two transcriptions in one, because we have to get the syllable with the right note(s) - so we have to transcribe the rtl Hebrew to ltr Latin and interpret the vowels as we go. Yes there are melismas, but they are simple - never more than three notes relative to the current reciting note. The original spec for the deciphering key is here (translated from the original French). It is important to have this for examples of her resolution of ornaments when there is some ambiguity as to whether to return to the reciting note or not. (Her spec is unclear and her actual practice is varied). Performers also take liberty with the ornaments and modes since they are 'unspecified', i.e. subject to musical judgment based on the text and the melody - itself determined by the signs under the text. 

[Actually there are multiple transcriptions going on: Hebrew to pronounceable Latin characters that can be read by a singer (not a linguist), words broken up by syllable, and cantilation transcribed to MusicXML.]

Here's the output for the first few measures of Genesis 1:1 given this input:

בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים

The music is e g# B ^A. The opening e is defaulted since it is not specified. The default applies for each verse if and only if there is no accent above or below the text on the first syllable.
The tifha ֭  always sets the reciting note to the third note of the mode, in this case, g#.
The munah ֣ to the fifth, B. The atnah  ֑ to the fourth, A.

The accents under the text define the current reciting note. This is the missing clue in every other interpretation of the accents - also called te-amim, marks of taste, or cantilation marks, or hand-signals.

First the file definition :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1"><identification><encoding><supports element="accidental" type="no"/></encoding></identification> <defaults> -- see the full file at the link below for the hard coded defaults
- defining the paper size etc.

<credit
page="1"><credit-words default-x="595.238" default-y="1626.98" font-size="16" justify="center" valign="top">Genesis 1</credit-words> -- title is input
</credit><credit page="1">
<credit-words default-x="56.6893" default-y="1559.98" font-size="10" justify="left" valign="top">[Mode 1] -- mode is input
based on the work of Suzanne Haik-Vantoura </credit-words>
</credit>
<credit page="1"> <credit-words default-x="1133.79" default-y="1559.98" font-size="10" justify="right" valign="top">Transcription automated
http://meafar.blogspot.com</credit-words> </credit><credit page="1"><credit-words default-x="595.238" default-y="113.379" justify="center" valign="bottom">
source data www.tanach.us/Tanach.xml. Transcription software (v3.3) by Bob MacDonald via GX-LEAF (www.gx.ca). Victoria BC 2016.01.25
Range: C4 -E5 verses 31 measures 257 words 434 syllables 1025 max recitation 34 </credit-words>
</credit>

<part-list><score-part id="P1"><part-name/><score-instrument id="P1-I3"><instrument-name/></score-instrument></score-part></part-list>

<part id="P1">

The part is defined by measure. For every reciting-note there is a measure - The program must limit the size and extend the measure to two if the recitation is very long. I have found that a maximum of 24 beats in a bar works for all the Bible and in my music program (Musescore). There are only a few recitations of such length.

<measure number="1"> -- calculate measure number as the text is read
<attributes> <divisions>6</divisions> -- hard coded to allow for triplets & duplets
see (e.g.) https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/divisions/
<key><fifths>0</fifths> -- number of flats or sharps - this is calculated as follows: 
case when l_poetry = '1' and pl_mode = '2' then '4' 
     when pl_mode = '8' then '2' -- locrian - experimental
     when pl_mode = '3' then '4' 
     when l_poetry = '1' then '1' 
     when pl_mode = '5' or pl_mode = '6' then '0' 
     when pl_mode <> '1' then '1' 
     else '0' end 
l_poetry is '1' if the chapter is poetry (Psalms, Proverbs and most of the book of Job except chapters 1, 2, 42, and the narrator's verses), 
pl_mode is the input parameter stating the mode for the chapter. See this post for the mode scales.

<mode>major</mode></key> -- hard coded - irrelevant but probably needed for the XML
<clef><sign>G</sign><line>2</line></clef></attributes> -- all generated music is single line treble clef suitable for voice(s). The pitch is arbitrary and may be transposed for alto or bass. Generally speaking though, the range is limited e to E and the high D and E are rare.

Text - word by word - Hebrew
<direction placement="above">
<direction-type>
<words font-size="12">
1.1 &#1489;&#1468;&#1456;&#1512;&#1461;&#1488;&#1513;&#1473;&#1460;&#1430;&#1497;&#1514; 
</words></direction-type></direction>

Notes - syllable by syllable - for lyric 1 - split by syllabic begin-middle-end (determines hyphenation)
<note><pitch><step>E</step><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type> <lyric number="1"><syllabic>begin</syllabic><text>be</text></lyric>
</note>
<note><pitch><step>E</step><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type> <lyric
number="1"><syllabic>middle</syllabic><text>rei</text></lyric>
</note>
<barline
location="right">
<bar-style>dotted</bar-style>
</barline>
</measure>
<measure number="2">
<note><pitch><step>G</step><alter>1</alter><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type>
<lyric number="1"><syllabic>end</syllabic><text>shit</text></lyric>
</note>
<direction
placement="above"><direction-type>
<words font-size="12"> &#1489;&#1468;&#1464;&#1512;&#1464;&#1443;&#1488; </words></direction-type></direction>
<note><pitch><step>G</step><alter>1</alter><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type>
<lyric
number="1"><syllabic>begin</syllabic><text>ba</text></lyric>
</note>
<barline
location="right">
<bar-style>dotted</bar-style>
</barline>
</measure>
<measure number="3">
<note><pitch><step>B</step><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type>
<lyric
number="1"><syllabic>end</syllabic><text>ra</text></lyric>
</note>
<direction
placement="above"><direction-type>
<words font-size="12"> &#1488;&#1457;&#1500;&#1465;&#1492;&#1460;&#1425;&#1497;&#1501; </words></direction-type></direction>
<note><pitch><step>B</step><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type>
<lyric
number="1"><syllabic>begin</syllabic><text>e</text></lyric>
</note>
<note><pitch><step>B</step><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type>
<lyric
number="1"><syllabic>middle</syllabic><text>lo</text></lyric>
</note>
<barline
location="right">
<bar-style>dotted</bar-style>
</barline>
</measure>
<measure number="4">
<note><pitch><step>A</step><octave>4</octave>
</pitch><duration>6</duration><voice>1</voice><type>quarter</type> <notations><articulations><caesura
default-x="31" default-y="-10"/></articulations></notations>
<lyric number="1"><syllabic>end</syllabic><text>him</text></lyric>
</note>
<barline location="right">
<bar-style>dotted</bar-style>
</barline>
</measure>

Then keep going till the end of the section you are producing (verse or group of verses, or chapter etc).
Full score for Genesis 1 is here in MusicXML. (Indentation varies - whim of the programmer!)

This is the overall shape, though we have stopped in the middle of a verse at the cadence on the atnah.  And there are no ornaments in this verse. The measure may continue after the caesura and a rest <note><rest/><duration>6</duration><voice>1</voice>
<type>quarter</type>
</note>
 if there is no change in the reciting note.

After every verse is done:
<!--C4 -E5 verse 31 measures 257 words 434 syllables 1025 max recit 34-->
</part></score-partwise>
ends the score

And the result is this:
The music for the XML above