@coderline/alphatab 1.6.0-alpha.1442 → 1.6.0-alpha.1448

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,15 @@ 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
+ * @param options The export options.
2969
+ * @returns An exporter instance to export the audio in a streaming fashion.
2970
+ */
2971
+ exportAudio(options: AudioExportOptions): Promise<IAudioExporter>;
2952
2972
  }
2953
2973
 
2954
2974
  export declare class AlphaTabError extends Error {
@@ -3164,6 +3184,94 @@ declare class AlphaTexImporter extends ScoreImporter {
3164
3184
  private parseWhammyType;
3165
3185
  }
3166
3186
 
3187
+ /**
3188
+ * Represents a single chunk of audio produced.
3189
+ */
3190
+ declare class AudioExportChunk {
3191
+ /**
3192
+ * The generated samples for the requested chunk.
3193
+ */
3194
+ samples: Float32Array;
3195
+ /**
3196
+ * The current time position within the song in milliseconds.
3197
+ */
3198
+ currentTime: number;
3199
+ /**
3200
+ * The total length of the song in milliseconds.
3201
+ */
3202
+ endTime: number;
3203
+ /**
3204
+ * The current time position within the song in midi ticks.
3205
+ */
3206
+ currentTick: number;
3207
+ /**
3208
+ * The total length of the song in midi ticks.
3209
+ */
3210
+ endTick: number;
3211
+ }
3212
+
3213
+ /**
3214
+ * The options controlling how to export the audio.
3215
+ */
3216
+ declare class AudioExportOptions {
3217
+ /**
3218
+ * The soundfonts to load and use for generating the audio.
3219
+ * If not provided, the already loaded soundfonts of the synthesizer will be used.
3220
+ * If no existing synthesizer is initialized, the generated audio might not contain any hearable audio.
3221
+ */
3222
+ soundFonts?: Uint8Array[];
3223
+ /**
3224
+ * The output sample rate.
3225
+ * @default `44100`
3226
+ */
3227
+ sampleRate: number;
3228
+ /**
3229
+ * Whether to respect sync point information during export.
3230
+ * @default `true`
3231
+ * @remarks
3232
+ * If the song contains sync point information for synchronization with an external media,
3233
+ * this option allows controlling whether the synthesized audio is aligned with these points.
3234
+ *
3235
+ * This is useful when mixing the exported audio together with external media, keeping the same timing.
3236
+ *
3237
+ * Disable this option if you want the original/exact timing as per music sheet in the exported audio.
3238
+ */
3239
+ useSyncPoints: boolean;
3240
+ /**
3241
+ * The current master volume as percentage. (range: 0.0-3.0, default 1.0)
3242
+ */
3243
+ masterVolume: number;
3244
+ /**
3245
+ * The metronome volume. (range: 0.0-3.0, default 0.0)
3246
+ */
3247
+ metronomeVolume: number;
3248
+ /**
3249
+ * The range of the song that should be exported. Set this to null
3250
+ * to play the whole song.
3251
+ */
3252
+ playbackRange?: PlaybackRange;
3253
+ /**
3254
+ * The volume for individual tracks as percentage (range: 0.0-3.0).
3255
+ * @remarks
3256
+ * The key is the track index, and the value is the relative volume.
3257
+ * The configured volume (as per data model) still applies, this is an additional volume control.
3258
+ * If no custom value is set, 100% is used.
3259
+ * No values from the currently active synthesizer are applied.
3260
+ *
3261
+ * The meaning of the key changes when used with AlphaSynth directly, in this case the key is the midi channel .
3262
+ */
3263
+ trackVolume: Map<number, number>;
3264
+ /**
3265
+ * The additional semitone pitch transpose to apply for individual tracks.
3266
+ * @remarks
3267
+ * The key is the track index, and the value is the number of semitones to apply.
3268
+ * No values from the currently active synthesizer are applied.
3269
+ *
3270
+ * The meaning of the key changes when used with AlphaSynth directly, in this case the key is the midi channel .
3271
+ */
3272
+ trackTranspositionPitches: Map<number, number>;
3273
+ }
3274
+
3167
3275
  /**
3168
3276
  * Automations are used to change the behaviour of a song.
3169
3277
  * @cloneable
@@ -5191,7 +5299,7 @@ export declare class CoreSettings {
5191
5299
  /**
5192
5300
  * Builds the default SMuFL font sources for the usage with alphaTab in cases
5193
5301
  * where no custom {@link smuflFontSources} are provided.
5194
- * @param fontDirectory The {@link fontDirectory} configured.
5302
+ * @param fontDirectory The {@link CoreSettings.fontDirectory} configured.
5195
5303
  * @target web
5196
5304
  */
5197
5305
  static buildDefaultSmuflFontSources(fontDirectory: string | null): Map<FontFileFormat, string>;
@@ -7350,6 +7458,26 @@ declare interface IAlphaSynth {
7350
7458
  readonly playbackRangeChanged: IEventEmitterOfT<PlaybackRangeChangedEventArgs>;
7351
7459
  }
7352
7460
 
7461
+ /**
7462
+ * An audio exporter allowing streaming synthesis of audio samples with a fixed configuration.
7463
+ * This is the internal synchronous version of the public {@link IAudioExporter}.
7464
+ */
7465
+ declare interface IAlphaSynthAudioExporter {
7466
+ /**
7467
+ * Renders the next chunk of audio and provides it as result.
7468
+ *
7469
+ * @param milliseconds The rough number of milliseconds that should be synthesized and exported as chunk.
7470
+ * @returns The requested chunk holding the samples and time information.
7471
+ * If the song completed playback `undefined` is returned indicating the end.
7472
+ * The provided audio might not be exactly the requested number of milliseconds as the synthesizer internally
7473
+ * uses a fixed block size of 64 samples for synthesizing audio. Depending on the sample rate
7474
+ * slightly longer audio is contained in the result.
7475
+ *
7476
+ * When the song ends, the chunk might contain less than the requested duration.
7477
+ */
7478
+ render(milliseconds: number): AudioExportChunk | undefined;
7479
+ }
7480
+
7353
7481
  /**
7354
7482
  * A {@link IBackingTrackSynthOutput} which uses a HTMLAudioElement as playback mechanism.
7355
7483
  * Allows the access to the element for further custom usage.
@@ -7364,6 +7492,42 @@ declare interface IAudioElementBackingTrackSynthOutput extends IBackingTrackSynt
7364
7492
  readonly audioElement: HTMLAudioElement;
7365
7493
  }
7366
7494
 
7495
+ /**
7496
+ * A exporter which can be used to obtain the synthesized audio for custom processing.
7497
+ */
7498
+ declare interface IAudioExporter extends Disposable {
7499
+ /**
7500
+ * Renders the next chunk of audio and provides it as result.
7501
+ *
7502
+ * @param milliseconds The rough number of milliseconds that should be synthesized and exported as chunk.
7503
+ * @returns The requested chunk holding the samples and time information.
7504
+ * If the song completed playback `undefined` is returned indicating the end.
7505
+ * The provided audio might not be exactly the requested number of milliseconds as the synthesizer internally
7506
+ * uses a fixed block size of 64 samples for synthesizing audio. Depending on the sample rate
7507
+ * slightly longer audio is contained in the result.
7508
+ *
7509
+ * When the song ends, the chunk might contain less than the requested duration.
7510
+ */
7511
+ render(milliseconds: number): Promise<AudioExportChunk | undefined>;
7512
+ destroy(): void;
7513
+ }
7514
+
7515
+ /**
7516
+ * This is the internal worker interface implemented by IAudioExporters and consists
7517
+ * of the internal APIs needed to spawn new exporters. Its mainly used to simplify
7518
+ * the public API visible when using exporters.
7519
+ */
7520
+ declare interface IAudioExporterWorker extends IAudioExporter {
7521
+ /**
7522
+ * Initializes the worker.
7523
+ * @param options The options to use
7524
+ * @param midi The midi file to load
7525
+ * @param syncPoints The sync points of the song (if any)
7526
+ * @param transpositionPitches The initial transposition pitches for the midi file.
7527
+ */
7528
+ initialize(options: AudioExportOptions, midi: MidiFile, syncPoints: BackingTrackSyncPoint[], transpositionPitches: Map<number, number>): Promise<void>;
7529
+ }
7530
+
7367
7531
  /**
7368
7532
  * Classes implementing this interface can act as main audio synthesis engine
7369
7533
  * within alphaSynth.
@@ -8412,6 +8576,14 @@ declare interface IUiFacade<TSettings> {
8412
8576
  * @returns
8413
8577
  */
8414
8578
  createWorkerPlayer(): IAlphaSynth | null;
8579
+ /**
8580
+ * Tells the UI layer to create a new audio exporter.
8581
+ * @param synth The currently active alphaSynth that might be used for synthesizing.
8582
+ * If the provided synthesizer is already an active player worker (created via {@link createWorkerPlayer}),
8583
+ * it can reuse the already initialized state.
8584
+ * @returns
8585
+ */
8586
+ createWorkerAudioExporter(synth: IAlphaSynth | null): IAudioExporterWorker;
8415
8587
  /**
8416
8588
  * Tells the UI layer to create a player which can play backing tracks.
8417
8589
  * @returns
@@ -9566,6 +9738,8 @@ declare class MidiFileSequencer {
9566
9738
  get currentEndTime(): number;
9567
9739
  get currentTempo(): number;
9568
9740
  get modifiedTempo(): number;
9741
+ get syncPointTempo(): number;
9742
+ get currentSyncPoints(): BackingTrackSyncPoint[];
9569
9743
  /**
9570
9744
  * Gets or sets the playback speed.
9571
9745
  */
@@ -9583,7 +9757,9 @@ declare class MidiFileSequencer {
9583
9757
  mainTickPositionToTimePosition(tickPosition: number): number;
9584
9758
  mainUpdateSyncPoints(syncPoints: BackingTrackSyncPoint[]): void;
9585
9759
  currentTimePositionToTickPosition(timePosition: number): number;
9760
+ currentUpdateCurrentTempo(timePosition: number): void;
9586
9761
  private updateCurrentTempo;
9762
+ currentUpdateSyncPoints(timePosition: number): void;
9587
9763
  private updateSyncPoints;
9588
9764
  mainTimePositionFromBackingTrack(timePosition: number, backingTrackLength: number): number;
9589
9765
  mainTimePositionToBackingTrack(timePosition: number, backingTrackLength: number): number;
@@ -9615,7 +9791,6 @@ declare class MidiSequencerState {
9615
9791
  division: number;
9616
9792
  eventIndex: number;
9617
9793
  currentTime: number;
9618
- currentTick: number;
9619
9794
  syncPointIndex: number;
9620
9795
  playbackRange: PlaybackRange | null;
9621
9796
  playbackRangeStartTime: number;
@@ -9623,7 +9798,7 @@ declare class MidiSequencerState {
9623
9798
  endTick: number;
9624
9799
  endTime: number;
9625
9800
  currentTempo: number;
9626
- modifiedTempo: number;
9801
+ syncPointTempo: number;
9627
9802
  }
9628
9803
 
9629
9804
  /**
@@ -13866,6 +14041,7 @@ export declare namespace synth {
13866
14041
  export {
13867
14042
  AlphaSynthBase,
13868
14043
  AlphaSynth,
14044
+ IAlphaSynthAudioExporter,
13869
14045
  CircularSampleBuffer,
13870
14046
  PlaybackRange,
13871
14047
  ISynthOutput,
@@ -13885,7 +14061,11 @@ export declare namespace synth {
13885
14061
  AlphaSynthAudioWorkletOutput,
13886
14062
  IAudioElementBackingTrackSynthOutput,
13887
14063
  IExternalMediaHandler,
13888
- IExternalMediaSynthOutput
14064
+ IExternalMediaSynthOutput,
14065
+ IAudioExporter,
14066
+ IAudioExporterWorker,
14067
+ AudioExportChunk,
14068
+ AudioExportOptions
13889
14069
  }
13890
14070
  }
13891
14071