Skip to content

Commit

Permalink
Correct cursor positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Oct 8, 2024
1 parent bf22af1 commit 046c07b
Show file tree
Hide file tree
Showing 23 changed files with 270 additions and 216 deletions.
2 changes: 1 addition & 1 deletion demo/demo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function handlePlayPauseKey(e) {
g_state.player.pause();
}
else {
g_state.player.resume();
g_state.player.play();
}
}
}
Expand Down
207 changes: 113 additions & 94 deletions dist/musicxml-player.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/musicxml-player.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/types/FetchConverter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { IMidiConverter, MeasureTimemap } from './IMidiConverter';
*
* The timemap JSON file can be generated using the script midi-timemap which is distributed with musicxml-midi
* @see https://github.com/infojunkie/musicxml-midi/blob/main/src/js/midi-timemap.js
* It assumes that the MIDI file is itself generated using musicxml-midi.
* ASSUMPTION The MIDI file is itself generated using musicxml-midi.
*
* The timemap JSON structure is simple enough to be generated by other tools as well.
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/types/IMidiConverter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type MeasureTimemapEntry = {
timestamp: MillisecsTimestamp;
duration: MillisecsTimestamp;
};
export type MeasureTimemap = Array<MeasureTimemapEntry>;
export type MeasureTimemap = MeasureTimemapEntry[];
/**
* Interface to a MusicXML-to-MIDI converter.
*
Expand Down
2 changes: 1 addition & 1 deletion dist/types/IMidiConverter.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/types/MmaConverter.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions dist/types/MuseScoreRendererConverter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ export type MuseScoreDownloader = (musicXml: string) => {
*/
export declare class MuseScoreRendererConverter implements ISheetRenderer, IMidiConverter {
private _downloader;
private _media?;
private _mscore?;
private _midi?;
private _timemap?;
private _cursor;
private _positions?;
private _measures?;
private _segments?;
constructor(_downloader: string | MuseScoreDownloader | ReturnType<MuseScoreDownloader>);
destroy(): void;
initialize(container: HTMLElement, musicXml: string): Promise<void>;
moveTo(_index: MeasureIndex, _start: MillisecsTimestamp, _offset: MillisecsTimestamp, _duration?: MillisecsTimestamp): void;
moveTo(index: MeasureIndex, start: MillisecsTimestamp, offset: MillisecsTimestamp, _duration?: MillisecsTimestamp): void;
resize(): void;
get midi(): IMidiFile;
get timemap(): MeasureTimemap;
Expand Down
2 changes: 1 addition & 1 deletion dist/types/MuseScoreRendererConverter.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/types/OpenSheetMusicDisplayRenderer.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/types/VerovioConverter.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dist/types/VerovioRenderer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export interface CursorOptions {
scrollOffset: number;
}
/**
* Implementation of ISheetRenderer that uses Verovio @see https://github.com/rism-digital/verovio
* Implementation of ISheetRenderer that uses Verovio.
* @see https://github.com/rism-digital/verovio
*/
export declare class VerovioRenderer implements ISheetRenderer {
player?: Player;
Expand Down
2 changes: 1 addition & 1 deletion dist/types/VerovioRenderer.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/types/helpers/parse-midi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export declare function parseMidiEvent(data: number[] | Uint8Array): TMidiEvent;
* Copied from https://github.com/chrisguttandin/midi-json-parser-worker
* because the original code only runs in a Web Worker.
*/
export declare const parseMidiFile: (arrayBuffer: ArrayBuffer) => {
export declare const parseMidiFile: (arrayBuffer: ArrayBuffer, callback?: (trackNum: number, track: TMidiEvent[]) => void) => {
division: number;
format: number;
tracks: (IMidiChannelPrefixEvent | IMidiCopyrightNoticeEvent | IMidiCuePointEvent | IMidiDeviceNameEvent | IMidiEndOfTrackEvent | IMidiInstrumentNameEvent | IMidiKeySignatureEvent | IMidiLyricEvent | IMidiMarkerEvent | IMidiMidiPortEvent | IMidiProgramNameEvent | IMidiSequencerSpecificEvent | IMidiSetTempoEvent | IMidiSmpteOffsetEvent | IMidiTextEvent | IMidiTimeSignatureEvent | IMidiTrackNameEvent | IMidiChannelPressureEvent | IMidiControlChangeEvent | IMidiKeyPressureEvent | IMidiNoteOffEvent | IMidiNoteOnEvent | IMidiPitchBendEvent | IMidiProgramChangeEvent | IMidiSysexEvent)[][];
Expand Down
2 changes: 1 addition & 1 deletion dist/types/helpers/parse-midi.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/FetchConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parseArrayBuffer as parseMidiBuffer } from 'midi-json-parser';
import type { IMidiFile } from 'midi-json-parser-worker';
import type { IMidiConverter, MeasureTimemap } from './IMidiConverter';
import pkg from '../package.json';
import { fetish } from './helpers';
import { assertIsDefined, fetish } from './helpers';
import SaxonJS from './saxon-js/SaxonJS2.rt';

const XSL_TIMEMAP =
Expand All @@ -13,7 +13,7 @@ const XSL_TIMEMAP =
*
* The timemap JSON file can be generated using the script midi-timemap which is distributed with musicxml-midi
* @see https://github.com/infojunkie/musicxml-midi/blob/main/src/js/midi-timemap.js
* It assumes that the MIDI file is itself generated using musicxml-midi.
* ASSUMPTION The MIDI file is itself generated using musicxml-midi.
*
* The timemap JSON structure is simple enough to be generated by other tools as well.
*/
Expand Down Expand Up @@ -45,12 +45,12 @@ export class FetchConverter implements IMidiConverter {
}

get midi(): IMidiFile {
if (!this._midi) throw 'TODO';
assertIsDefined(this._midi);
return this._midi;
}

get timemap(): MeasureTimemap {
if (!this._timemap) throw 'TODO';
assertIsDefined(this._timemap);
return this._timemap;
}

Expand Down
2 changes: 1 addition & 1 deletion src/IMidiConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type MeasureTimemapEntry = {
timestamp: MillisecsTimestamp;
duration: MillisecsTimestamp;
};
export type MeasureTimemap = Array<MeasureTimemapEntry>;
export type MeasureTimemap = MeasureTimemapEntry[];

/**
* Interface to a MusicXML-to-MIDI converter.
Expand Down
Loading

0 comments on commit 046c07b

Please sign in to comment.