From 7af2bae7166fc97b193190457058a34450d396f7 Mon Sep 17 00:00:00 2001 From: Takamitsu Endo Date: Sat, 30 Oct 2021 00:56:07 +0900 Subject: [PATCH] Remove pop noise on SyncSawSynth when resting note becomes active Before this fix, reset wasn't performed on sustain smoother in gain envelope. --- SyncSawSynth/source/dsp/dspcore.cpp | 8 ++++---- SyncSawSynth/source/dsp/dspcore.hpp | 2 -- SyncSawSynth/source/dsp/envelope.hpp | 1 + SyncSawSynth/source/version.hpp | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/SyncSawSynth/source/dsp/dspcore.cpp b/SyncSawSynth/source/dsp/dspcore.cpp index f2a4b582..2d170b93 100644 --- a/SyncSawSynth/source/dsp/dspcore.cpp +++ b/SyncSawSynth/source/dsp/dspcore.cpp @@ -254,7 +254,7 @@ template Sample Note::process(NoteProcessInfo & if (bypassFilter) return gain * (info.osc1Gain * outSaw1 + info.osc2Gain * outSaw2); - filterEnv = filterEnvelope.process(); + auto filterEnv = filterEnvelope.process(); filter.setCutoffQ( info.filterCutoff * powf( @@ -283,8 +283,8 @@ void DSPCore::setup(double sampleRate) for (auto &nt : note) nt = std::make_unique>(this->sampleRate); } - // 2 msec + 1 sample transition time. - transitionBuffer.resize(1 + int(sampleRate * 0.005), 0.0); + // 10 msec + 1 sample transition time. + transitionBuffer.resize(1 + size_t(this->sampleRate * 0.01f), 0.0); startup(); } @@ -502,7 +502,7 @@ void DSPCore::noteOn(int32_t noteId, int16_t pitch, float tuning, float velocity mostSilent = i; } } - if (i >= nVoice) { + if (i >= nVoice && notes[i][0]->state != NoteState::rest) { isTransitioning = true; i = mostSilent; diff --git a/SyncSawSynth/source/dsp/dspcore.hpp b/SyncSawSynth/source/dsp/dspcore.hpp index 263ef9f7..d69c0c35 100644 --- a/SyncSawSynth/source/dsp/dspcore.hpp +++ b/SyncSawSynth/source/dsp/dspcore.hpp @@ -85,8 +85,6 @@ template class Note { Sample frequency = 0; bool bypassFilter = false; - Sample filterEnv = 0; - PTRSyncSaw saw1; PTRSyncSaw saw2; std::array oscBuffer = {0, 0}; diff --git a/SyncSawSynth/source/dsp/envelope.hpp b/SyncSawSynth/source/dsp/envelope.hpp index 8e4fe5ff..117a96b7 100644 --- a/SyncSawSynth/source/dsp/envelope.hpp +++ b/SyncSawSynth/source/dsp/envelope.hpp @@ -59,6 +59,7 @@ template class ExpADSREnvelope { { state = State::attack; value = threshold; + sustain.reset(sustainLevel); set(attackTime, decayTime, sustainLevel, releaseTime, declickTime, threshold); } diff --git a/SyncSawSynth/source/version.hpp b/SyncSawSynth/source/version.hpp index 9a93d02b..26ad0df9 100644 --- a/SyncSawSynth/source/version.hpp +++ b/SyncSawSynth/source/version.hpp @@ -29,11 +29,11 @@ #define SUB_VERSION_STR "1" #define SUB_VERSION_INT 1 -#define RELEASE_NUMBER_STR "16" -#define RELEASE_NUMBER_INT 16 +#define RELEASE_NUMBER_STR "17" +#define RELEASE_NUMBER_INT 17 -#define BUILD_NUMBER_STR "16" -#define BUILD_NUMBER_INT 16 +#define BUILD_NUMBER_STR "17" +#define BUILD_NUMBER_INT 17 #define FULL_VERSION_STR \ MAJOR_VERSION_STR "." SUB_VERSION_STR "." RELEASE_NUMBER_STR "." BUILD_NUMBER_STR