OPL and OPLL vol map

This commit is contained in:
tildearrow 2023-12-17 14:54:38 -05:00
parent 8d30ac4d3b
commit 0208883fa1
6 changed files with 26 additions and 2 deletions

View file

@ -191,7 +191,7 @@ class DivPlatformOPN: public DivPlatformFMBase {
if (ch==adpcmBChanOffs) return vel*255.0;
if (ch>=adpcmAChanOffs) {
if (vel==0) return 0;
if (vel==127) return 31;
if (vel>=1.0) return 31;
return CLAMP(round(32.0-(56.0-log2(vel*127.0)*8.0)),0,31);
}
if (ch>=psgChanOffs) return round(15.0*pow(vel,0.33));

View file

@ -132,7 +132,7 @@ class DivPlatformFMBase: public DivDispatch {
// -36: 2: 48
// -42: 1: 56
if (vel==0) return 0;
if (vel==127) return 127;
if (vel>=1.0) return 127;
return CLAMP(round(128.0-(56.0-log2(vel*127.0)*8.0)),0,127);
}

View file

@ -2104,6 +2104,21 @@ DivDispatchOscBuffer* DivPlatformOPL::getOscBuffer(int ch) {
return oscBuf[ch];
}
int DivPlatformOPL::mapVelocity(int ch, float vel) {
if (ch==adpcmChan) return vel*255.0;
// -0.75dB per step
// -6: 64: 8
// -12: 32: 16
// -18: 16: 24
// -24: 8: 32
// -30: 4: 40
// -36: 2: 48
// -42: 1: 56
if (vel==0) return 0;
if (vel>=1.0) return 63;
return CLAMP(round(64.0-(56.0-log2(vel*127.0)*8.0)),0,63);
}
unsigned char* DivPlatformOPL::getRegisterPool() {
return regPool;
}

View file

@ -150,6 +150,7 @@ class DivPlatformOPL: public DivDispatch {
unsigned short getPan(int chan);
DivChannelPair getPaired(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();

View file

@ -962,6 +962,13 @@ DivDispatchOscBuffer* DivPlatformOPLL::getOscBuffer(int ch) {
return oscBuf[ch];
}
int DivPlatformOPLL::mapVelocity(int ch, float vel) {
// -3dB per step
if (vel==0) return 0;
if (vel>=1.0) return 15;
return CLAMP(round(16.0-(14.0-log2(vel*127.0)*2.0)),0,15);
}
unsigned char* DivPlatformOPLL::getRegisterPool() {
return regPool;
}

View file

@ -95,6 +95,7 @@ class DivPlatformOPLL: public DivDispatch {
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();