12345678910111213141516171819202122232425262728293031323334353637383940 |
- import {Note} from "./Note";
- import { Fraction } from "../../Common/DataObjects/Fraction";
- import { Pitch } from "../../Common/DataObjects/Pitch";
- /**
- * A [[Tie]] connects two notes of the same pitch and name, indicating that they have to be played as a single note.
- */
- export class Tie {
- constructor(note: Note) {
- this.AddNote(note);
- }
- private notes: Note[] = [];
- public get Notes(): Note[] {
- return this.notes;
- }
- public get StartNote(): Note {
- return this.notes[0];
- }
- public get Duration(): Fraction {
- const duration: Fraction = new Fraction();
- for (const note of this.notes) {
- duration.Add(note.Length);
- }
- return duration;
- }
- public get Pitch(): Pitch {
- return this.StartNote.Pitch;
- }
- public AddNote(note: Note): void {
- this.notes.push(note);
- note.NoteTie = this;
- }
- }
|