Add utility function to convert panning values from [0,127] to [-1,1]

This commit is contained in:
Phillip Stephens 2020-10-24 15:58:29 -07:00
parent fa3188e569
commit 1275293327
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
1 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,13 @@
#include "amuse/Studio.hpp" #include "amuse/Studio.hpp"
namespace amuse { namespace amuse {
constexpr float convertMusyXPanToAmusePan(uint32_t pan) {
// Amuse expects pan values to be between [-1,1] while MusyX expects pan to be between [0,127], we need to make sure
// to map the values properly, we do this by subtracting the center value and then dividing, thus forcing [0, 127] into
// [-1,1], we must also make sure clamp the result so we don't over or underflow.
return std::clamp(static_cast<float>(pan - 64) / 63.f, -1.f, 1.f);
}
class IBackendVoice; class IBackendVoice;
struct Keymap; struct Keymap;
struct LayerMapping; struct LayerMapping;