Skip to content

Commit

Permalink
Fix std::clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed Sep 28, 2023
1 parent 136e4b9 commit 13f2f8e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/Stk/Mallets/Mallets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,18 @@ void MalletsInstrument::playNote( NotePlayHandle * _n,
if(p < 9)
{
hardness += random * static_cast<float>(fast_rand() % 128) - 64.0;
hardness = std::clamp(0.0f, hardness, 128.0f);
hardness = std::clamp(hardness, 0.0f, 128.0f);

position += random * static_cast<float>(fast_rand() % 64) - 32.0;
position = std::clamp(0.0f, position, 64.0f);
position = std::clamp(position, 0.0f, 64.0f);
}
else if(p == 9)
{
modulator += random * static_cast<float>(fast_rand() % 128) - 64.0;
modulator = std::clamp(0.0f, modulator, 128.0f);
modulator = std::clamp(modulator, 0.0f, 128.0f);

crossfade += random * static_cast<float>(fast_rand() % 128) - 64.0;
crossfade = std::clamp(0.0f, crossfade, 128.0f);
crossfade = std::clamp(crossfade, 0.0f, 128.0f);
}

// critical section as STK is not thread-safe
Expand Down

0 comments on commit 13f2f8e

Please sign in to comment.