MusicSheet.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. import {Fraction} from "../Common/DataObjects/Fraction";
  2. import {MusicPartManager} from "./MusicParts/MusicPartManager";
  3. import {SourceMeasure} from "./VoiceData/SourceMeasure";
  4. import {Repetition} from "./MusicSource/Repetition";
  5. import {DynamicsContainer} from "./VoiceData/HelperObjects/DynamicsContainer";
  6. import {InstrumentalGroup} from "./InstrumentalGroup";
  7. import {Instrument} from "./Instrument";
  8. import {Label} from "./Label";
  9. import {Staff} from "./VoiceData/Staff";
  10. import {MusicPartManagerIterator} from "./MusicParts/MusicPartManagerIterator";
  11. import {VerticalSourceStaffEntryContainer} from "./VoiceData/VerticalSourceStaffEntryContainer";
  12. import {Voice} from "./VoiceData/Voice";
  13. import {MusicSheetErrors} from "../Common/DataObjects/MusicSheetErrors";
  14. import {MultiTempoExpression} from "./VoiceData/Expressions/MultiTempoExpression";
  15. import {EngravingRules} from "./Graphical/EngravingRules";
  16. import {NoteState} from "./Graphical/DrawingEnums";
  17. import {Note} from "./VoiceData/Note";
  18. import {VoiceEntry} from "./VoiceData/VoiceEntry";
  19. import log from "loglevel";
  20. import { Dictionary } from "typescript-collections";
  21. import { PlaybackEntry } from "./Playback/PlaybackEntry";
  22. import { PlaybackSettings } from "../Common/DataObjects/PlaybackSettings";
  23. // FIXME Andrea: Commented out some unnecessary/not-ported-yet code, have a look at (*)
  24. /**
  25. * This is the representation of a complete piece of sheet music.
  26. * It includes the contents of a MusicXML file after the reading.
  27. * Notes: the musicsheet might not need the Rules, e.g. in the testframework. The EngravingRules Constructor
  28. * fails when no FontInfo exists, which needs a TextMeasurer
  29. */
  30. export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet>*/ {
  31. constructor() {
  32. // initialize SheetPlaybackSetting with default values
  33. this.userStartTempoInBPM = 100;
  34. this.playbackSettings = new PlaybackSettings(new Fraction(4, 4, 0, false), this.userStartTempoInBPM);
  35. this.pageWidth = 120;
  36. // create MusicPartManager
  37. this.MusicPartManager = new MusicPartManager(this);
  38. this.hasBPMInfo = false;
  39. }
  40. public static defaultTitle: string = "defaultTitle";
  41. public userStartTempoInBPM: number;
  42. public pageWidth: number;
  43. private idString: string = "uninitialized";
  44. private sourceMeasures: SourceMeasure[] = [];
  45. private repetitions: Repetition[] = [];
  46. private dynListStaves: DynamicsContainer[][] = [];
  47. private timestampSortedDynamicExpressionsList: DynamicsContainer[] = [];
  48. private timestampSortedTempoExpressionsList: MultiTempoExpression[] = [];
  49. private instrumentalGroups: InstrumentalGroup[] = [];
  50. /** The parts in the sheet, e.g. piano left hand, or piano right hand, or violin. */
  51. private instruments: Instrument[] = []; // Should be renamed from instruments to parts and part, though this will be a big refactor
  52. private playbackSettings: PlaybackSettings;
  53. private path: string;
  54. private title: Label;
  55. private subtitle: Label;
  56. private composer: Label;
  57. private lyricist: Label;
  58. // private languages: Language[] = [];
  59. // private activeLanguage: Language;
  60. private musicPartManager: MusicPartManager = undefined;
  61. private musicSheetErrors: MusicSheetErrors = new MusicSheetErrors();
  62. private staves: Staff[] = [];
  63. private playbackDataDict: Dictionary<Voice, { enrolledTimestamp: Fraction, playbackEntry: PlaybackEntry }[]>
  64. = new Dictionary<Voice, { enrolledTimestamp: Fraction, playbackEntry: PlaybackEntry }[]>();
  65. private selectionStart: Fraction;
  66. private selectionEnd: Fraction;
  67. private transpose: number = 0;
  68. private defaultStartTempoInBpm: number = 0;
  69. private drawErroneousMeasures: boolean = false;
  70. private hasBeenOpenedForTheFirstTime: boolean = false;
  71. private currentEnrolledPosition: Fraction = new Fraction(0, 1);
  72. // (*) private musicSheetParameterObject: MusicSheetParameterObject = undefined;
  73. private rules: EngravingRules;
  74. // (*) private musicSheetParameterChangedDelegate: MusicSheetParameterChangedDelegate;
  75. /* Whether BPM info is present in the sheet. If it is set to false, each measure's BPM was set to a default of 120. */
  76. private hasBPMInfo: boolean;
  77. /**
  78. * Get the global index within the music sheet for this staff.
  79. * @param staff
  80. * @returns {number}
  81. */
  82. public static getIndexFromStaff(staff: Staff): number {
  83. return staff.idInMusicSheet;
  84. }
  85. public get SourceMeasures(): SourceMeasure[] {
  86. return this.sourceMeasures;
  87. }
  88. public set SourceMeasures(value: SourceMeasure[]) {
  89. this.sourceMeasures = value;
  90. }
  91. public get Repetitions(): Repetition[] {
  92. return this.repetitions;
  93. }
  94. public set Repetitions(value: Repetition[]) {
  95. this.repetitions = value;
  96. }
  97. public get DynListStaves(): DynamicsContainer[][] {
  98. return this.dynListStaves;
  99. }
  100. public get TimestampSortedTempoExpressionsList(): MultiTempoExpression[] {
  101. return this.timestampSortedTempoExpressionsList;
  102. }
  103. public get TimestampSortedDynamicExpressionsList(): DynamicsContainer[] {
  104. return this.timestampSortedDynamicExpressionsList;
  105. }
  106. public get InstrumentalGroups(): InstrumentalGroup[] {
  107. return this.instrumentalGroups;
  108. }
  109. public get Parts(): Instrument[] { // Instrument should be renamed to Part
  110. return this.instruments;
  111. }
  112. public get Instruments(): Instrument[] { // deprecated
  113. // this method name should remain for a while to maintain compatibility even when Instrument is renamed to Part
  114. return this.instruments;
  115. }
  116. public get SheetPlaybackSetting(): PlaybackSettings {
  117. return this.playbackSettings;
  118. }
  119. public set SheetPlaybackSetting(value: PlaybackSettings) {
  120. this.playbackSettings = value;
  121. }
  122. public get DrawErroneousMeasures(): boolean {
  123. return this.drawErroneousMeasures;
  124. }
  125. public set DrawErroneousMeasures(value: boolean) {
  126. this.drawErroneousMeasures = value;
  127. }
  128. public get HasBeenOpenedForTheFirstTime(): boolean {
  129. return this.hasBeenOpenedForTheFirstTime;
  130. }
  131. public set HasBeenOpenedForTheFirstTime(value: boolean) {
  132. this.hasBeenOpenedForTheFirstTime = value;
  133. }
  134. public InitializeStartTempoInBPM(startTempo: number): void {
  135. this.playbackSettings.BeatsPerMinute = startTempo;
  136. this.userStartTempoInBPM = startTempo;
  137. }
  138. public get DefaultStartTempoInBpm(): number {
  139. return this.defaultStartTempoInBpm;
  140. }
  141. public set DefaultStartTempoInBpm(value: number) {
  142. this.defaultStartTempoInBpm = value;
  143. this.InitializeStartTempoInBPM(value);
  144. }
  145. public get Path(): string {
  146. return this.path;
  147. }
  148. public set Path(value: string) {
  149. this.path = value;
  150. }
  151. public get Staves(): Staff[] {
  152. return this.staves;
  153. }
  154. public get TitleString(): string {
  155. if (this.title) {
  156. return this.title.text;
  157. } else {
  158. return "";
  159. }
  160. }
  161. public set TitleString(value: string) {
  162. this.Title = new Label(value);
  163. }
  164. public get SubtitleString(): string {
  165. if (this.subtitle) {
  166. return this.subtitle.text;
  167. } else {
  168. return "";
  169. }
  170. }
  171. public set SubtitleString(value: string) {
  172. this.Subtitle = new Label(value);
  173. }
  174. public get ComposerString(): string {
  175. if (this.composer) {
  176. return this.composer.text;
  177. } else {
  178. return "";
  179. }
  180. }
  181. public set ComposerString(value: string) {
  182. this.Composer = new Label(value);
  183. }
  184. public get LyricistString(): string {
  185. if (this.lyricist) {
  186. return this.lyricist.text;
  187. } else {
  188. return "";
  189. }
  190. }
  191. public set LyricistString(value: string) {
  192. this.Lyricist = new Label(value);
  193. }
  194. public get Title(): Label {
  195. return this.title;
  196. }
  197. public set Title(value: Label) {
  198. this.title = value;
  199. }
  200. public get Subtitle(): Label {
  201. return this.subtitle;
  202. }
  203. public set Subtitle(value: Label) {
  204. this.subtitle = value;
  205. }
  206. public get Composer(): Label {
  207. return this.composer;
  208. }
  209. public set Composer(value: Label) {
  210. this.composer = value;
  211. }
  212. public get Lyricist(): Label {
  213. return this.lyricist;
  214. }
  215. public set Lyricist(value: Label) {
  216. this.lyricist = value;
  217. }
  218. public get Rules(): EngravingRules {
  219. if (!this.rules) {
  220. log.debug("warning: sheet.Rules was undefined. Creating new EngravingRules.");
  221. this.rules = new EngravingRules();
  222. }
  223. return this.rules;
  224. }
  225. public set Rules(value: EngravingRules) {
  226. this.rules = value;
  227. }
  228. public get SheetErrors(): MusicSheetErrors {
  229. return this.musicSheetErrors;
  230. }
  231. public get PlaybackDataDict(): Dictionary<Voice, { enrolledTimestamp: Fraction, playbackEntry: PlaybackEntry}[]> {
  232. return this.playbackDataDict;
  233. }
  234. public get SelectionStart(): Fraction {
  235. return this.selectionStart;
  236. }
  237. public set SelectionStart(value: Fraction) {
  238. this.selectionStart = value.clone();
  239. this.currentEnrolledPosition = value.clone();
  240. }
  241. public get SelectionEnd(): Fraction {
  242. return this.selectionEnd;
  243. }
  244. public set SelectionEnd(value: Fraction) {
  245. this.selectionEnd = value;
  246. }
  247. public set HasBPMInfo(value: boolean) {
  248. this.hasBPMInfo = value;
  249. }
  250. public get HasBPMInfo(): boolean {
  251. return this.hasBPMInfo;
  252. }
  253. // (*) public get MusicSheetParameterObject(): MusicSheetParameterObject {
  254. // return this.musicSheetParameterObject;
  255. //}
  256. // (*) public set MusicSheetParameterObject(value: MusicSheetParameterObject) {
  257. // this.musicSheetParameterObject = value;
  258. // this.Title = new Label(this.musicSheetParameterObject.Title);
  259. // this.Composer = new Label(this.musicSheetParameterObject.Composer);
  260. //}
  261. public addMeasure(measure: SourceMeasure): void {
  262. this.sourceMeasures.push(measure);
  263. measure.measureListIndex = this.sourceMeasures.length - 1;
  264. }
  265. public checkForInstrumentWithNoVoice(): void {
  266. for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
  267. const instrument: Instrument = this.instruments[idx];
  268. if (instrument.Voices.length === 0) {
  269. const voice: Voice = new Voice(instrument, 1);
  270. instrument.Voices.push(voice);
  271. }
  272. }
  273. }
  274. /**
  275. *
  276. * @param staffIndexInMusicSheet - The global staff index, iterating through all staves of all instruments.
  277. * @returns {Staff}
  278. */
  279. public getStaffFromIndex(staffIndexInMusicSheet: number): Staff {
  280. return this.staves[staffIndexInMusicSheet];
  281. }
  282. public fillStaffList(): void {
  283. let i: number = 0;
  284. for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
  285. const instrument: Instrument = this.instruments[idx];
  286. for (let idx2: number = 0, len2: number = instrument.Staves.length; idx2 < len2; ++idx2) {
  287. const staff: Staff = instrument.Staves[idx2];
  288. staff.idInMusicSheet = i;
  289. this.staves.push(staff);
  290. i++;
  291. }
  292. }
  293. }
  294. public get MusicPartManager(): MusicPartManager {
  295. return this.musicPartManager;
  296. }
  297. public set MusicPartManager(value: MusicPartManager) {
  298. this.musicPartManager = value;
  299. }
  300. public getCompleteNumberOfStaves(): number {
  301. let num: number = 0;
  302. for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
  303. const instrument: Instrument = this.instruments[idx];
  304. num += instrument.Staves.length;
  305. }
  306. return num;
  307. }
  308. /**
  309. * Return a sourceMeasureList, where the given indices correspond to the whole SourceMeasureList of the MusicSheet.
  310. * @param start
  311. * @param end
  312. * @returns {SourceMeasure[]}
  313. */
  314. public getListOfMeasuresFromIndeces(start: number, end: number): SourceMeasure[] {
  315. const measures: SourceMeasure[] = [];
  316. for (let i: number = start; i <= end; i++) {
  317. measures.push(this.sourceMeasures[i]);
  318. }
  319. return measures;
  320. }
  321. /**
  322. * Returns the next SourceMeasure from a given SourceMeasure.
  323. * @param measure
  324. */
  325. public getNextSourceMeasure(measure: SourceMeasure): SourceMeasure {
  326. const index: number = this.sourceMeasures.indexOf(measure);
  327. if (index === this.sourceMeasures.length - 1) {
  328. return measure;
  329. }
  330. return this.sourceMeasures[index + 1];
  331. }
  332. /**
  333. * Returns the first SourceMeasure of MusicSheet.
  334. */
  335. public getFirstSourceMeasure(): SourceMeasure {
  336. return this.sourceMeasures[0];
  337. }
  338. /**
  339. * Returns the last SourceMeasure of MusicSheet.
  340. */
  341. public getLastSourceMeasure(): SourceMeasure {
  342. return this.sourceMeasures[this.sourceMeasures.length - 1];
  343. }
  344. public resetAllNoteStates(): void {
  345. const iterator: MusicPartManagerIterator = this.MusicPartManager.getIterator();
  346. while (!iterator.EndReached && iterator.CurrentVoiceEntries) {
  347. for (let idx: number = 0, len: number = iterator.CurrentVoiceEntries.length; idx < len; ++idx) {
  348. const voiceEntry: VoiceEntry = iterator.CurrentVoiceEntries[idx];
  349. for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
  350. const note: Note = voiceEntry.Notes[idx2];
  351. note.state = NoteState.Normal;
  352. }
  353. }
  354. iterator.moveToNext();
  355. }
  356. }
  357. public getMusicSheetInstrumentIndex(instrument: Instrument): number {
  358. return this.Instruments.indexOf(instrument);
  359. }
  360. public getGlobalStaffIndexOfFirstStaff(instrument: Instrument): number {
  361. const instrumentIndex: number = this.getMusicSheetInstrumentIndex(instrument);
  362. let staffLineIndex: number = 0;
  363. for (let i: number = 0; i < instrumentIndex; i++) {
  364. staffLineIndex += this.Instruments[i].Staves.length;
  365. }
  366. return staffLineIndex;
  367. }
  368. /**
  369. * Set to the index-given Repetition a new (set from user) value.
  370. * @param index
  371. * @param value
  372. */
  373. public setRepetitionNewUserNumberOfRepetitions(index: number, value: number): void {
  374. let repIndex: number = 0;
  375. for (let i: number = 0; i < this.repetitions.length; i++) {
  376. if (this.repetitions[i] instanceof Repetition) { // FIXME
  377. if (index === repIndex) {
  378. this.repetitions[i].UserNumberOfRepetitions = value;
  379. break;
  380. } else {
  381. repIndex++;
  382. }
  383. }
  384. }
  385. }
  386. /**
  387. * Return the [[Repetition]] from the given index.
  388. * @param index
  389. * @returns {any}
  390. */
  391. public getRepetitionByIndex(index: number): Repetition {
  392. let repIndex: number = 0;
  393. for (let i: number = 0; i < this.repetitions.length; i++) {
  394. if (this.repetitions[i] instanceof Repetition) {
  395. if (index === repIndex) {
  396. return <Repetition>this.repetitions[i];
  397. }
  398. repIndex++;
  399. }
  400. }
  401. return undefined;
  402. }
  403. public CompareTo(other: MusicSheet): number {
  404. return this.Title.text.localeCompare(other.Title.text);
  405. }
  406. // (*)
  407. //public get IInstruments(): IInstrument[] {
  408. // return this.instruments.slice()
  409. //}
  410. //public get IInitializableInstruments(): ISettableInstrument[] {
  411. // return this.instruments.slice();
  412. //}
  413. //public get IRepetitions(): IRepetition[] {
  414. // try {
  415. // let repetitions: IRepetition[] = [];
  416. // for (let idx: number = 0, len: number = this.repetitions.length; idx < len; ++idx) {
  417. // let partListEntry: PartListEntry = this.repetitions[idx];
  418. // if (partListEntry instanceof Repetition) {
  419. // repetitions.push(<Repetition>partListEntry);
  420. // }
  421. // }
  422. // return repetitions;
  423. // } catch (ex) {
  424. // log.info("MusicSheet.IRepetitions get: ", ex);
  425. // return undefined;
  426. // }
  427. //
  428. //}
  429. public getExpressionsStartTempoInBPM(): number {
  430. if (this.TimestampSortedTempoExpressionsList.length > 0) {
  431. const me: MultiTempoExpression = this.TimestampSortedTempoExpressionsList[0];
  432. if (me.InstantaneousTempo) {
  433. return me.InstantaneousTempo.TempoInBpm;
  434. } else if (me.ContinuousTempo) {
  435. return me.ContinuousTempo.StartTempo;
  436. }
  437. }
  438. return this.userStartTempoInBPM;
  439. }
  440. public get Errors(): { [n: number]: string[] } {
  441. return this.musicSheetErrors.measureErrors;
  442. }
  443. public get FirstMeasureNumber(): number {
  444. try {
  445. return this.getFirstSourceMeasure().MeasureNumber;
  446. } catch (ex) {
  447. log.info("MusicSheet.FirstMeasureNumber: ", ex);
  448. return 0;
  449. }
  450. }
  451. public get LastMeasureNumber(): number {
  452. try {
  453. return this.getLastSourceMeasure().MeasureNumber;
  454. } catch (ex) {
  455. log.info("MusicSheet.LastMeasureNumber: ", ex);
  456. return 0;
  457. }
  458. }
  459. public get CurrentEnrolledPosition(): Fraction {
  460. return this.currentEnrolledPosition.clone();
  461. }
  462. public set CurrentEnrolledPosition(value: Fraction) {
  463. this.currentEnrolledPosition = value.clone();
  464. }
  465. public get Transpose(): number {
  466. return this.transpose;
  467. }
  468. /** Sets the number of halftones for transposition.
  469. * E.g. +1 halftone will transpose Eb major to E major.
  470. * also see Instrument.Transpose (e.g. osmd.Sheet.Instruments[0].Transpose will additionally transpose this instrument only)
  471. * osmd.TransposeCaculator needs to be defined/created for this to take effect. (just set it with new TransposeCalculator())
  472. */
  473. public set Transpose(value: number) {
  474. this.transpose = value;
  475. }
  476. // (*)
  477. //public SetMusicSheetParameter(parameter: MusicSheetParameters, value: Object): void {
  478. // if (this.PhonicScoreInterface) {
  479. // this.PhonicScoreInterface.RequestMusicSheetParameter(parameter, value);
  480. // } else {
  481. // let oldValue: Object = 0;
  482. // if (!parameter) { // FIXME MusicSheetParameters.MusicSheetTranspose) {
  483. // oldValue = this.Transpose;
  484. // this.Transpose = value;
  485. // }
  486. // if (!parameter) { // FIXME MusicSheetParameters.StartTempoInBPM) {
  487. // oldValue = this.UserStartTempoInBPM;
  488. // this.UserStartTempoInBPM = value;
  489. // }
  490. // if (!parameter) { // FIXME MusicSheetParameters.HighlightErrors) {
  491. // oldValue = value;
  492. // }
  493. // if (this.MusicSheetParameterChanged) {
  494. // this.musicSheetParameterChangedDelegate(undefined, parameter, value, oldValue);
  495. // }
  496. // }
  497. //}
  498. //public get MusicSheetParameterChanged(): MusicSheetParameterChangedDelegate {
  499. // return this.musicSheetParameterChangedDelegate;
  500. //}
  501. //public set MusicSheetParameterChanged(value: MusicSheetParameterChangedDelegate) {
  502. // this.musicSheetParameterChangedDelegate = value;
  503. //}
  504. public get FullNameString(): string {
  505. return this.ComposerString + " " + this.TitleString;
  506. }
  507. public get IdString(): string {
  508. return this.idString;
  509. }
  510. public set IdString(value: string) {
  511. this.idString = value;
  512. }
  513. // (*)
  514. // public Dispose(): void {
  515. // this.MusicSheetParameterChanged = undefined;
  516. // for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
  517. // let instrument: Instrument = this.instruments[idx];
  518. // instrument.dispose();
  519. // }
  520. // }
  521. public getEnrolledSelectionStartTimeStampWorkaround(): Fraction {
  522. const iter: MusicPartManagerIterator = this.MusicPartManager.getIterator(this.SelectionStart);
  523. return Fraction.createFromFraction(iter.CurrentEnrolledTimestamp);
  524. }
  525. public get SheetEndTimestamp(): Fraction {
  526. const lastMeasure: SourceMeasure = this.getLastSourceMeasure();
  527. return Fraction.plus(lastMeasure.AbsoluteTimestamp, lastMeasure.Duration);
  528. }
  529. /**
  530. * Works only if the [[SourceMeasure]]s are already filled with VerticalStaffEntryContainers!
  531. * @param timeStamp
  532. * @returns {SourceMeasure}
  533. */
  534. public getSourceMeasureFromTimeStamp(timeStamp: Fraction): SourceMeasure {
  535. for (let idx: number = 0, len: number = this.sourceMeasures.length; idx < len; ++idx) {
  536. const sm: SourceMeasure = this.sourceMeasures[idx];
  537. for (let idx2: number = 0, len2: number = sm.VerticalSourceStaffEntryContainers.length; idx2 < len2; ++idx2) {
  538. const vssec: VerticalSourceStaffEntryContainer = sm.VerticalSourceStaffEntryContainers[idx2];
  539. if (timeStamp.Equals(vssec.getAbsoluteTimestamp())) {
  540. return sm;
  541. }
  542. }
  543. }
  544. return this.findSourceMeasureFromTimeStamp(timeStamp);
  545. }
  546. public findSourceMeasureFromTimeStamp(timestamp: Fraction): SourceMeasure {
  547. for (const sm of this.sourceMeasures) {
  548. if (sm.AbsoluteTimestamp.lte(timestamp) && timestamp.lt(Fraction.plus(sm.AbsoluteTimestamp, sm.Duration))) {
  549. return sm;
  550. }
  551. }
  552. }
  553. public getVisibleInstruments(): Instrument[] {
  554. const visInstruments: Instrument[] = [];
  555. for (let idx: number = 0, len: number = this.Instruments.length; idx < len; ++idx) {
  556. const instrument: Instrument = this.Instruments[idx];
  557. if (instrument.Voices.length > 0 && instrument.Voices[0].Visible) {
  558. visInstruments.push(instrument);
  559. }
  560. }
  561. return visInstruments;
  562. }
  563. }