@coderline/alphatab 1.6.0-alpha.1401 → 1.6.0-alpha.1405

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,17 +77,47 @@ declare class ActiveBeatsChangedEventArgs {
77
77
  * This is the main synthesizer component which can be used to
78
78
  * play a {@link MidiFile} via a {@link ISynthOutput}.
79
79
  */
80
- declare class AlphaSynth implements IAlphaSynth {
81
- private _sequencer;
82
- private _synthesizer;
83
- private _isSoundFontLoaded;
80
+ declare class AlphaSynth extends AlphaSynthBase {
81
+ /**
82
+ * Initializes a new instance of the {@link AlphaSynth} class.
83
+ * @param output The output to use for playing the generated samples.
84
+ */
85
+ constructor(output: ISynthOutput, bufferTimeInMilliseconds: number);
86
+ }
87
+
88
+ /**
89
+ * This class implements a HTML5 Web Audio API based audio output device
90
+ * for alphaSynth. It can be controlled via a JS API.
91
+ * @target web
92
+ */
93
+ declare class AlphaSynthAudioWorkletOutput extends AlphaSynthWebAudioOutputBase {
94
+ private _worklet;
95
+ private _bufferTimeInMilliseconds;
96
+ private readonly _settings;
97
+ constructor(settings: Settings);
98
+ open(bufferTimeInMilliseconds: number): void;
99
+ play(): void;
100
+ private handleMessage;
101
+ pause(): void;
102
+ addSamples(f: Float32Array): void;
103
+ resetSamples(): void;
104
+ }
105
+
106
+ /**
107
+ * This is the base class for synthesizer components which can be used to
108
+ * play a {@link MidiFile} via a {@link ISynthOutput}.
109
+ */
110
+ declare class AlphaSynthBase implements IAlphaSynth {
111
+ protected sequencer: MidiFileSequencer;
112
+ protected synthesizer: IAudioSampleSynthesizer;
113
+ protected isSoundFontLoaded: boolean;
84
114
  private _isMidiLoaded;
85
115
  private _tickPosition;
86
116
  private _timePosition;
87
117
  private _metronomeVolume;
88
118
  private _countInVolume;
89
- private _playedEventsQueue;
90
- private _midiEventsPlayedFilter;
119
+ protected _playedEventsQueue: Queue<SynthEvent>;
120
+ protected _midiEventsPlayedFilter: Set<MidiEventType>;
91
121
  private _notPlayedSamples;
92
122
  private _synthStopping;
93
123
  private _output;
@@ -99,6 +129,7 @@ declare class AlphaSynth implements IAlphaSynth {
99
129
  set logLevel(value: LogLevel);
100
130
  get masterVolume(): number;
101
131
  set masterVolume(value: number);
132
+ protected updateMasterVolume(value: number): void;
102
133
  get metronomeVolume(): number;
103
134
  set metronomeVolume(value: number);
104
135
  get countInVolume(): number;
@@ -107,6 +138,7 @@ declare class AlphaSynth implements IAlphaSynth {
107
138
  set midiEventsPlayedFilter(value: MidiEventType[]);
108
139
  get playbackSpeed(): number;
109
140
  set playbackSpeed(value: number);
141
+ protected updatePlaybackSpeed(value: number): void;
110
142
  get tickPosition(): number;
111
143
  set tickPosition(value: number);
112
144
  get timePosition(): number;
@@ -117,10 +149,11 @@ declare class AlphaSynth implements IAlphaSynth {
117
149
  set isLooping(value: boolean);
118
150
  destroy(): void;
119
151
  /**
120
- * Initializes a new instance of the {@link AlphaSynth} class.
152
+ * Initializes a new instance of the {@link AlphaSynthBase} class.
121
153
  * @param output The output to use for playing the generated samples.
122
154
  */
123
- constructor(output: ISynthOutput, bufferTimeInMilliseconds: number);
155
+ constructor(output: ISynthOutput, synthesizer: IAudioSampleSynthesizer, bufferTimeInMilliseconds: number);
156
+ protected onSampleRequest(): void;
124
157
  play(): boolean;
125
158
  private playInternal;
126
159
  pause(): void;
@@ -143,9 +176,9 @@ declare class AlphaSynth implements IAlphaSynth {
143
176
  setChannelSolo(channel: number, solo: boolean): void;
144
177
  setChannelVolume(channel: number, volume: number): void;
145
178
  private onSamplesPlayed;
146
- private checkForFinish;
179
+ protected checkForFinish(): void;
147
180
  private stopOneTimeMidi;
148
- private updateTimePosition;
181
+ protected updateTimePosition(timePosition: number, isSeek: boolean): void;
149
182
  readonly ready: IEventEmitter;
150
183
  readonly readyForPlayback: IEventEmitter;
151
184
  readonly finished: IEventEmitter;
@@ -159,24 +192,7 @@ declare class AlphaSynth implements IAlphaSynth {
159
192
  readonly playbackRangeChanged: IEventEmitterOfT<PlaybackRangeChangedEventArgs>;
160
193
  /* Excluded from this release type: hasSamplesForProgram */
161
194
  /* Excluded from this release type: hasSamplesForPercussion */
162
- }
163
-
164
- /**
165
- * This class implements a HTML5 Web Audio API based audio output device
166
- * for alphaSynth. It can be controlled via a JS API.
167
- * @target web
168
- */
169
- declare class AlphaSynthAudioWorkletOutput extends AlphaSynthWebAudioOutputBase {
170
- private _worklet;
171
- private _bufferTimeInMilliseconds;
172
- private readonly _settings;
173
- constructor(settings: Settings);
174
- open(bufferTimeInMilliseconds: number): void;
175
- play(): void;
176
- private handleMessage;
177
- pause(): void;
178
- addSamples(f: Float32Array): void;
179
- resetSamples(): void;
195
+ loadBackingTrack(_score: Score, _syncPoints: BackingTrackSyncPoint[]): void;
180
196
  }
181
197
 
182
198
  /**
@@ -237,7 +253,6 @@ declare abstract class AlphaSynthWebAudioOutputBase implements ISynthOutput {
237
253
  get sampleRate(): number;
238
254
  activate(resumedCallback?: () => void): void;
239
255
  private patchIosSampleRate;
240
- private createAudioContext;
241
256
  open(bufferTimeInMilliseconds: number): void;
242
257
  private registerResumeHandler;
243
258
  private unregisterResumeHandler;
@@ -252,8 +267,6 @@ declare abstract class AlphaSynthWebAudioOutputBase implements ISynthOutput {
252
267
  protected onSamplesPlayed(numberOfSamples: number): void;
253
268
  protected onSampleRequest(): void;
254
269
  protected onReady(): void;
255
- private checkSinkIdSupport;
256
- private _knownDevices;
257
270
  enumerateOutputDevices(): Promise<ISynthOutputDevice[]>;
258
271
  setOutputDevice(device: ISynthOutputDevice | null): Promise<void>;
259
272
  getOutputDevice(): Promise<ISynthOutputDevice | null>;
@@ -337,6 +350,7 @@ declare class AlphaSynthWebWorkerApi implements IAlphaSynth {
337
350
  onOutputSampleRequest(): void;
338
351
  onOutputSamplesPlayed(samples: number): void;
339
352
  private onOutputReady;
353
+ loadBackingTrack(_score: Score): void;
340
354
  }
341
355
 
342
356
  /**
@@ -456,6 +470,11 @@ export declare class AlphaTabApiBase<TSettings> {
456
470
  private _isDestroyed;
457
471
  private _score;
458
472
  private _tracks;
473
+ private _actualPlayerMode;
474
+ /**
475
+ * The actual player mode which is currently active (e.g. allows determining whether a backing track or the synthesizer is active).
476
+ */
477
+ get actualPlayerMode(): PlayerMode;
459
478
  /**
460
479
  * Gets the UI facade to use for interacting with the user interface.
461
480
  */
@@ -975,9 +994,6 @@ export declare class AlphaTabApiBase<TSettings> {
975
994
  * @since 1.5.0
976
995
  */
977
996
  get boundsLookup(): BoundsLookup | null;
978
- /**
979
- * Gets the alphaSynth player used for playback. This is the low-level API to the Midi synthesizer used for playback.
980
- */
981
997
  /**
982
998
  * The alphaSynth player used for playback.
983
999
  * @remarks
@@ -2952,6 +2968,10 @@ declare class Automation {
2952
2968
  * Gets or sets the target value of the automation.
2953
2969
  */
2954
2970
  value: number;
2971
+ /**
2972
+ * The sync point data in case of {@link AutomationType.SyncPoint}
2973
+ */
2974
+ syncPointValue: SyncPointData | undefined;
2955
2975
  /**
2956
2976
  * Gets or sets the relative position of of the automation.
2957
2977
  */
@@ -2983,7 +3003,43 @@ declare enum AutomationType {
2983
3003
  /**
2984
3004
  * Balance change.
2985
3005
  */
2986
- Balance = 3
3006
+ Balance = 3,
3007
+ /**
3008
+ * A sync point for synchronizing the internal time axis with an external audio track.
3009
+ */
3010
+ SyncPoint = 4
3011
+ }
3012
+
3013
+ /**
3014
+ * Holds information about the backing track which can be played instead of synthesized audio.
3015
+ * @json
3016
+ * @json_strict
3017
+ */
3018
+ declare class BackingTrack {
3019
+ /**
3020
+ * The data of the raw audio file to be used for playback.
3021
+ * @json_ignore
3022
+ */
3023
+ rawAudioFile: Uint8Array | undefined;
3024
+ /**
3025
+ * The number of milliseconds the audio should be shifted to align with the song.
3026
+ * (e.g. negative values allow skipping potential silent parts at the start of the file and directly start with the first note).
3027
+ */
3028
+ padding: number;
3029
+ }
3030
+
3031
+ /**
3032
+ * Rerpresents a point to sync the alphaTab time axis with an external backing track.
3033
+ */
3034
+ declare class BackingTrackSyncPoint {
3035
+ tick: number;
3036
+ data: SyncPointData;
3037
+ constructor(tick: number, data: SyncPointData);
3038
+ }
3039
+
3040
+ declare class BackingTrackSyncPointWithTime extends BackingTrackSyncPoint {
3041
+ time: number;
3042
+ constructor(tick: number, data: SyncPointData, time: number);
2987
3043
  }
2988
3044
 
2989
3045
  /**
@@ -6656,6 +6712,116 @@ declare class HeaderFooterStyle {
6656
6712
  private static readonly PlaceholderPattern;
6657
6713
  }
6658
6714
 
6715
+ declare class Hydra {
6716
+ phdrs: HydraPhdr[];
6717
+ pbags: HydraPbag[];
6718
+ pmods: HydraPmod[];
6719
+ pgens: HydraPgen[];
6720
+ insts: HydraInst[];
6721
+ ibags: HydraIbag[];
6722
+ imods: HydraImod[];
6723
+ igens: HydraIgen[];
6724
+ sHdrs: HydraShdr[];
6725
+ sampleData: Uint8Array;
6726
+ private _sampleCache;
6727
+ decodeSamples(startByte: number, endByte: number, decompressVorbis: boolean): Float32Array;
6728
+ load(readable: IReadable): void;
6729
+ }
6730
+
6731
+ declare class HydraGenAmount {
6732
+ wordAmount: number;
6733
+ get shortAmount(): number;
6734
+ get lowByteAmount(): number;
6735
+ get highByteAmount(): number;
6736
+ constructor(reader: IReadable);
6737
+ }
6738
+
6739
+ declare class HydraIbag {
6740
+ static readonly SizeInFile: number;
6741
+ instGenNdx: number;
6742
+ instModNdx: number;
6743
+ constructor(reader: IReadable);
6744
+ }
6745
+
6746
+ declare class HydraIgen {
6747
+ static readonly SizeInFile: number;
6748
+ genOper: number;
6749
+ genAmount: HydraGenAmount;
6750
+ constructor(reader: IReadable);
6751
+ }
6752
+
6753
+ declare class HydraImod {
6754
+ static readonly SizeInFile: number;
6755
+ modSrcOper: number;
6756
+ modDestOper: number;
6757
+ modAmount: number;
6758
+ modAmtSrcOper: number;
6759
+ modTransOper: number;
6760
+ constructor(reader: IReadable);
6761
+ }
6762
+
6763
+ declare class HydraInst {
6764
+ static readonly SizeInFile: number;
6765
+ instName: string;
6766
+ instBagNdx: number;
6767
+ constructor(reader: IReadable);
6768
+ }
6769
+
6770
+ declare class HydraPbag {
6771
+ static readonly SizeInFile: number;
6772
+ genNdx: number;
6773
+ modNdx: number;
6774
+ constructor(reader: IReadable);
6775
+ }
6776
+
6777
+ declare class HydraPgen {
6778
+ static readonly SizeInFile: number;
6779
+ static readonly GenInstrument: number;
6780
+ static readonly GenKeyRange: number;
6781
+ static readonly GenVelRange: number;
6782
+ static readonly GenSampleId: number;
6783
+ genOper: number;
6784
+ genAmount: HydraGenAmount;
6785
+ constructor(reader: IReadable);
6786
+ }
6787
+
6788
+ declare class HydraPhdr {
6789
+ static readonly SizeInFile: number;
6790
+ presetName: string;
6791
+ preset: number;
6792
+ bank: number;
6793
+ presetBagNdx: number;
6794
+ library: number;
6795
+ genre: number;
6796
+ morphology: number;
6797
+ constructor(reader: IReadable);
6798
+ }
6799
+
6800
+ declare class HydraPmod {
6801
+ static readonly SizeInFile: number;
6802
+ modSrcOper: number;
6803
+ modDestOper: number;
6804
+ modAmount: number;
6805
+ modAmtSrcOper: number;
6806
+ modTransOper: number;
6807
+ constructor(reader: IReadable);
6808
+ }
6809
+
6810
+ declare class HydraShdr {
6811
+ static readonly SizeInFile: number;
6812
+ sampleName: string;
6813
+ start: number;
6814
+ end: number;
6815
+ startLoop: number;
6816
+ endLoop: number;
6817
+ sampleRate: number;
6818
+ originalPitch: number;
6819
+ pitchCorrection: number;
6820
+ sampleLink: number;
6821
+ sampleType: number;
6822
+ constructor(reader: IReadable);
6823
+ }
6824
+
6659
6825
  /**
6660
6826
  * The public API interface for interacting with the synthesizer.
6661
6827
  */
@@ -6760,6 +6926,11 @@ declare interface IAlphaSynth {
6760
6926
  * @param midi
6761
6927
  */
6762
6928
  loadMidiFile(midi: MidiFile): void;
6929
+ /**
6930
+ * Loads the synchronization information from the given score (used for backing tracks and external media).
6931
+ * @param score
6932
+ */
6933
+ loadBackingTrack(score: Score, syncPoints: BackingTrackSyncPoint[]): void;
6763
6934
  /**
6764
6935
  * Applies the given transposition pitches to be used during playback.
6765
6936
  * @param transpositionPitches a map defining the transposition pitches for midi channel.
@@ -6849,6 +7020,176 @@ declare interface IAlphaSynth {
6849
7020
  readonly playbackRangeChanged: IEventEmitterOfT<PlaybackRangeChangedEventArgs>;
6850
7021
  }
6851
7022
 
7023
+ /**
7024
+ * A {@link IBackingTrackSynthOutput} which uses a HTMLAudioElement as playback mechanism.
7025
+ * Allows the access to the element for further custom usage.
7026
+ * @target web
7027
+ */
7028
+ declare interface IAudioElementBackingTrackSynthOutput extends IBackingTrackSynthOutput {
7029
+ /**
7030
+ * The audio element used for playing the backing track.
7031
+ * @remarks
7032
+ * Direct interaction with the element might not result in correct alphaTab behavior.
7033
+ */
7034
+ readonly audioElement: HTMLAudioElement;
7035
+ }
7036
+
7037
+ /**
7038
+ * Classes implementing this interface can act as main audio synthesis engine
7039
+ * within alphaSynth.
7040
+ */
7041
+ declare interface IAudioSampleSynthesizer {
7042
+ /**
7043
+ * The master volume to produce.
7044
+ */
7045
+ masterVolume: number;
7046
+ /**
7047
+ * The volume of metronome ticks.
7048
+ */
7049
+ metronomeVolume: number;
7050
+ /**
7051
+ * The output sample rate which is produced.
7052
+ */
7053
+ readonly outSampleRate: number;
7054
+ /**
7055
+ * The current tempo according to the processed midi events (used for metronome event generation)
7056
+ */
7057
+ readonly currentTempo: number;
7058
+ /**
7059
+ * The current time signature numerator according to the processed midi events (used for metronome event generation)
7060
+ */
7061
+ readonly timeSignatureNumerator: number;
7062
+ /**
7063
+ * The current time signature denominator according to the processed midi events (used for metronome event generation)
7064
+ */
7065
+ readonly timeSignatureDenominator: number;
7066
+ /**
7067
+ * The number of voices which are currently active in the syntheiszer and still producing audio.
7068
+ */
7069
+ readonly activeVoiceCount: number;
7070
+ /**
7071
+ * Ensures for all active notes a note-off is issued to stop playing the keys.
7072
+ * @param immediate Whether the stop should happen immediately or with sustain->release.
7073
+ */
7074
+ noteOffAll(immediate: boolean): void;
7075
+ /**
7076
+ * Stop all playing notes immediatly and reset all channel parameters but keeps user
7077
+ * defined settings
7078
+ */
7079
+ resetSoft(): void;
7080
+ /**
7081
+ * Resets all loaded presets.
7082
+ */
7083
+ resetPresets(): void;
7084
+ /**
7085
+ * Loads the presets from the given SoundFont hydra structure.
7086
+ * @param hydra The SoundFont hydra structure.
7087
+ * @param instrumentPrograms The used instrument programs to load the samples for.
7088
+ * @param percussionKeys The instrument keys used.
7089
+ * @param append Whether the presets should be appended or whether they should replace all loaded ones.
7090
+ */
7091
+ loadPresets(hydra: Hydra, instrumentPrograms: Set<number>, percussionKeys: Set<number>, append: boolean): void;
7092
+ /**
7093
+ * Configures the channel used to generate metronome sounds.
7094
+ * @param metronomeVolume The volume for the channel.
7095
+ */
7096
+ setupMetronomeChannel(metronomeVolume: number): void;
7097
+ /**
7098
+ * Synthesizes the given number of samples without producing an output (e.g. on seeking)
7099
+ * @param sampleCount The number of samples to synthesize.
7100
+ */
7101
+ synthesizeSilent(sampleCount: number): void;
7102
+ /**
7103
+ * Processes the given synth event.
7104
+ * @param synthEvent The synth event.
7105
+ */
7106
+ dispatchEvent(synthEvent: SynthEvent): void;
7107
+ /**
7108
+ * Synthesizes the given number of samples into the provided output buffer.
7109
+ * @param buffer The buffer to fill.
7110
+ * @param bufferPos The offset in the buffer to start writing into.
7111
+ * @param sampleCount The number of samples to synthesize.
7112
+ */
7113
+ synthesize(buffer: Float32Array, bufferPos: number, sampleCount: number): SynthEvent[];
7114
+ /**
7115
+ * Applies the given transposition pitches used for general pitch changes that should be applied to the song.
7116
+ * Used for general transpositions applied to the file.
7117
+ * @param transpositionPitches A map defining for a given list of midi channels the number of semitones that should be adjusted.
7118
+ */
7119
+ applyTranspositionPitches(transpositionPitches: Map<number, number>): void;
7120
+ /**
7121
+ * Sets the transposition pitch of a given channel. This pitch is additionally applied beside the
7122
+ * ones applied already via {@link applyTranspositionPitches}.
7123
+ * @param channel The channel number
7124
+ * @param semitones The number of semitones to apply as pitch offset.
7125
+ */
7126
+ setChannelTranspositionPitch(channel: number, semitones: number): void;
7127
+ /**
7128
+ * Sets the mute state of a channel.
7129
+ * @param channel The channel number
7130
+ * @param mute true if the channel should be muted, otherwise false.
7131
+ */
7132
+ channelSetMute(channel: number, mute: boolean): void;
7133
+ /**
7134
+ * Gets the solo state of a channel.
7135
+ * @param channel The channel number
7136
+ * @param solo true if the channel should be played solo, otherwise false.
7137
+ */
7138
+ channelSetSolo(channel: number, solo: boolean): void;
7139
+ /**
7140
+ * Resets the mute/solo state of all channels
7141
+ */
7142
+ resetChannelStates(): void;
7143
+ /**
7144
+ * Gets or sets the current and initial volume of the given channel.
7145
+ * @param channel The channel number.
7146
+ * @param volume The volume of of the channel (0.0-1.0)
7147
+ */
7148
+ channelSetMixVolume(channel: number, volume: number): void;
7149
+ /**
7150
+ * Checks whether the synth has loaded the samples for a given midi program.
7151
+ * @param program The program to check.
7152
+ */
7153
+ hasSamplesForProgram(program: number): boolean;
7154
+ /**
7155
+ * Checks whether the synth has loaded the samples for a given percussion key.
7156
+ * @param key The midi key defining the percussion instrument.
7157
+ */
7158
+ hasSamplesForPercussion(key: number): boolean;
7159
+ }
7160
+
7161
+ /**
7162
+ * A synth output for playing backing tracks.
7163
+ */
7164
+ declare interface IBackingTrackSynthOutput extends ISynthOutput {
7165
+ /**
7166
+ * An event fired when the playback time changes. The time is in absolute milliseconds.
7167
+ */
7168
+ readonly timeUpdate: IEventEmitterOfT<number>;
7169
+ /**
7170
+ * The total duration of the backing track in milliseconds.
7171
+ */
7172
+ readonly backingTrackDuration: number;
7173
+ /**
7174
+ * The playback rate at which the output should playback.
7175
+ */
7176
+ playbackRate: number;
7177
+ /**
7178
+ * The volume at which the output should play (0-1)
7179
+ */
7180
+ masterVolume: number;
7181
+ /**
7182
+ * Instructs the output to seek to the given time position.
7183
+ * @param time The absolute time in milliseconds.
7184
+ */
7185
+ seekTo(time: number): void;
7186
+ /**
7187
+ * Instructs the output to load the given backing track.
7188
+ * @param backingTrack The backing track to load.
7189
+ */
7190
+ loadBackingTrack(backingTrack: BackingTrack): void;
7191
+ }
7192
+
6852
7193
  /**
6853
7194
  * This is the base public interface for canvas implementations on different plattforms.
6854
7195
  */
@@ -7664,10 +8005,15 @@ declare interface IUiFacade<TSettings> {
7664
8005
  */
7665
8006
  createWorkerRenderer(): IScoreRenderer;
7666
8007
  /**
7667
- * Tells the UI layer to create a player worker.
8008
+ * Tells the UI layer to create a player worker for the synthesizer.
7668
8009
  * @returns
7669
8010
  */
7670
8011
  createWorkerPlayer(): IAlphaSynth | null;
8012
+ /**
8013
+ * Tells the UI layer to create a player which can play backing tracks.
8014
+ * @returns
8015
+ */
8016
+ createBackingTrackPlayer(): IAlphaSynth | null;
7671
8017
  /**
7672
8018
  * Creates the cursor objects that are used to highlight the currently played beats and bars.
7673
8019
  * @returns
@@ -8164,6 +8510,12 @@ declare class MasterBar {
8164
8510
  * Gets or sets all tempo automation for this bar.
8165
8511
  */
8166
8512
  tempoAutomations: Automation[];
8513
+ /**
8514
+ * The sync points for this master bar to synchronize the alphaTab time axis with the
8515
+ * external backing track audio.
8516
+ * @json_add addSyncPoint
8517
+ */
8518
+ syncPoints: Automation[] | undefined;
8167
8519
  /**
8168
8520
  * Gets or sets the reference to the score this song belongs to.
8169
8521
  * @json_ignore
@@ -8216,6 +8568,11 @@ declare class MasterBar {
8216
8568
  * @returns
8217
8569
  */
8218
8570
  getFermata(beat: Beat): Fermata | null;
8571
+ /**
8572
+ * Adds the given sync point to the list of sync points for this bar.
8573
+ * @param syncPoint The sync point to add.
8574
+ */
8575
+ addSyncPoint(syncPoint: Automation): void;
8219
8576
  }
8220
8577
 
8221
8578
  /**
@@ -8654,6 +9011,10 @@ declare class MidiFileGenerator {
8654
9011
  * Gets or sets whether transposition pitches should be applied to the individual midi events or not.
8655
9012
  */
8656
9013
  applyTranspositionPitches: boolean;
9014
+ /**
9015
+ * The computed sync points for synchronizing the midi file with an external backing track.
9016
+ */
9017
+ syncPoints: BackingTrackSyncPoint[];
8657
9018
  /**
8658
9019
  * Gets the transposition pitches for the individual midi channels.
8659
9020
  */
@@ -8750,6 +9111,91 @@ declare class MidiFileGenerator {
8750
9111
  generateSingleNote(note: Note): void;
8751
9112
  }
8752
9113
 
9114
+ /**
9115
+ * This sequencer dispatches midi events to the synthesizer based on the current
9116
+ * synthesize position. The sequencer does not consider the playback speed.
9117
+ */
9118
+ declare class MidiFileSequencer {
9119
+ private _synthesizer;
9120
+ private _currentState;
9121
+ private _mainState;
9122
+ private _oneTimeState;
9123
+ private _countInState;
9124
+ get isPlayingMain(): boolean;
9125
+ get isPlayingOneTimeMidi(): boolean;
9126
+ get isPlayingCountIn(): boolean;
9127
+ constructor(synthesizer: IAudioSampleSynthesizer);
9128
+ get mainPlaybackRange(): PlaybackRange | null;
9129
+ set mainPlaybackRange(value: PlaybackRange | null);
9130
+ isLooping: boolean;
9131
+ get currentTime(): number;
9132
+ /**
9133
+ * Gets the duration of the song in ticks.
9134
+ */
9135
+ get currentEndTick(): number;
9136
+ get currentEndTime(): number;
9137
+ get currentTempo(): number;
9138
+ get modifiedTempo(): number;
9139
+ /**
9140
+ * Gets or sets the playback speed.
9141
+ */
9142
+ playbackSpeed: number;
9143
+ mainSeek(timePosition: number): void;
9144
+ private mainSilentProcess;
9145
+ loadOneTimeMidi(midiFile: MidiFile): void;
9146
+ instrumentPrograms: Set<number>;
9147
+ percussionKeys: Set<number>;
9148
+ loadMidi(midiFile: MidiFile): void;
9149
+ createStateFromFile(midiFile: MidiFile): MidiSequencerState;
9150
+ fillMidiEventQueue(): boolean;
9151
+ fillMidiEventQueueToEndTime(endTime: number): boolean;
9152
+ private fillMidiEventQueueLimited;
9153
+ mainTickPositionToTimePosition(tickPosition: number): number;
9154
+ mainTimePositionToTickPosition(timePosition: number): number;
9155
+ mainUpdateSyncPoints(syncPoints: BackingTrackSyncPoint[]): void;
9156
+ currentTimePositionToTickPosition(timePosition: number): number;
9157
+ mainTimePositionFromBackingTrack(timePosition: number, backingTrackLength: number): number;
9158
+ mainTimePositionToBackingTrack(timePosition: number, backingTrackLength: number): number;
9159
+ private tickPositionToTimePositionWithSpeed;
9160
+ private timePositionToTickPositionWithSpeed;
9161
+ private get internalEndTime();
9162
+ get isFinished(): boolean;
9163
+ stop(): void;
9164
+ resetOneTimeMidi(): void;
9165
+ resetCountIn(): void;
9166
+ startCountIn(): void;
9167
+ generateCountInMidi(): void;
9168
+ }
9169
+
9170
+ declare class MidiFileSequencerTempoChange {
9171
+ bpm: number;
9172
+ ticks: number;
9173
+ time: number;
9174
+ constructor(bpm: number, ticks: number, time: number);
9175
+ }
9176
+
9177
+ declare class MidiSequencerState {
9178
+ tempoChanges: MidiFileSequencerTempoChange[];
9179
+ tempoChangeIndex: number;
9180
+ syncPoints: BackingTrackSyncPointWithTime[];
9181
+ firstProgramEventPerChannel: Map<number, SynthEvent>;
9182
+ firstTimeSignatureNumerator: number;
9183
+ firstTimeSignatureDenominator: number;
9184
+ synthData: SynthEvent[];
9185
+ division: number;
9186
+ eventIndex: number;
9187
+ currentTime: number;
9188
+ currentTick: number;
9189
+ syncPointIndex: number;
9190
+ playbackRange: PlaybackRange | null;
9191
+ playbackRangeStartTime: number;
9192
+ playbackRangeEndTime: number;
9193
+ endTick: number;
9194
+ endTime: number;
9195
+ currentTempo: number;
9196
+ modifiedTempo: number;
9197
+ }
9198
+
8753
9199
  /**
8754
9200
  * This class holds all information about when {@link MasterBar}s and {@link Beat}s are played.
8755
9201
  *
@@ -8927,6 +9373,7 @@ export declare namespace model {
8927
9373
  AccidentalType,
8928
9374
  AutomationType,
8929
9375
  Automation,
9376
+ SyncPointData,
8930
9377
  Bar,
8931
9378
  SustainPedalMarkerType,
8932
9379
  SustainPedalMarker,
@@ -9003,7 +9450,8 @@ export declare namespace model {
9003
9450
  VoiceStyle,
9004
9451
  WahPedal,
9005
9452
  WhammyType,
9006
- ElementStyle
9453
+ ElementStyle,
9454
+ BackingTrack
9007
9455
  }
9008
9456
  }
9009
9457
 
@@ -10715,6 +11163,35 @@ declare class PlaybackRangeChangedEventArgs {
10715
11163
  constructor(playbackRange: PlaybackRange | null);
10716
11164
  }
10717
11165
 
11166
+ /**
11167
+ * Lists the different modes how the internal alphaTab player (and related cursor behavior) is working.
11168
+ */
11169
+ export declare enum PlayerMode {
11170
+ /**
11171
+ * The player functionality is fully disabled.
11172
+ */
11173
+ Disabled = 0,
11174
+ /**
11175
+ * The player functionality is enabled.
11176
+ * If the loaded file provides a backing track, it is used for playback.
11177
+ * If no backing track is provided, the midi synthesizer is used.
11178
+ */
11179
+ EnabledAutomatic = 1,
11180
+ /**
11181
+ * The player functionality is enabled and the synthesizer is used (even if a backing track is embedded in the file).
11182
+ */
11183
+ EnabledSynthesizer = 2,
11184
+ /**
11185
+ * The player functionality is enabled. If the input data model has no backing track configured, the player might not work as expected (as playback completes instantly).
11186
+ */
11187
+ EnabledBackingTrack = 3,
11188
+ /**
11189
+ * The player functionality is enabled and an external audio/video source is used as time axis.
11190
+ * The related player APIs need to be used to update the current position of the external audio source within alphaTab.
11191
+ */
11192
+ EnabledExternalMedia = 4
11193
+ }
11194
+
10718
11195
  /**
10719
11196
  * Lists the different modes how alphaTab will play the generated audio.
10720
11197
  * @target web
@@ -10776,6 +11253,7 @@ export declare class PlayerSettings {
10776
11253
  * @since 0.9.6
10777
11254
  * @defaultValue `false`
10778
11255
  * @category Player
11256
+ * @deprecated Use {@link playerMode} instead.
10779
11257
  * @remarks
10780
11258
  * This setting configures whether the player feature is enabled or not. Depending on the platform enabling the player needs some additional actions of the developer.
10781
11259
  * For the JavaScript version the [player.soundFont](/docs/reference/settings/player/soundfont) property must be set to the URL of the sound font that should be used or it must be loaded manually via API.
@@ -10784,6 +11262,37 @@ export declare class PlayerSettings {
10784
11262
  * AlphaTab does not ship a default UI for the player. The API must be hooked up to some UI controls to allow the user to interact with the player.
10785
11263
  */
10786
11264
  enablePlayer: boolean;
11265
+ /**
11266
+ * Whether the player should be enabled and which mode it should use.
11267
+ * @since 1.6.0
11268
+ * @defaultValue `PlayerMode.Disabled`
11269
+ * @category Player
11270
+ * @remarks
11271
+ * This setting configures whether the player feature is enabled or not. Depending on the platform enabling the player needs some additional actions of the developer.
11272
+ *
11273
+ * **Synthesizer**
11274
+ *
11275
+ * If the synthesizer is used (via {@link PlayerMode.EnabledAutomatic} or {@link PlayerMode.EnabledSynthesizer}) a sound font is needed so that the midi synthesizer can produce the audio samples.
11276
+ *
11277
+ * For the JavaScript version the [player.soundFont](/docs/reference/settings/player/soundfont) property must be set to the URL of the sound font that should be used or it must be loaded manually via API.
11278
+ * For .net manually the soundfont must be loaded.
11279
+ *
11280
+ * **Backing Track**
11281
+ *
11282
+ * For a built-in backing track of the input file no additional data needs to be loaded (assuming everything is filled via the input file).
11283
+ * Otherwise the `score.backingTrack` needs to be filled before loading and the related sync points need to be configured.
11284
+ *
11285
+ * **External Media**
11286
+ *
11287
+ * For synchronizing alphaTab with an external media no data needs to be loaded into alphaTab. The configured sync points on the MasterBars are used
11288
+ * as reference to synchronize the external media with the internal time axis. Then the related APIs on the AlphaTabApi object need to be used
11289
+ * to update the playback state and exterrnal audio position during playback.
11290
+ *
11291
+ * **User Interface**
11292
+ *
11293
+ * AlphaTab does not ship a default UI for the player. The API must be hooked up to some UI controls to allow the user to interact with the player.
11294
+ */
11295
+ playerMode: PlayerMode;
10787
11296
  /**
10788
11297
  * Whether playback cursors should be displayed.
10789
11298
  * @since 0.9.6
@@ -11015,6 +11524,7 @@ declare interface PlayerSettingsJson {
11015
11524
  * @since 0.9.6
11016
11525
  * @defaultValue `false`
11017
11526
  * @category Player
11527
+ * @deprecated Use {@link playerMode} instead.
11018
11528
  * @remarks
11019
11529
  * This setting configures whether the player feature is enabled or not. Depending on the platform enabling the player needs some additional actions of the developer.
11020
11530
  * For the JavaScript version the [player.soundFont](/docs/reference/settings/player/soundfont) property must be set to the URL of the sound font that should be used or it must be loaded manually via API.
@@ -11023,6 +11533,37 @@ declare interface PlayerSettingsJson {
11023
11533
  * AlphaTab does not ship a default UI for the player. The API must be hooked up to some UI controls to allow the user to interact with the player.
11024
11534
  */
11025
11535
  enablePlayer?: boolean;
11536
+ /**
11537
+ * Whether the player should be enabled and which mode it should use.
11538
+ * @since 1.6.0
11539
+ * @defaultValue `PlayerMode.Disabled`
11540
+ * @category Player
11541
+ * @remarks
11542
+ * This setting configures whether the player feature is enabled or not. Depending on the platform enabling the player needs some additional actions of the developer.
11543
+ *
11544
+ * **Synthesizer**
11545
+ *
11546
+ * If the synthesizer is used (via {@link PlayerMode.EnabledAutomatic} or {@link PlayerMode.EnabledSynthesizer}) a sound font is needed so that the midi synthesizer can produce the audio samples.
11547
+ *
11548
+ * For the JavaScript version the [player.soundFont](/docs/reference/settings/player/soundfont) property must be set to the URL of the sound font that should be used or it must be loaded manually via API.
11549
+ * For .net manually the soundfont must be loaded.
11550
+ *
11551
+ * **Backing Track**
11552
+ *
11553
+ * For a built-in backing track of the input file no additional data needs to be loaded (assuming everything is filled via the input file).
11554
+ * Otherwise the `score.backingTrack` needs to be filled before loading and the related sync points need to be configured.
11555
+ *
11556
+ * **External Media**
11557
+ *
11558
+ * For synchronizing alphaTab with an external media no data needs to be loaded into alphaTab. The configured sync points on the MasterBars are used
11559
+ * as reference to synchronize the external media with the internal time axis. Then the related APIs on the AlphaTabApi object need to be used
11560
+ * to update the playback state and exterrnal audio position during playback.
11561
+ *
11562
+ * **User Interface**
11563
+ *
11564
+ * AlphaTab does not ship a default UI for the player. The API must be hooked up to some UI controls to allow the user to interact with the player.
11565
+ */
11566
+ playerMode?: PlayerMode | keyof typeof PlayerMode | Lowercase<keyof typeof PlayerMode>;
11026
11567
  /**
11027
11568
  * Whether playback cursors should be displayed.
11028
11569
  * @since 0.9.6
@@ -11267,6 +11808,14 @@ declare class PositionChangedEventArgs {
11267
11808
  * @since 1.2.0
11268
11809
  */
11269
11810
  isSeek: boolean;
11811
+ /**
11812
+ * The original tempo in which alphaTab internally would be playing right now.
11813
+ */
11814
+ originalTempo: number;
11815
+ /**
11816
+ * The modified tempo in which the actual playback is happening (e.g. due to playback speed or external audio synchronization)
11817
+ */
11818
+ modifiedTempo: number;
11270
11819
  /**
11271
11820
  * Initializes a new instance of the {@link PositionChangedEventArgs} class.
11272
11821
  * @param currentTime The current time.
@@ -11275,7 +11824,7 @@ declare class PositionChangedEventArgs {
11275
11824
  * @param endTick The end tick.
11276
11825
  * @param isSeek Whether the time was seeked.
11277
11826
  */
11278
- constructor(currentTime: number, endTime: number, currentTick: number, endTick: number, isSeek: boolean);
11827
+ constructor(currentTime: number, endTime: number, currentTick: number, endTick: number, isSeek: boolean, originalTempo: number, modifiedTempo: number);
11279
11828
  }
11280
11829
 
11281
11830
  /**
@@ -11315,6 +11864,16 @@ export declare class ProgressEventArgs {
11315
11864
  constructor(loaded: number, total: number);
11316
11865
  }
11317
11866
 
11867
+ declare class Queue<T> {
11868
+ private _head?;
11869
+ private _tail?;
11870
+ get isEmpty(): boolean;
11871
+ clear(): void;
11872
+ enqueue(item: T): void;
11873
+ peek(): T | undefined;
11874
+ dequeue(): T | undefined;
11875
+ }
11876
+
11318
11877
  /**
11319
11878
  * Lists all Rasgueado types.
11320
11879
  */
@@ -11997,6 +12556,10 @@ declare class Score {
11997
12556
  * Gets or sets the rendering stylesheet for this song.
11998
12557
  */
11999
12558
  stylesheet: RenderStylesheet;
12559
+ /**
12560
+ * Information about the backing track that can be used instead of the synthesized audio.
12561
+ */
12562
+ backingTrack: BackingTrack | undefined;
12000
12563
  /**
12001
12564
  * The style customizations for this item.
12002
12565
  */
@@ -12826,6 +13389,31 @@ declare abstract class SvgCanvas implements ICanvas {
12826
13389
  endRotate(): void;
12827
13390
  }
12828
13391
 
13392
+ /**
13393
+ * Represents the data of a sync point for synchronizing the internal time axis with
13394
+ * an external audio file.
13395
+ * @cloneable
13396
+ * @json
13397
+ * @json_strict
13398
+ */
13399
+ declare class SyncPointData {
13400
+ /**
13401
+ * Indicates for which repeat occurence this sync point is valid (e.g. 0 on the first time played, 1 on the second time played)
13402
+ */
13403
+ barOccurence: number;
13404
+ /**
13405
+ * The modified tempo at which the cursor should move (aka. the tempo played within the external audio track).
13406
+ * This information is used together with the {@link originalTempo} to calculate how much faster/slower the
13407
+ * cursor playback is performed to align with the audio track.
13408
+ */
13409
+ modifiedTempo: number;
13410
+ /**
13411
+ * The uadio offset marking the position within the audio track in milliseconds.
13412
+ * This information is used to regularly sync (or on seeking) to match a given external audio time axis with the internal time axis.
13413
+ */
13414
+ millisecondOffset: number;
13415
+ }
13416
+
12829
13417
  export declare namespace synth {
12830
13418
  export {
12831
13419
  AlphaSynth,
@@ -12833,6 +13421,7 @@ export declare namespace synth {
12833
13421
  PlaybackRange,
12834
13422
  ISynthOutput,
12835
13423
  ISynthOutputDevice,
13424
+ IBackingTrackSynthOutput,
12836
13425
  IAlphaSynth,
12837
13426
  PlayerState,
12838
13427
  PlayerStateChangedEventArgs,
@@ -12843,10 +13432,20 @@ export declare namespace synth {
12843
13432
  AlphaSynthWebWorkerApi,
12844
13433
  AlphaSynthWebAudioOutputBase,
12845
13434
  AlphaSynthScriptProcessorOutput,
12846
- AlphaSynthAudioWorkletOutput
13435
+ AlphaSynthAudioWorkletOutput,
13436
+ IAudioElementBackingTrackSynthOutput
12847
13437
  }
12848
13438
  }
12849
13439
 
13440
+ declare class SynthEvent {
13441
+ eventIndex: number;
13442
+ event: MidiEvent;
13443
+ readonly isMetronome: boolean;
13444
+ time: number;
13445
+ constructor(eventIndex: number, e: MidiEvent);
13446
+ static newMetronomeEvent(eventIndex: number, tick: number, counter: number, durationInTicks: number, durationInMillis: number): SynthEvent;
13447
+ }
13448
+
12850
13449
  declare abstract class SystemBracket {
12851
13450
  firstStaffInBracket: RenderStaff | null;
12852
13451
  lastStaffInBracket: RenderStaff | null;
@@ -12934,7 +13533,15 @@ declare class TempoChangeEvent extends MidiEvent {
12934
13533
  /**
12935
13534
  * The tempo in microseconds per quarter note (aka USQ). A time format typically for midi.
12936
13535
  */
12937
- microSecondsPerQuarterNote: number;
13536
+ get microSecondsPerQuarterNote(): number;
13537
+ /**
13538
+ * The tempo in microseconds per quarter note (aka USQ). A time format typically for midi.
13539
+ */
13540
+ set microSecondsPerQuarterNote(value: number);
13541
+ /**
13542
+ * The tempo in beats per minute
13543
+ */
13544
+ beatsPerMinute: number;
12938
13545
  constructor(tick: number, microSecondsPerQuarterNote: number);
12939
13546
  writeTo(s: IWriteable): void;
12940
13547
  }