Skip to content

Commit 0b0e852

Browse files
nickdowellAnClark
authored andcommitted
Reset smoothed params when note is first triggered
Fixes DISTRHO#196
1 parent da2f962 commit 0b0e852

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
amsynth TBD
22

33
- Added PatriksBank04 and PatriksBank05.
4+
- Fixed click when playing a note for the first time - issue #196
45
- Stopped vendoring lv2 headers; install lv2-dev (or similar) via your package manager.
56

67

src/VoiceAllocationUnit.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* VoiceAllocationUnit.cpp
33
*
4-
* Copyright (c) 2001-2019 Nick Dowell
4+
* Copyright (c) 2001-2021 Nick Dowell
55
*
66
* This file is part of amsynth.
77
*
@@ -162,7 +162,7 @@ VoiceAllocationUnit::HandleMidiNoteOn(int note, float velocity)
162162
_voices[note]->reset();
163163

164164
_voices[note]->setVelocity(velocity);
165-
_voices[note]->triggerOn();
165+
_voices[note]->triggerOn(true);
166166

167167
active[note] = true;
168168
}
@@ -186,7 +186,7 @@ VoiceAllocationUnit::HandleMidiNoteOn(int note, float velocity)
186186
voice->setFrequency(voice->getFrequency(), pitch, portamentoTime);
187187

188188
if (_keyboardMode == KeyboardModeMono || previousNote == -1)
189-
voice->triggerOn();
189+
voice->triggerOn(!active[0]);
190190

191191
active[0] = true;
192192
}
@@ -243,7 +243,7 @@ VoiceAllocationUnit::HandleMidiNoteOff(int note, float /*velocity*/)
243243
if (0 <= nextNote) {
244244
voice->setFrequency(voice->getFrequency(), (float) noteToPitch(nextNote), mPortamentoTime);
245245
if (_keyboardMode == KeyboardModeMono)
246-
voice->triggerOn();
246+
voice->triggerOn(false);
247247
} else {
248248
voice->triggerOff();
249249
}

src/VoiceBoard/Synth--.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Synth--.h
33
*
4-
* Copyright (c) 2001-2012 Nick Dowell
4+
* Copyright (c) 2001-2021 Nick Dowell
55
*
66
* This file is part of amsynth.
77
*
@@ -165,6 +165,11 @@ class SmoothedParam
165165
{
166166
return _rawValue;
167167
}
168+
169+
void reset()
170+
{
171+
_smoother.set(_rawValue);
172+
}
168173

169174
inline float tick()
170175
{

src/VoiceBoard/VoiceBoard.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* VoiceBoard.cpp
33
*
4-
* Copyright (c) 2001-2020 Nick Dowell
4+
* Copyright (c) 2001-2021 Nick Dowell
55
*
66
* This file is part of amsynth.
77
*
@@ -221,8 +221,14 @@ VoiceBoard::isSilent()
221221
}
222222

223223
void
224-
VoiceBoard::triggerOn()
224+
VoiceBoard::triggerOn(bool reset)
225225
{
226+
if (reset) {
227+
mOscMix.reset();
228+
mRingModAmt.reset();
229+
mAmpModAmount.reset();
230+
mAmpVelSens.reset();
231+
}
226232
mAmpADSR.triggerOn();
227233
mFilterADSR.triggerOn();
228234
}

src/VoiceBoard/VoiceBoard.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* VoiceBoard.h
33
*
4-
* Copyright (c) 2001-2020 Nick Dowell
4+
* Copyright (c) 2001-2021 Nick Dowell
55
*
66
* This file is part of amsynth.
77
*
@@ -42,7 +42,7 @@ class VoiceBoard
4242
static constexpr int kMaxProcessBufferSize = 64;
4343

4444
bool isSilent ();
45-
void triggerOn ();
45+
void triggerOn (bool reset);
4646
void triggerOff ();
4747
void setVelocity (float velocity);
4848

0 commit comments

Comments
 (0)