Fix release fade-out not being applied

This fixes to bugs leading to clicks on instrument note-off in most
instruments.

The first bug was introduced as part of a refactoring done by Vesa [1]
and caused each note play handle's last buffer being dropped because
the play handles were deleted before being processed in AudioPort.
Thanks to @lleroy for pointing this out. [2]

The second bug / typo has always been there [3] and was a misplaced
parenthesis in Instrument::applyRelease breaking the calculation of the
note-off envelope's start frame, sometimes putting it outside of the
buffer.

Fixes #3086

[1] 857de8d2c8 and related commits
[1] https://github.com/LMMS/lmms/issues/3086#issuecomment-519087089
[2] 02433380c6
This commit is contained in:
Lukas W
2023-09-30 00:01:10 +02:00
parent 7dc00524fa
commit d962070d7c
2 changed files with 12 additions and 12 deletions

View File

@@ -394,6 +394,17 @@ void AudioEngine::renderStageInstruments()
AudioEngineWorkerThread::fillJobQueue(m_playHandles);
AudioEngineWorkerThread::startAndWaitForJobs();
}
void AudioEngine::renderStageEffects()
{
AudioEngineProfiler::Probe profilerProbe(m_profiler, AudioEngineProfiler::DetailType::Effects);
// STAGE 2: process effects of all instrument- and sampletracks
AudioEngineWorkerThread::fillJobQueue(m_audioPorts);
AudioEngineWorkerThread::startAndWaitForJobs();
// removed all play handles which are done
for( PlayHandleList::Iterator it = m_playHandles.begin();
@@ -424,17 +435,6 @@ void AudioEngine::renderStageInstruments()
void AudioEngine::renderStageEffects()
{
AudioEngineProfiler::Probe profilerProbe(m_profiler, AudioEngineProfiler::DetailType::Effects);
// STAGE 2: process effects of all instrument- and sampletracks
AudioEngineWorkerThread::fillJobQueue(m_audioPorts);
AudioEngineWorkerThread::startAndWaitForJobs();
}
void AudioEngine::renderStageMix()
{
AudioEngineProfiler::Probe profilerProbe(m_profiler, AudioEngineProfiler::DetailType::Mixing);

View File

@@ -186,7 +186,7 @@ void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n )
{
for( fpp_t f = (fpp_t)( ( fl > desiredReleaseFrames() ) ?
(std::max(fpp - desiredReleaseFrames(), 0) +
fl % fpp) : 0); f < frames; ++f)
fl) % fpp : 0); f < frames; ++f)
{
const float fac = (float)( fl-f-1 ) /
desiredReleaseFrames();