File Structure
The Hello World example used one instrument and one section. This example adds multiple instruments, structure annotations, performance directions, and section repeats.
Example XML
Section titled “Example XML”<?xml version="1.0" encoding="UTF-8"?><thai-score version="0.1"> <header> <title>Example Song</title> <composer>Example Composer</composer> <structure> <annotation>Example Comments</annotation> <direction> <chan value="1" /> <bpm>65</bpm> </direction> <annotation>บรรทัดที่ 1 มี 7 ห้อง</annotation> <section id="s1" number="1" name="ท่อน 1" repeat="2" /> <annotation>End of section 1 message</annotation> </structure> </header> <ensemble> <part id="P1"> <instrument-name>Ranat Ek</instrument-name> </part> <part id="P2"> <instrument-name>Ching</instrument-name> </part> </ensemble> <part-data id="P1"> <section-ref id="s1"> <line number="1"> <measure number="1"><note pitch="ด"/><note pitch="ร"/><note pitch="ม"/><note pitch="ร"/></measure> <measure number="2"><note pitch="ซ"/><note pitch="ม"/><note pitch="ร"/><note pitch="ด"/></measure> <measure number="3"><note pitch="ทฺ"/><note pitch="ด"/><note pitch="ร"/><note pitch="ลฺ"/></measure> <measure number="4"><note pitch="ทฺ"/><note pitch="ด"/><note pitch="ร"/><note pitch="ด"/></measure> <measure number="5"><note pitch="ร"/><note pitch="ม"/><note pitch="ฟ"/><note pitch="ซ"/></measure> <measure number="6"><note pitch="ล"/><note pitch="ซ"/><note pitch="ฟ"/><note pitch="ม"/></measure> <measure number="7"><note pitch="ร"/><note pitch="ม"/><note pitch="ฟ"/><note pitch="ซ"/></measure> </line> </section-ref> </part-data> <part-data id="P2"> <section-ref id="s1"> <annotation target="instrument">0 = ฉิ่ง / 1 = ฉับ</annotation> <line number="1"> <measure number="1"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> <measure number="2"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> <measure number="3"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> <measure number="4"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> <measure number="5"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> <measure number="6"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> <measure number="7"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> </line> </section-ref> </part-data></thai-score>Header
Section titled “Header”The <header> can include a <composer> alongside <title>:
<header> <title>Example Song</title> <composer>Example Composer</composer></header>Structure
Section titled “Structure”The <structure> element can contain several child types that describe the score layout:
<structure> <annotation>Example Comments</annotation> <direction> <chan value="1" /> <bpm>65</bpm> </direction> <annotation>บรรทัดที่ 1 มี 7 ห้อง</annotation> <section id="s1" number="1" name="ท่อน 1" repeat="2" /> <annotation>End of section 1 message</annotation></structure><annotation>: Free-form comments that can appear anywhere. Playback ignores them. The optionaltargetattribute specifies what the annotation refers to.<direction>: Performance directions. This example sets the ชั้น (<chan>) and tempo (<bpm>). ชั้น (chan) is the Thai rhythmic layer system.value="1"means ชั้นเดียว.<section>: A named section. Therepeatattribute indicates how many times it is played.
Multiple Instruments
Section titled “Multiple Instruments”The <ensemble> can list multiple parts:
<ensemble> <part id="P1"> <instrument-name>Ranat Ek</instrument-name> </part> <part id="P2"> <instrument-name>Ching</instrument-name> </part></ensemble>Each instrument gets its own <part-data> element with a matching id. Here, P1 is a Ranat Ek (ระนาดเอก, a Thai xylophone) and P2 is a Ching (ฉิ่ง, small cymbals).
Part Data
Section titled “Part Data”Each <part-data> links to a section through <section-ref>. The Ching part includes an annotation explaining its notation:
<part-data id="P2"> <section-ref id="s1"> <annotation target="instrument">0 = ฉิ่ง / 1 = ฉับ</annotation> <line number="1"> <measure number="1"><rest/><note pitch="0"/><rest/><note pitch="1"/></measure> ... </line> </section-ref></part-data>The target="instrument" attribute limits this comment to the instrument. It documents the Ching notation convention: 0 means ฉิ่ง (open) and 1 means ฉับ (closed).