RhythmInstruction.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. export class RhythmInstruction extends AbstractNotationInstruction {
  2. constructor(rhythm: Fraction, numerator: number, denominator: number, rhythmSymbolEnum: RhythmSymbolEnum) {
  3. super();
  4. this.rhythm = rhythm;
  5. this.numerator = numerator;
  6. this.denominator = denominator;
  7. this.symbolEnum = rhythmSymbolEnum;
  8. }
  9. constructor(rhythmInstruction: RhythmInstruction) {
  10. super(rhythmInstruction.parent);
  11. this.rhythm = rhythmInstruction.rhythm;
  12. this.numerator = rhythmInstruction.numerator;
  13. this.denominator = rhythmInstruction.denominator;
  14. this.symbolEnum = rhythmInstruction.symbolEnum;
  15. }
  16. private numerator: number;
  17. private denominator: number;
  18. private rhythm: Fraction;
  19. private symbolEnum: RhythmSymbolEnum;
  20. public get Rhythm(): Fraction {
  21. return this.rhythm;
  22. }
  23. public set Rhythm(value: Fraction) {
  24. this.rhythm = value;
  25. }
  26. public get SymbolEnum(): RhythmSymbolEnum {
  27. return this.symbolEnum;
  28. }
  29. public set SymbolEnum(value: RhythmSymbolEnum) {
  30. this.symbolEnum = value;
  31. }
  32. public OperatorEquals(rhythm2: RhythmInstruction): boolean {
  33. let rhythm1: RhythmInstruction = this;
  34. if (ReferenceEquals(rhythm1, rhythm2)) {
  35. return true;
  36. }
  37. if ((<Object>rhythm1 === undefined) || (<Object>rhythm2 === undefined)) {
  38. return false;
  39. }
  40. return (rhythm1.numerator === rhythm2.numerator && rhythm1.denominator === rhythm2.denominator);
  41. }
  42. public OperatorNotEqual(rhythm2: RhythmInstruction): boolean {
  43. let rhythm1: RhythmInstruction = this;
  44. return !(rhythm1 === rhythm2);
  45. }
  46. public ToString(): string {
  47. return "Rhythm: " + this.rhythm.ToString();
  48. }
  49. }
  50. export enum RhythmSymbolEnum {
  51. NONE = 0,
  52. COMMON = 1,
  53. CUT = 2,
  54. }