Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/synth/AlphaSynth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class AlphaSynth implements IAlphaSynth {
public set masterVolume(value: number) {
value = Math.max(value, SynthConstants.MinVolume);
this._synthesizer.masterVolume = value;
this.onAudioSettingsUpdate();
}

public get metronomeVolume(): number {
Expand All @@ -73,6 +74,7 @@ export class AlphaSynth implements IAlphaSynth {
value = Math.max(value, SynthConstants.MinVolume);
this._metronomeVolume = value;
this._synthesizer.metronomeVolume = value;
this.onAudioSettingsUpdate();
}

public get countInVolume(): number {
Expand Down Expand Up @@ -100,7 +102,7 @@ export class AlphaSynth implements IAlphaSynth {
value = SynthHelper.clamp(value, SynthConstants.MinPlaybackSpeed, SynthConstants.MaxPlaybackSpeed);
let oldSpeed: number = this._sequencer.playbackSpeed;
this._sequencer.playbackSpeed = value;
this.updateTimePosition(this._timePosition * (oldSpeed / value), true);
this.timePosition = this.timePosition * (oldSpeed / value);
}

public get tickPosition(): number {
Expand Down Expand Up @@ -348,6 +350,7 @@ export class AlphaSynth implements IAlphaSynth {

public setChannelMute(channel: number, mute: boolean): void {
this._synthesizer.channelSetMute(channel, mute);
this.onAudioSettingsUpdate();
}

public resetChannelStates(): void {
Expand All @@ -356,11 +359,19 @@ export class AlphaSynth implements IAlphaSynth {

public setChannelSolo(channel: number, solo: boolean): void {
this._synthesizer.channelSetSolo(channel, solo);
this.onAudioSettingsUpdate();
}

public setChannelVolume(channel: number, volume: number): void {
volume = Math.max(volume, SynthConstants.MinVolume);
this._synthesizer.channelSetMixVolume(channel, volume);
this.onAudioSettingsUpdate();
}
private onAudioSettingsUpdate() {
// seeking to the currently known position, will ensure we
// clear all audio buffers and re-generate the audio
// which was not actually played yet.
this.timePosition = this.timePosition;
}

private onSamplesPlayed(sampleCount: number): void {
Expand Down