Voice.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {Instrument} from "../Instrument";
  2. import {VoiceEntry} from "./VoiceEntry";
  3. /**
  4. * A [[Voice]] contains all the [[VoiceEntry]]s in a voice in a [[StaffLine]].
  5. */
  6. export class Voice {
  7. private voiceEntries: VoiceEntry[] = [];
  8. private parent: Instrument;
  9. private visible: boolean;
  10. private audible: boolean;
  11. private following: boolean;
  12. private solo: boolean;
  13. /**
  14. * The Id given in the MusicXMl file to distinguish the different voices. It is unique per instrument.
  15. */
  16. private voiceId: number;
  17. private volume: number = 1;
  18. private uniqueVoiceId: string;
  19. constructor(parent: Instrument, voiceId: number) {
  20. this.parent = parent;
  21. this.visible = true;
  22. this.audible = true;
  23. this.following = true;
  24. this.voiceId = voiceId;
  25. // This is used for using the Voice as a key in a dictionary:
  26. this.uniqueVoiceId = "I:" + this.parent.Id + " V: " + this.voiceId;
  27. }
  28. public get VoiceEntries(): VoiceEntry[] {
  29. return this.voiceEntries;
  30. }
  31. public get Parent(): Instrument {
  32. return this.parent;
  33. }
  34. public get Visible(): boolean {
  35. return this.visible;
  36. }
  37. public set Visible(value: boolean) {
  38. this.visible = value;
  39. }
  40. public get Audible(): boolean {
  41. return this.audible;
  42. }
  43. public set Audible(value: boolean) {
  44. this.audible = value;
  45. }
  46. public get Following(): boolean {
  47. return this.following;
  48. }
  49. public set Following(value: boolean) {
  50. this.following = value;
  51. }
  52. public get Solo(): boolean {
  53. return this.solo;
  54. }
  55. public set Solo(value: boolean) {
  56. this.solo = value;
  57. }
  58. public get VoiceId(): number {
  59. return this.voiceId;
  60. }
  61. public get Volume(): number {
  62. return this.volume;
  63. }
  64. public set Volume(value: number) {
  65. this.volume = value;
  66. }
  67. /**
  68. * This is needed for using the Voice as a key in a dictionary,
  69. * where a unique identifier is expected.
  70. */
  71. public toString(): string {
  72. return this.uniqueVoiceId;
  73. }
  74. }