Log scaling for better vol control
This commit is contained in:
parent
10fe7103da
commit
cb9770a757
2 changed files with 25 additions and 6 deletions
|
|
@ -13,6 +13,14 @@
|
|||
#include <QtNodes/NodeStyle>
|
||||
#include <QtNodes/StyleCollection>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace {
|
||||
inline int volumeToSlider(float volume) {
|
||||
return static_cast<int>(std::round(std::cbrt(volume) * 100.0f));
|
||||
}
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
|
|
@ -633,7 +641,7 @@ void WarpGraphModel::refreshFromClient() {
|
|||
|
||||
float vol = volResult.value.volume;
|
||||
bool mute = volResult.value.mute;
|
||||
int sliderVal = static_cast<int>(std::round(vol * 100.0f));
|
||||
int sliderVal = volumeToSlider(vol);
|
||||
sliderVal = std::clamp(sliderVal, 0, 150);
|
||||
|
||||
auto stateIt = m_volumeStates.find(qtId);
|
||||
|
|
@ -820,7 +828,7 @@ void WarpGraphModel::setNodeVolumeState(QtNodes::NodeId nodeId,
|
|||
if (wIt != m_volumeWidgets.end()) {
|
||||
auto *w = qobject_cast<NodeVolumeWidget *>(wIt->second);
|
||||
if (w) {
|
||||
w->setVolume(static_cast<int>(state.volume * 100.0f));
|
||||
w->setVolume(volumeToSlider(state.volume));
|
||||
w->setMuted(state.mute);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue