Skip to content

Commit

Permalink
Fix Lb302 silence (#7504)
Browse files Browse the repository at this point in the history
This problem seem to arise due to casting _n->framesLeft() and _n->offset() from an unsigned type (size_t) to a signed type (int). The fix is to use size_t as the type for std::max across the board.
  • Loading branch information
sakertooth authored Sep 18, 2024
1 parent 4803bbb commit 0129419
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions plugins/Lb302/Lb302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ inline float GET_INC(float freq) {
return freq/Engine::audioEngine()->outputSampleRate(); // TODO: Use actual sampling rate.
}

int Lb302Synth::process(SampleFrame* outbuf, const int size)
int Lb302Synth::process(SampleFrame* outbuf, const std::size_t size)
{
const float sampleRatio = 44100.f / Engine::audioEngine()->outputSampleRate();

Expand Down Expand Up @@ -498,13 +498,10 @@ int Lb302Synth::process(SampleFrame* outbuf, const int size)
// hard coded value of 0.99897516.
auto decay = computeDecayFactor(0.245260770975f, 1.f / 65536.f);

for( int i=0; i<size; i++ )
for (auto i = std::size_t{0}; i < size; i++)
{
// start decay if we're past release
if( i >= release_frame )
{
vca_mode = VcaMode::Decay;
}
if (i >= release_frame) { vca_mode = VcaMode::Decay; }

// update vcf
if(vcf_envpos >= ENVINC) {
Expand Down Expand Up @@ -751,7 +748,7 @@ void Lb302Synth::playNote( NotePlayHandle * _n, SampleFrame* _working_buffer )
}
m_notesMutex.unlock();

release_frame = std::max(release_frame, static_cast<int>(_n->framesLeft()) + static_cast<int>(_n->offset()));
release_frame = std::max(release_frame, _n->framesLeft() + _n->offset());
}


Expand Down
4 changes: 2 additions & 2 deletions plugins/Lb302/Lb302.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public slots:
Lb302FilterKnobState fs;
QAtomicPointer<Lb302Filter> vcf;

int release_frame;
size_t release_frame;

// More States
int vcf_envpos; // Update counter. Updates when >= ENVINC
Expand Down Expand Up @@ -246,7 +246,7 @@ public slots:

void recalcFilter();

int process(SampleFrame* outbuf, const int size);
int process(SampleFrame* outbuf, const std::size_t size);

friend class gui::Lb302SynthView;

Expand Down

0 comments on commit 0129419

Please sign in to comment.