@coderline/alphatab 1.6.0-alpha.1444 → 1.6.0-alpha.1449

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.
@@ -83,6 +83,16 @@ declare class AlphaSynth extends AlphaSynthBase {
83
83
  * @param output The output to use for playing the generated samples.
84
84
  */
85
85
  constructor(output: ISynthOutput, bufferTimeInMilliseconds: number);
86
+ /**
87
+ * Creates a new audio exporter, initialized with the given data.
88
+ * @param options The export options to use.
89
+ * The track volume and transposition pitches must lists must be filled with midi channels.
90
+ * @param midi The midi file to use.
91
+ * @param syncPoints The sync points to use
92
+ * @param transpositionPitches The initial transposition pitches to apply.
93
+ * @param transpositionPitches The initial transposition pitches to apply.
94
+ */
95
+ exportAudio(options: AudioExportOptions, midi: MidiFile, syncPoints: BackingTrackSyncPoint[], mainTranspositionPitches: Map<number, number>): IAlphaSynthAudioExporter;
86
96
  }
87
97
 
88
98
  /**
@@ -298,6 +308,7 @@ declare class AlphaSynthWebWorkerApi implements IAlphaSynth {
298
308
  get isReadyForPlayback(): boolean;
299
309
  get state(): PlayerState;
300
310
  get logLevel(): LogLevel;
311
+ get worker(): Worker;
301
312
  set logLevel(value: LogLevel);
302
313
  get masterVolume(): number;
303
314
  set masterVolume(value: number);
@@ -2949,6 +2960,20 @@ export declare class AlphaTabApiBase<TSettings> {
2949
2960
  *
2950
2961
  */
2951
2962
  getOutputDevice(): Promise<ISynthOutputDevice | null>;
2963
+ /**
2964
+ * Starts the audio export for the currently loaded song.
2965
+ * @remarks
2966
+ * This will not export or use any backing track media but will always use the synthesizer to generate the output.
2967
+ * This method works with any PlayerMode active but changing the mode during export can lead to unexpected side effects.
2968
+ *
2969
+ * See [Audio Export](https://www.alphatab.net/docs/guides/audio-export) for further guidance how to use this feature.
2970
+ *
2971
+ * @param options The export options.
2972
+ * @category Methods - Player
2973
+ * @since 1.6.0
2974
+ * @returns An exporter instance to export the audio in a streaming fashion.
2975
+ */
2976
+ exportAudio(options: AudioExportOptions): Promise<IAudioExporter>;
2952
2977
  }
2953
2978
 
2954
2979
  export declare class AlphaTabError extends Error {
@@ -3164,6 +3189,94 @@ declare class AlphaTexImporter extends ScoreImporter {
3164
3189
  private parseWhammyType;
3165
3190
  }
3166
3191
 
3192
+ /**
3193
+ * Represents a single chunk of audio produced.
3194
+ */
3195
+ declare class AudioExportChunk {
3196
+ /**
3197
+ * The generated samples for the requested chunk.
3198
+ */
3199
+ samples: Float32Array;
3200
+ /**
3201
+ * The current time position within the song in milliseconds.
3202
+ */
3203
+ currentTime: number;
3204
+ /**
3205
+ * The total length of the song in milliseconds.
3206
+ */
3207
+ endTime: number;
3208
+ /**
3209
+ * The current time position within the song in midi ticks.
3210
+ */
3211
+ currentTick: number;
3212
+ /**
3213
+ * The total length of the song in midi ticks.
3214
+ */
3215
+ endTick: number;
3216
+ }
3217
+
3218
+ /**
3219
+ * The options controlling how to export the audio.
3220
+ */
3221
+ declare class AudioExportOptions {
3222
+ /**
3223
+ * The soundfonts to load and use for generating the audio.
3224
+ * If not provided, the already loaded soundfonts of the synthesizer will be used.
3225
+ * If no existing synthesizer is initialized, the generated audio might not contain any hearable audio.
3226
+ */
3227
+ soundFonts?: Uint8Array[];
3228
+ /**
3229
+ * The output sample rate.
3230
+ * @default `44100`
3231
+ */
3232
+ sampleRate: number;
3233
+ /**
3234
+ * Whether to respect sync point information during export.
3235
+ * @default `true`
3236
+ * @remarks
3237
+ * If the song contains sync point information for synchronization with an external media,
3238
+ * this option allows controlling whether the synthesized audio is aligned with these points.
3239
+ *
3240
+ * This is useful when mixing the exported audio together with external media, keeping the same timing.
3241
+ *
3242
+ * Disable this option if you want the original/exact timing as per music sheet in the exported audio.
3243
+ */
3244
+ useSyncPoints: boolean;
3245
+ /**
3246
+ * The current master volume as percentage. (range: 0.0-3.0, default 1.0)
3247
+ */
3248
+ masterVolume: number;
3249
+ /**
3250
+ * The metronome volume. (range: 0.0-3.0, default 0.0)
3251
+ */
3252
+ metronomeVolume: number;
3253
+ /**
3254
+ * The range of the song that should be exported. Set this to null
3255
+ * to play the whole song.
3256
+ */
3257
+ playbackRange?: PlaybackRange;
3258
+ /**
3259
+ * The volume for individual tracks as percentage (range: 0.0-3.0).
3260
+ * @remarks
3261
+ * The key is the track index, and the value is the relative volume.
3262
+ * The configured volume (as per data model) still applies, this is an additional volume control.
3263
+ * If no custom value is set, 100% is used.
3264
+ * No values from the currently active synthesizer are applied.
3265
+ *
3266
+ * The meaning of the key changes when used with AlphaSynth directly, in this case the key is the midi channel .
3267
+ */
3268
+ trackVolume: Map<number, number>;
3269
+ /**
3270
+ * The additional semitone pitch transpose to apply for individual tracks.
3271
+ * @remarks
3272
+ * The key is the track index, and the value is the number of semitones to apply.
3273
+ * No values from the currently active synthesizer are applied.
3274
+ *
3275
+ * The meaning of the key changes when used with AlphaSynth directly, in this case the key is the midi channel .
3276
+ */
3277
+ trackTranspositionPitches: Map<number, number>;
3278
+ }
3279
+
3167
3280
  /**
3168
3281
  * Automations are used to change the behaviour of a song.
3169
3282
  * @cloneable
@@ -5191,7 +5304,7 @@ export declare class CoreSettings {
5191
5304
  /**
5192
5305
  * Builds the default SMuFL font sources for the usage with alphaTab in cases
5193
5306
  * where no custom {@link smuflFontSources} are provided.
5194
- * @param fontDirectory The {@link fontDirectory} configured.
5307
+ * @param fontDirectory The {@link CoreSettings.fontDirectory} configured.
5195
5308
  * @target web
5196
5309
  */
5197
5310
  static buildDefaultSmuflFontSources(fontDirectory: string | null): Map<FontFileFormat, string>;
@@ -7350,6 +7463,26 @@ declare interface IAlphaSynth {
7350
7463
  readonly playbackRangeChanged: IEventEmitterOfT<PlaybackRangeChangedEventArgs>;
7351
7464
  }
7352
7465
 
7466
+ /**
7467
+ * An audio exporter allowing streaming synthesis of audio samples with a fixed configuration.
7468
+ * This is the internal synchronous version of the public {@link IAudioExporter}.
7469
+ */
7470
+ declare interface IAlphaSynthAudioExporter {
7471
+ /**
7472
+ * Renders the next chunk of audio and provides it as result.
7473
+ *
7474
+ * @param milliseconds The rough number of milliseconds that should be synthesized and exported as chunk.
7475
+ * @returns The requested chunk holding the samples and time information.
7476
+ * If the song completed playback `undefined` is returned indicating the end.
7477
+ * The provided audio might not be exactly the requested number of milliseconds as the synthesizer internally
7478
+ * uses a fixed block size of 64 samples for synthesizing audio. Depending on the sample rate
7479
+ * slightly longer audio is contained in the result.
7480
+ *
7481
+ * When the song ends, the chunk might contain less than the requested duration.
7482
+ */
7483
+ render(milliseconds: number): AudioExportChunk | undefined;
7484
+ }
7485
+
7353
7486
  /**
7354
7487
  * A {@link IBackingTrackSynthOutput} which uses a HTMLAudioElement as playback mechanism.
7355
7488
  * Allows the access to the element for further custom usage.
@@ -7364,6 +7497,42 @@ declare interface IAudioElementBackingTrackSynthOutput extends IBackingTrackSynt
7364
7497
  readonly audioElement: HTMLAudioElement;
7365
7498
  }
7366
7499
 
7500
+ /**
7501
+ * A exporter which can be used to obtain the synthesized audio for custom processing.
7502
+ */
7503
+ declare interface IAudioExporter extends Disposable {
7504
+ /**
7505
+ * Renders the next chunk of audio and provides it as result.
7506
+ *
7507
+ * @param milliseconds The rough number of milliseconds that should be synthesized and exported as chunk.
7508
+ * @returns The requested chunk holding the samples and time information.
7509
+ * If the song completed playback `undefined` is returned indicating the end.
7510
+ * The provided audio might not be exactly the requested number of milliseconds as the synthesizer internally
7511
+ * uses a fixed block size of 64 samples for synthesizing audio. Depending on the sample rate
7512
+ * slightly longer audio is contained in the result.
7513
+ *
7514
+ * When the song ends, the chunk might contain less than the requested duration.
7515
+ */
7516
+ render(milliseconds: number): Promise<AudioExportChunk | undefined>;
7517
+ destroy(): void;
7518
+ }
7519
+
7520
+ /**
7521
+ * This is the internal worker interface implemented by IAudioExporters and consists
7522
+ * of the internal APIs needed to spawn new exporters. Its mainly used to simplify
7523
+ * the public API visible when using exporters.
7524
+ */
7525
+ declare interface IAudioExporterWorker extends IAudioExporter {
7526
+ /**
7527
+ * Initializes the worker.
7528
+ * @param options The options to use
7529
+ * @param midi The midi file to load
7530
+ * @param syncPoints The sync points of the song (if any)
7531
+ * @param transpositionPitches The initial transposition pitches for the midi file.
7532
+ */
7533
+ initialize(options: AudioExportOptions, midi: MidiFile, syncPoints: BackingTrackSyncPoint[], transpositionPitches: Map<number, number>): Promise<void>;
7534
+ }
7535
+
7367
7536
  /**
7368
7537
  * Classes implementing this interface can act as main audio synthesis engine
7369
7538
  * within alphaSynth.
@@ -8412,6 +8581,14 @@ declare interface IUiFacade<TSettings> {
8412
8581
  * @returns
8413
8582
  */
8414
8583
  createWorkerPlayer(): IAlphaSynth | null;
8584
+ /**
8585
+ * Tells the UI layer to create a new audio exporter.
8586
+ * @param synth The currently active alphaSynth that might be used for synthesizing.
8587
+ * If the provided synthesizer is already an active player worker (created via {@link createWorkerPlayer}),
8588
+ * it can reuse the already initialized state.
8589
+ * @returns
8590
+ */
8591
+ createWorkerAudioExporter(synth: IAlphaSynth | null): IAudioExporterWorker;
8415
8592
  /**
8416
8593
  * Tells the UI layer to create a player which can play backing tracks.
8417
8594
  * @returns
@@ -9566,6 +9743,8 @@ declare class MidiFileSequencer {
9566
9743
  get currentEndTime(): number;
9567
9744
  get currentTempo(): number;
9568
9745
  get modifiedTempo(): number;
9746
+ get syncPointTempo(): number;
9747
+ get currentSyncPoints(): BackingTrackSyncPoint[];
9569
9748
  /**
9570
9749
  * Gets or sets the playback speed.
9571
9750
  */
@@ -9583,7 +9762,9 @@ declare class MidiFileSequencer {
9583
9762
  mainTickPositionToTimePosition(tickPosition: number): number;
9584
9763
  mainUpdateSyncPoints(syncPoints: BackingTrackSyncPoint[]): void;
9585
9764
  currentTimePositionToTickPosition(timePosition: number): number;
9765
+ currentUpdateCurrentTempo(timePosition: number): void;
9586
9766
  private updateCurrentTempo;
9767
+ currentUpdateSyncPoints(timePosition: number): void;
9587
9768
  private updateSyncPoints;
9588
9769
  mainTimePositionFromBackingTrack(timePosition: number, backingTrackLength: number): number;
9589
9770
  mainTimePositionToBackingTrack(timePosition: number, backingTrackLength: number): number;
@@ -9615,7 +9796,6 @@ declare class MidiSequencerState {
9615
9796
  division: number;
9616
9797
  eventIndex: number;
9617
9798
  currentTime: number;
9618
- currentTick: number;
9619
9799
  syncPointIndex: number;
9620
9800
  playbackRange: PlaybackRange | null;
9621
9801
  playbackRangeStartTime: number;
@@ -9623,7 +9803,7 @@ declare class MidiSequencerState {
9623
9803
  endTick: number;
9624
9804
  endTime: number;
9625
9805
  currentTempo: number;
9626
- modifiedTempo: number;
9806
+ syncPointTempo: number;
9627
9807
  }
9628
9808
 
9629
9809
  /**
@@ -13866,6 +14046,7 @@ export declare namespace synth {
13866
14046
  export {
13867
14047
  AlphaSynthBase,
13868
14048
  AlphaSynth,
14049
+ IAlphaSynthAudioExporter,
13869
14050
  CircularSampleBuffer,
13870
14051
  PlaybackRange,
13871
14052
  ISynthOutput,
@@ -13885,7 +14066,11 @@ export declare namespace synth {
13885
14066
  AlphaSynthAudioWorkletOutput,
13886
14067
  IAudioElementBackingTrackSynthOutput,
13887
14068
  IExternalMediaHandler,
13888
- IExternalMediaSynthOutput
14069
+ IExternalMediaSynthOutput,
14070
+ IAudioExporter,
14071
+ IAudioExporterWorker,
14072
+ AudioExportChunk,
14073
+ AudioExportOptions
13889
14074
  }
13890
14075
  }
13891
14076