diff --git a/Source/AlphaTab/Audio/Synth/MidiFileSequencer.cs b/Source/AlphaTab/Audio/Synth/MidiFileSequencer.cs index c952ac9db..ad6fc6015 100644 --- a/Source/AlphaTab/Audio/Synth/MidiFileSequencer.cs +++ b/Source/AlphaTab/Audio/Synth/MidiFileSequencer.cs @@ -112,7 +112,7 @@ public void Seek(double timePosition) _eventIndex = 0; var metronomeVolume = _synthesizer.MetronomeVolume; _synthesizer.NoteOffAll(true); - _synthesizer.Reset(); + _synthesizer.ResetSoft(); _synthesizer.SetupMetronomeChannel(metronomeVolume); SilentProcess(timePosition); @@ -345,7 +345,7 @@ public void CheckForStop() { var metronomeVolume = _synthesizer.MetronomeVolume; _synthesizer.NoteOffAll(true); - _synthesizer.Reset(); + _synthesizer.ResetSoft(); _synthesizer.SetupMetronomeChannel(metronomeVolume); OnFinished(); } diff --git a/Source/AlphaTab/Audio/Synth/Synthesis/TinySoundFont.AlphaTab.cs b/Source/AlphaTab/Audio/Synth/Synthesis/TinySoundFont.AlphaTab.cs index 329ef45ed..999820711 100644 --- a/Source/AlphaTab/Audio/Synth/Synthesis/TinySoundFont.AlphaTab.cs +++ b/Source/AlphaTab/Audio/Synth/Synthesis/TinySoundFont.AlphaTab.cs @@ -189,5 +189,37 @@ public void SetupMetronomeChannel(float volume) ChannelSetMixVolume(SynthConstants.MetronomeChannel, volume); ChannelSetPresetNumber(SynthConstants.MetronomeChannel, 0, true); } + + /// + /// Stop all playing notes immediatly and reset all channel parameters but keeps user + /// defined settings + /// + public void ResetSoft() + { + foreach (var v in _voices) + { + if (v.PlayingPreset != -1 && + (v.AmpEnv.Segment < VoiceEnvelopeSegment.Release || v.AmpEnv.Parameters.Release != 0)) + { + v.EndQuick(OutSampleRate); + } + } + + if (_channels != null) + { + foreach (var c in _channels.ChannelList) + { + c.PresetIndex = c.Bank = 0; + c.PitchWheel = c.MidiPan = 8192; + c.MidiVolume = c.MidiExpression = 16383; + c.MidiRpn = 0xFFFF; + c.MidiData = 0; + c.PanOffset = 0.0f; + c.GainDb = 0.0f; + c.PitchRange = 2.0f; + c.Tuning = 0.0f; + } + } + } } }