Merge branch 'master' into feature/esfm

This commit is contained in:
Kagamiin~ 2024-01-01 14:45:54 -03:00
commit 215c8c375a
46 changed files with 1596 additions and 829 deletions

View file

@ -186,6 +186,17 @@ class DivPlatformOPN: public DivPlatformFMBase {
void setCombo(bool combo) {
useCombo=combo;
}
virtual int mapVelocity(int ch, float vel) {
if (ch==csmChan) return vel*127.0;
if (ch==adpcmBChanOffs) return vel*255.0;
if (ch>=adpcmAChanOffs) {
if (vel==0) return 0;
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));
return DivPlatformFMBase::mapVelocity(ch,vel);
}
};
#endif

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

@ -1300,6 +1300,12 @@ DivDispatchOscBuffer* DivPlatformGenesis::getOscBuffer(int ch) {
return oscBuf[ch];
}
int DivPlatformGenesis::mapVelocity(int ch, float vel) {
if (ch==csmChan) return DivPlatformOPN::mapVelocity(ch,vel);
if (ch>5) return DivPlatformOPN::mapVelocity(5,vel);
return DivPlatformOPN::mapVelocity(ch,vel);
}
unsigned char* DivPlatformGenesis::getRegisterPool() {
return regPool;
}

View file

@ -112,6 +112,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
virtual unsigned short getPan(int chan);
DivSamplePos getSamplePos(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
virtual int mapVelocity(int ch, float vel);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();

View file

@ -818,6 +818,12 @@ DivDispatchOscBuffer* DivPlatformGenesisExt::getOscBuffer(int ch) {
return NULL;
}
int DivPlatformGenesisExt::mapVelocity(int ch, float vel) {
if (ch>=extChanOffs+4) return DivPlatformGenesis::mapVelocity(ch-3,vel);
if (ch>=extChanOffs) return DivPlatformGenesis::mapVelocity(extChanOffs,vel);
return DivPlatformGenesis::mapVelocity(ch,vel);
}
void DivPlatformGenesisExt::reset() {
DivPlatformGenesis::reset();

View file

@ -36,6 +36,7 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
DivMacroInt* getChanMacroInt(int ch);
unsigned short getPan(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
void reset();
void forceIns();
void tick(bool sysTick=true);

View file

@ -199,7 +199,7 @@ void DivPlatformNamcoWSG::tick(bool sysTick) {
for (int i=0; i<chans; i++) {
chan[i].std.next();
if (chan[i].std.vol.had) {
chan[i].outVol=((chan[i].vol&15)*MIN(15,chan[i].std.vol.val))>>4;
chan[i].outVol=VOL_SCALE_LINEAR(chan[i].vol,chan[i].std.vol.val,15);
}
if (chan[i].std.duty.had) {
chan[i].noise=chan[i].std.duty.val;

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();

View file

@ -692,6 +692,12 @@ DivDispatchOscBuffer* DivPlatformYM2203Ext::getOscBuffer(int ch) {
return NULL;
}
int DivPlatformYM2203Ext::mapVelocity(int ch, float vel) {
if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel);
if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel);
return DivPlatformOPN::mapVelocity(ch,vel);
}
void DivPlatformYM2203Ext::reset() {
DivPlatformYM2203::reset();

View file

@ -34,6 +34,7 @@ class DivPlatformYM2203Ext: public DivPlatformYM2203 {
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
void reset();
void forceIns();
void tick(bool sysTick=true);

View file

@ -767,6 +767,12 @@ DivDispatchOscBuffer* DivPlatformYM2608Ext::getOscBuffer(int ch) {
return NULL;
}
int DivPlatformYM2608Ext::mapVelocity(int ch, float vel) {
if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel);
if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel);
return DivPlatformOPN::mapVelocity(ch,vel);
}
void DivPlatformYM2608Ext::reset() {
DivPlatformYM2608::reset();

View file

@ -35,6 +35,7 @@ class DivPlatformYM2608Ext: public DivPlatformYM2608 {
DivMacroInt* getChanMacroInt(int ch);
unsigned short getPan(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
void reset();
void forceIns();
void tick(bool sysTick=true);

View file

@ -757,6 +757,12 @@ DivDispatchOscBuffer* DivPlatformYM2610BExt::getOscBuffer(int ch) {
return NULL;
}
int DivPlatformYM2610BExt::mapVelocity(int ch, float vel) {
if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel);
if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel);
return DivPlatformOPN::mapVelocity(ch,vel);
}
void DivPlatformYM2610BExt::reset() {
DivPlatformYM2610B::reset();

View file

@ -35,6 +35,7 @@ class DivPlatformYM2610BExt: public DivPlatformYM2610B {
DivMacroInt* getChanMacroInt(int ch);
unsigned short getPan(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
void reset();
void forceIns();
void tick(bool sysTick=true);

View file

@ -757,6 +757,12 @@ DivDispatchOscBuffer* DivPlatformYM2610Ext::getOscBuffer(int ch) {
return NULL;
}
int DivPlatformYM2610Ext::mapVelocity(int ch, float vel) {
if (ch>=extChanOffs+4) return DivPlatformOPN::mapVelocity(ch-3,vel);
if (ch>=extChanOffs) return DivPlatformOPN::mapVelocity(extChanOffs,vel);
return DivPlatformOPN::mapVelocity(ch,vel);
}
void DivPlatformYM2610Ext::reset() {
DivPlatformYM2610::reset();

View file

@ -35,6 +35,7 @@ class DivPlatformYM2610Ext: public DivPlatformYM2610 {
DivMacroInt* getChanMacroInt(int ch);
unsigned short getPan(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
void reset();
void forceIns();
void tick(bool sysTick=true);