From b8a0d85cac2c7cdf09d25efc449e3e20926adf69 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Sun, 11 Sep 2022 01:34:11 -0400 Subject: [PATCH 1/4] Add support for entering barlines. Keystrokes for single ('|') and double/end ('=') barlines which are rendered and saved in Humdrum (as single '=' and double '==', respectively). When exported into MEI (which naturally uses Humdrum functionality to convert to MEI), the double/end barline ('==') is encoded as 'form=end', the single one ('=') is not parsed into any attribute form (because Humdrum does not encode it into MEI, it is used in KERN for measures). Missing: parsing the MEI barlines correctly. --- .../staff-select/staff-select.component.ts | 7 ++- src/app/utils/MusicItem.ts | 48 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/app/input/staff-select/staff-select.component.ts b/src/app/input/staff-select/staff-select.component.ts index cb46e25..c6d082f 100644 --- a/src/app/input/staff-select/staff-select.component.ts +++ b/src/app/input/staff-select/staff-select.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, HostListener, ViewChild, ElementRef } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { PitchClass, NoteItem, RestItem, Accid, LigStatus, PlicaStatus, ColorStatus } from '../../utils/MusicItem'; +import { PitchClass, NoteItem, RestItem, Accid, LigStatus, PlicaStatus, ColorStatus, BarlineItem } from '../../utils/MusicItem'; import { StateService } from '../../state-service.service'; import { InputService } from '../input.service'; import { vrvToolkit } from '../../utils/verovio'; @@ -235,6 +235,11 @@ export class StaffSelectComponent implements OnInit { this.processColor(event.key); event.preventDefault(); break; + case '=': + case '|': + musicList.addBarline(event.key); + event.preventDefault(); + break; case 'r': case 'R': if (!musicList.hasOpenLigature()) { diff --git a/src/app/utils/MusicItem.ts b/src/app/utils/MusicItem.ts index 53f975a..418a5a1 100644 --- a/src/app/utils/MusicItem.ts +++ b/src/app/utils/MusicItem.ts @@ -568,6 +568,11 @@ export class MusicList { this.runNotationCallback(); } + addBarline (bar: string) { + this.m_list.push(new BarlineItem(bar)); + this.runNotationCallback(); + } + getLastNote(): NoteItem | null { for (let i = this.m_list.length - 1; i >= 0; i--) { if (this.m_list[i].m_type === "note") { @@ -811,3 +816,46 @@ export class MusicList { } } } + +export class BarlineItem implements MusicItem{ + readonly m_type = "barLine"; + m_line = -1; + m_id: string; + m_barline: string; + + constructor (bar?: string) { + if (bar !== undefined) { + this.m_barline = bar; + } + } + + getHumdrumLine (): string { + let output = ""; + switch (this.m_barline) { + case "|": output += "="; break; + case "=": output += "=="; break; + default: output += ""; break; + } + output += "\t."; + return output; + } + + static parseXML(element: Element): BarlineItem { + let barline = new BarlineItem(); + if (element.hasAttribute("xml:id")) { + barline.m_id = element.getAttribute("xml:id"); + } + if (element.hasAttribute("form")) { + switch(element.getAttribute("form")) { + case "dbl": + case "end": + barline.m_barline = "=="; + break; + case "single": + barline.m_barline = "="; + break; + } + } + return barline; + } +} From 67186f31dffbcaec09be0a34e0173daa9b115747 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 12 Sep 2022 16:22:17 -0400 Subject: [PATCH 2/4] Add lines in mei.ts to parse xml of barline. It does not seem to be working yet. --- src/app/utils/mei.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/utils/mei.ts b/src/app/utils/mei.ts index 5463de1..9a409de 100644 --- a/src/app/utils/mei.ts +++ b/src/app/utils/mei.ts @@ -1,6 +1,6 @@ import { Part, Tenor } from './part'; import { System, Pb, Sb } from './system'; -import { ClefItem, NoteItem, RestItem, MensurItem } from './MusicItem'; +import { ClefItem, NoteItem, RestItem, MensurItem, BarlineItem } from './MusicItem'; import { Voice, Mensuration, Contributor, Sign } from './definitions'; import { IRI } from './definitions'; @@ -260,6 +260,9 @@ export class MEIDocument { } else if (child.tagName === "mensur") { let mensur = MensurItem.parseXML(child); activeSystem.contents.m_list.push(mensur); + } else if (child.tagName === "barLine") { + let barline = BarlineItem.parseXML(child); + activeSystem.contents.m_list.push(barline); } } } From d3df31826e80d5ac6778a81591b8950c8b16d32b Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Mon, 12 Sep 2022 16:23:03 -0400 Subject: [PATCH 3/4] Rearrange code and add possibility of processing barlines with no form attribute --- src/app/utils/MusicItem.ts | 89 ++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/src/app/utils/MusicItem.ts b/src/app/utils/MusicItem.ts index 418a5a1..28cfe5a 100644 --- a/src/app/utils/MusicItem.ts +++ b/src/app/utils/MusicItem.ts @@ -457,6 +457,52 @@ export class NoteItem implements MusicItem { } } +export class BarlineItem implements MusicItem { + readonly m_type = "barLine"; + m_line = -1; + m_id: string; + m_barline: string; + + constructor (bar?: string) { + if (bar !== undefined) { + this.m_barline = bar; + } + } + + getHumdrumLine (): string { + let output = ""; + switch (this.m_barline) { + case "|": output += "="; break; + case "=": output += "=="; break; + default: output += ""; break; + } + output += "\t."; + return output; + } + + static parseXML(element: Element): BarlineItem { + let barline = new BarlineItem(); + if (element.hasAttribute("xml:id")) { + barline.m_id = element.getAttribute("xml:id"); + } + if (element.hasAttribute("form")) { + switch(element.getAttribute("form")) { + case "dbl": + case "end": + barline.m_barline = "=="; + break; + case "single": + barline.m_barline = "="; + break; + default: + barline.m_barline = "="; + break; + } + } + return barline; + } +} + export class MusicList { m_list: Array = []; m_index = -1; @@ -816,46 +862,3 @@ export class MusicList { } } } - -export class BarlineItem implements MusicItem{ - readonly m_type = "barLine"; - m_line = -1; - m_id: string; - m_barline: string; - - constructor (bar?: string) { - if (bar !== undefined) { - this.m_barline = bar; - } - } - - getHumdrumLine (): string { - let output = ""; - switch (this.m_barline) { - case "|": output += "="; break; - case "=": output += "=="; break; - default: output += ""; break; - } - output += "\t."; - return output; - } - - static parseXML(element: Element): BarlineItem { - let barline = new BarlineItem(); - if (element.hasAttribute("xml:id")) { - barline.m_id = element.getAttribute("xml:id"); - } - if (element.hasAttribute("form")) { - switch(element.getAttribute("form")) { - case "dbl": - case "end": - barline.m_barline = "=="; - break; - case "single": - barline.m_barline = "="; - break; - } - } - return barline; - } -} From 27dc9ca92031b76b7477daffe31fb4acbd34fe93 Mon Sep 17 00:00:00 2001 From: martha-thomae Date: Thu, 16 Apr 2026 01:09:34 +0200 Subject: [PATCH 4/4] Add support for double barlines (in addition to single and end barlines) --- .../input/staff-select/staff-select.component.ts | 1 + src/app/utils/MusicItem.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/app/input/staff-select/staff-select.component.ts b/src/app/input/staff-select/staff-select.component.ts index c6d082f..605b768 100644 --- a/src/app/input/staff-select/staff-select.component.ts +++ b/src/app/input/staff-select/staff-select.component.ts @@ -237,6 +237,7 @@ export class StaffSelectComponent implements OnInit { break; case '=': case '|': + case '/': musicList.addBarline(event.key); event.preventDefault(); break; diff --git a/src/app/utils/MusicItem.ts b/src/app/utils/MusicItem.ts index 28cfe5a..4a502e2 100644 --- a/src/app/utils/MusicItem.ts +++ b/src/app/utils/MusicItem.ts @@ -472,8 +472,9 @@ export class BarlineItem implements MusicItem { getHumdrumLine (): string { let output = ""; switch (this.m_barline) { - case "|": output += "="; break; - case "=": output += "=="; break; + case "/": output += "=|"; break; // single barline (@form = single in mei) + case "|": output += "=||"; break; // double barline (@form = dbl in mei) + case "=": output += "=="; break; // final barline (@form = end in mei) default: output += ""; break; } output += "\t."; @@ -487,15 +488,17 @@ export class BarlineItem implements MusicItem { } if (element.hasAttribute("form")) { switch(element.getAttribute("form")) { + case "single": + barline.m_barline = "=|"; + break; case "dbl": + barline.m_barline = "=||"; + break; case "end": barline.m_barline = "=="; break; - case "single": - barline.m_barline = "="; - break; default: - barline.m_barline = "="; + barline.m_barline = "=."; // probably an error, so we are marking it as a dotted barline break; } }