VexFlowStaffEntry.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import {GraphicalStaffEntry} from "../GraphicalStaffEntry";
  2. import {VexFlowMeasure} from "./VexFlowMeasure";
  3. import {SourceStaffEntry} from "../../VoiceData/SourceStaffEntry";
  4. import {GraphicalNote} from "../GraphicalNote";
  5. export class VexFlowStaffEntry extends GraphicalStaffEntry {
  6. constructor(measure: VexFlowMeasure, sourceStaffEntry: SourceStaffEntry, staffEntryParent: VexFlowStaffEntry) {
  7. super(measure, sourceStaffEntry, staffEntryParent);
  8. }
  9. // The Graphical Notes belonging to this StaffEntry, sorted by voiceID
  10. public graphicalNotes: { [voiceID: number]: GraphicalNote[]; } = {};
  11. // The corresponding VexFlow.StaveNotes
  12. public vfNotes: { [voiceID: number]: Vex.Flow.StaveNote; } = {};
  13. public getXinpx(): number {
  14. let x: number = 0;
  15. let n: number = 0;
  16. let vfNotes: { [voiceID: number]: Vex.Flow.StaveNote; } = this.vfNotes;
  17. for (let voiceId in vfNotes) {
  18. if (vfNotes.hasOwnProperty(voiceId)) {
  19. x += (vfNotes[voiceId].getNoteHeadBeginX() + vfNotes[voiceId].getNoteHeadEndX()) / 2;
  20. n += 1;
  21. }
  22. }
  23. console.log(x, n);
  24. return x / n;
  25. }
  26. }