11import { AlphaTabError , AlphaTabErrorType } from '@coderline/alphatab/AlphaTabError' ;
22import type { CoreSettings } from '@coderline/alphatab/CoreSettings' ;
33import { Environment } from '@coderline/alphatab/Environment' ;
4- import { EventEmitter , EventEmitterOfT , type IEventEmitter , type IEventEmitterOfT } from '@coderline/alphatab/EventEmitter' ;
4+ import {
5+ EventEmitter ,
6+ EventEmitterOfT ,
7+ type IEventEmitter ,
8+ type IEventEmitterOfT
9+ } from '@coderline/alphatab/EventEmitter' ;
510import { AlphaTexImporter } from '@coderline/alphatab/importer/AlphaTexImporter' ;
611import { Logger } from '@coderline/alphatab/Logger' ;
712import { AlphaSynthMidiFileHandler } from '@coderline/alphatab/midi/AlphaSynthMidiFileHandler' ;
@@ -42,11 +47,10 @@ import { ModelUtils } from '@coderline/alphatab/model/ModelUtils';
4247import type { Note } from '@coderline/alphatab/model/Note' ;
4348import type { Score } from '@coderline/alphatab/model/Score' ;
4449import type { Track } from '@coderline/alphatab/model/Track' ;
45- import { PlayerMode , ScrollMode } from '@coderline/alphatab/PlayerSettings' ;
4650import type { IContainer } from '@coderline/alphatab/platform/IContainer' ;
4751import type { IMouseEventArgs } from '@coderline/alphatab/platform/IMouseEventArgs' ;
4852import type { IUiFacade } from '@coderline/alphatab/platform/IUiFacade' ;
49- import { ResizeEventArgs } from '@coderline/alphatab/ResizeEventArgs ' ;
53+ import { PlayerMode , ScrollMode } from '@coderline/alphatab/PlayerSettings ' ;
5054import { BeatContainerGlyph } from '@coderline/alphatab/rendering/glyphs/BeatContainerGlyph' ;
5155import type { IScoreRenderer } from '@coderline/alphatab/rendering/IScoreRenderer' ;
5256import type { RenderFinishedEventArgs } from '@coderline/alphatab/rendering/RenderFinishedEventArgs' ;
@@ -57,12 +61,17 @@ import type { Bounds } from '@coderline/alphatab/rendering/utils/Bounds';
5761import type { BoundsLookup } from '@coderline/alphatab/rendering/utils/BoundsLookup' ;
5862import type { MasterBarBounds } from '@coderline/alphatab/rendering/utils/MasterBarBounds' ;
5963import type { StaffSystemBounds } from '@coderline/alphatab/rendering/utils/StaffSystemBounds' ;
64+ import { ResizeEventArgs } from '@coderline/alphatab/ResizeEventArgs' ;
6065import type { Settings } from '@coderline/alphatab/Settings' ;
6166import { ActiveBeatsChangedEventArgs } from '@coderline/alphatab/synth/ActiveBeatsChangedEventArgs' ;
6267import { AlphaSynthWrapper } from '@coderline/alphatab/synth/AlphaSynthWrapper' ;
6368import { ExternalMediaPlayer } from '@coderline/alphatab/synth/ExternalMediaPlayer' ;
6469import type { IAlphaSynth } from '@coderline/alphatab/synth/IAlphaSynth' ;
65- import { AudioExportOptions , type IAudioExporter , type IAudioExporterWorker } from '@coderline/alphatab/synth/IAudioExporter' ;
70+ import {
71+ AudioExportOptions ,
72+ type IAudioExporter ,
73+ type IAudioExporterWorker
74+ } from '@coderline/alphatab/synth/IAudioExporter' ;
6675import type { ISynthOutputDevice } from '@coderline/alphatab/synth/ISynthOutput' ;
6776import type { MidiEventsPlayedEventArgs } from '@coderline/alphatab/synth/MidiEventsPlayedEventArgs' ;
6877import { PlaybackRange } from '@coderline/alphatab/synth/PlaybackRange' ;
@@ -100,6 +109,15 @@ export class AlphaTabApiBase<TSettings> {
100109 private _player ! : AlphaSynthWrapper ;
101110 private _renderer : ScoreRendererWrapper ;
102111
112+ /**
113+ * An indicator by how many midi-ticks the song contents are shifted.
114+ * Grace beats at start might require a shift for the first beat to start at 0.
115+ * This information can be used to translate back the player time axis to the music notation.
116+ */
117+ public get midiTickShift ( ) {
118+ return this . _player . midiTickShift ;
119+ }
120+
103121 /**
104122 * The actual player mode which is currently active.
105123 * @remarks
@@ -1537,6 +1555,7 @@ export class AlphaTabApiBase<TSettings> {
15371555 this . _onMidiLoad ( midiFile ) ;
15381556
15391557 const player = this . _player ;
1558+ player . midiTickShift = handler . tickShift ;
15401559 player . loadMidiFile ( midiFile ) ;
15411560 player . loadBackingTrack ( score ) ;
15421561 player . updateSyncPoints ( generator . syncPoints ) ;
@@ -3578,10 +3597,12 @@ export class AlphaTabApiBase<TSettings> {
35783597 return ;
35793598 }
35803599
3581- this . _previousTick = e . currentTick ;
3600+ const currentTick = e . currentTick ;
3601+
3602+ this . _previousTick = currentTick ;
35823603 this . uiFacade . beginInvoke ( ( ) => {
35833604 const cursorSpeed = e . modifiedTempo / e . originalTempo ;
3584- this . _cursorUpdateTick ( e . currentTick , false , cursorSpeed , false , e . isSeek ) ;
3605+ this . _cursorUpdateTick ( currentTick , false , cursorSpeed , false , e . isSeek ) ;
35853606 } ) ;
35863607
35873608 this . uiFacade . triggerEvent ( this . container , 'playerPositionChanged' , e ) ;
0 commit comments