Skip to main content

alphaTab.synth.IAlphaSynth

The public API interface for interacting with the synthesizer.

 interface IAlphaSynth

Properties​

countInVolume​

Gets or sets volume of the metronome during count-in. (range: 0.0-3.0, default 0.0 - no count in)

countInVolume: number;

currentPosition​

The latest time information of the played song.

readonly currentPosition: PositionChangedEventArgs;

isLooping​

Gets or sets whether the playback should automatically restart after it finished.

isLooping: boolean;

isReady​

Gets or sets whether the synthesizer is ready for interaction. (output and worker are initialized)

readonly isReady: boolean;

isReadyForPlayback​

Gets or sets whether the synthesizer is ready for playback. (output, worker are initialized, soundfont and midi are loaded)

readonly isReadyForPlayback: boolean;

loadedMidiInfo​

The information about the main song loaded (does not account for "one time midis" or "count in").

readonly loadedMidiInfo?: PositionChangedEventArgs;

logLevel​

Gets or sets the loging level.

logLevel: LogLevel;

masterVolume​

Gets or sets the current master volume as percentage. (range: 0.0-3.0, default 1.0)

masterVolume: number;

metronomeVolume​

Gets or sets the metronome volume. (range: 0.0-3.0, default 0.0)

metronomeVolume: number;

midiEventsPlayedFilter​

Gets or sets the midi events which will trigger the midiEventsPlayed event.

midiEventsPlayedFilter: MidiEventType[];

output​

Gets the output used by alphaSynth.

readonly output: ISynthOutput;

playbackRange​

Gets or sets the range of the song that should be played. Set this to null to play the whole song.

playbackRange: PlaybackRange | null;

playbackSpeed​

Gets or sets the current playback speed as percentage. (range: 0.125-8.0, default: 1.0)

playbackSpeed: number;

ready​

This event is fired when the player is ready to be interacted with.

readonly ready: IEventEmitter;

readyForPlayback​

This event is fired when all required data for playback is loaded and ready.

readonly readyForPlayback: IEventEmitter;

state​

Gets the current player state.

readonly state: PlayerState;

tickPosition​

Gets or sets the position within the song in midi ticks.

tickPosition: number;

timePosition​

Gets or sets the position within the song in milliseconds.

timePosition: number;

Methods​

applyTranspositionPitches​

Applies the given transposition pitches to be used during playback.

applyTranspositionPitches(transpositionPitches: Map<number, number>): void
ParameterSummary
transpositionPitchesAll

a map defining the transposition pitches for midi channel.

destroy​

Destroys the synthesizer and all related components

destroy(): void

loadBackingTrack​

Loads the synchronization information from the given score (used for backing tracks and external media).

loadBackingTrack(score: Score): void
ParameterSummary
scoreAll

(no description)

loadMidiFile​

Loads the given midi file structure.

loadMidiFile(midi: MidiFile): void
ParameterSummary
midiAll

(no description)

loadSoundFont​

Loads a soundfont from the given data

loadSoundFont(data: Uint8Array, append: boolean): void
ParameterSummary
dataAll

a byte array to load the data from

appendAll

Whether to fully replace or append the data from the given soundfont.

pause​

Pauses the playback if was running

pause(): void

play​

Starts the playback if possible

play(): boolean

Returns​

true if the playback was started, otherwise false. Reasons for not starting can be that the player is not ready or already playing.

playOneTimeMidiFile​

Stops any ongoing playback and plays the given midi file instead.

playOneTimeMidiFile(midi: MidiFile): void
ParameterSummary
midiAll

The midi file to play

playPause​

Starts the playback if possible, pauses the playback if was running

playPause(): void

resetChannelStates​

Resets the mute/solo state of all channels

resetChannelStates(): void

resetSoundFonts​

Resets all loaded soundfonts as if they were not loaded.

resetSoundFonts(): void

setChannelMute​

Sets the mute state of a channel.

setChannelMute(channel: number, mute: boolean): void
ParameterSummary
channelAll

The channel number

muteAll

true if the channel should be muted, otherwise false.

setChannelSolo​

Gets the solo state of a channel.

setChannelSolo(channel: number, solo: boolean): void
ParameterSummary
channelAll

The channel number

soloAll

true if the channel should be played solo, otherwise false.

setChannelTranspositionPitch​

Sets the transposition pitch of a given channel. This pitch is additionally applied beside the ones applied already via applyTranspositionPitches .

setChannelTranspositionPitch(channel: number, semitones: number): void
ParameterSummary
channelAll

The channel number

semitonesAll

The number of semitones to apply as pitch offset.

setChannelVolume​

Gets or sets the current and initial volume of the given channel.

setChannelVolume(channel: number, volume: number): void
ParameterSummary
channelAll

The channel number.

volumeAll

The volume of of the channel (0.0-1.0)

stop​

Stopps the playback

stop(): void

updateSyncPoints​

Updates the points used to synchronize the backing track with the synthesized audio for correct cursor placement.

updateSyncPoints(syncPoints: BackingTrackSyncPoint[]): void
ParameterSummary
syncPointsAll

(no description)

Events​

finished​

This event is fired when the playback of the whole song finished.

This event is fired when the playback of the whole song finished.

readonly finished: IEventEmitter;

midiEventsPlayed​

The event is fired when certain midi events were sent to the audio output device for playback.

The event is fired when certain midi events were sent to the audio output device for playback.

readonly midiEventsPlayed: IEventEmitterOfT<MidiEventsPlayedEventArgs>;

midiLoaded​

This event is fired when the Midi file needed for playback was loaded.

This event is fired when the Midi file needed for playback was loaded.

midiLoadFailed​

This event is fired when the loading of the Midi file failed.

This event is fired when the loading of the Midi file failed.

readonly midiLoadFailed: IEventEmitterOfT<Error>;

playbackRangeChanged​

The event is fired when the playback range within the player was updated.

The event is fired when the playback range within the player was updated.

readonly playbackRangeChanged: IEventEmitterOfT<PlaybackRangeChangedEventArgs>;

positionChanged​

This event is fired when the current playback position of/ the song changed.

This event is fired when the current playback position of/ the song changed.

soundFontLoaded​

This event is fired when the SoundFont needed for playback was loaded.

This event is fired when the SoundFont needed for playback was loaded.

readonly soundFontLoaded: IEventEmitter;

soundFontLoadFailed​

This event is fired when the loading of the SoundFont failed.

This event is fired when the loading of the SoundFont failed.

readonly soundFontLoadFailed: IEventEmitterOfT<Error>;

stateChanged​

This event is fired when the playback state changed.

This event is fired when the playback state changed.