implement getGain for a couple chips

the ones with log volume
This commit is contained in:
tildearrow 2024-07-22 19:08:39 -05:00
parent b108156954
commit b2223ccd0f
17 changed files with 65 additions and 1 deletions

View file

@ -2330,6 +2330,13 @@ int DivEngine::mapVelocity(int ch, float vel) {
return disCont[dispatchOfChan[ch]].dispatch->mapVelocity(dispatchChanOfChan[ch],vel);
}
float DivEngine::getGain(int ch, int vol) {
if (ch<0) return 0;
if (ch>=chans) return 0;
if (disCont[dispatchOfChan[ch]].dispatch==NULL) return 0;
return disCont[dispatchOfChan[ch]].dispatch->getGain(dispatchChanOfChan[ch],vol);
}
unsigned char DivEngine::getOrder() {
return prevOrder;
}

View file

@ -927,6 +927,9 @@ class DivEngine {
// map MIDI velocity to volume
int mapVelocity(int ch, float vel);
// map volume to gain
float getGain(int ch, int vol);
// get current order
unsigned char getOrder();

View file

@ -801,6 +801,11 @@ int DivPlatformAY8910::mapVelocity(int ch, float vel) {
return round(15.0*pow(vel,0.33));
}
float DivPlatformAY8910::getGain(int ch, int vol) {
if (vol==0) return 0;
return 1.0/pow(10.0,(float)(15-vol)*2.0/20.0);
}
unsigned char* DivPlatformAY8910::getRegisterPool() {
return regPool;
}

View file

@ -144,6 +144,7 @@ class DivPlatformAY8910: public DivDispatch {
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
float getGain(int ch, int vol);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void setCore(unsigned char core);

View file

@ -792,6 +792,11 @@ int DivPlatformAY8930::mapVelocity(int ch, float vel) {
return round(31.0*pow(vel,0.22));
}
float DivPlatformAY8930::getGain(int ch, int vol) {
if (vol==0) return 0;
return 1.0/pow(10.0,(float)(31-vol)*1.5/20.0);
}
unsigned char* DivPlatformAY8930::getRegisterPool() {
return regPool;
}

View file

@ -138,6 +138,7 @@ class DivPlatformAY8930: public DivDispatch {
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
float getGain(int ch, int vol);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();

View file

@ -198,6 +198,19 @@ class DivPlatformOPN: public DivPlatformFMBase {
if (ch>=psgChanOffs) return round(15.0*pow(vel,0.33));
return DivPlatformFMBase::mapVelocity(ch,vel);
}
virtual float getGain(int ch, int vol) {
if (vol==0) return 0;
if (ch==csmChan) return 1;
if (ch==adpcmBChanOffs) return (float)vol/255.0;
if (ch>=adpcmAChanOffs) {
return 1.0/pow(10.0,(float)(31-vol)*0.75/20.0);
}
if (ch>=psgChanOffs) {
return 1.0/pow(10.0,(float)(15-vol)*1.5/20.0);
}
return DivPlatformFMBase::getGain(ch,vol);
}
};
#endif

View file

@ -136,6 +136,11 @@ class DivPlatformFMBase: public DivDispatch {
return CLAMP(round(128.0-(56.0-log2(vel*127.0)*8.0)),0,127);
}
virtual float getGain(int ch, int vol) {
if (vol==0) return 0;
return 1.0/pow(10.0,(float)(127-vol)*0.75/20.0);
}
bool getLegacyAlwaysSetVolume() {
return true;
}

View file

@ -2140,6 +2140,11 @@ int DivPlatformOPL::mapVelocity(int ch, float vel) {
return CLAMP(round(64.0-(56.0-log2(vel*127.0)*8.0)),0,63);
}
float DivPlatformOPL::getGain(int ch, int vol) {
if (vol==0) return 0;
return 1.0/pow(10.0,(float)(63-vol)*0.75/20.0);
}
unsigned char* DivPlatformOPL::getRegisterPool() {
return regPool;
}

View file

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

View file

@ -1026,6 +1026,11 @@ int DivPlatformOPLL::mapVelocity(int ch, float vel) {
return CLAMP(round(16.0-(14.0-log2(vel*127.0)*2.0)),0,15);
}
float DivPlatformOPLL::getGain(int ch, int vol) {
if (vol==0) return 0;
return 1.0/pow(10.0,(float)(15-vol)*3.0/20.0);
}
unsigned char* DivPlatformOPLL::getRegisterPool() {
return regPool;
}

View file

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

View file

@ -575,6 +575,11 @@ int DivPlatformPCE::mapVelocity(int ch, float vel) {
return round(31.0*pow(vel,0.22));
}
float DivPlatformPCE::getGain(int ch, int vol) {
if (vol==0) return 0;
return 1.0/pow(10.0,(float)(31-vol)*3.0/20.0);
}
unsigned char* DivPlatformPCE::getRegisterPool() {
return regPool;
}

View file

@ -90,6 +90,7 @@ class DivPlatformPCE: public DivDispatch {
DivSamplePos getSamplePos(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
float getGain(int ch, int vol);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();

View file

@ -466,6 +466,11 @@ int DivPlatformSMS::mapVelocity(int ch, float vel) {
return round(15.0*pow(vel,0.33));
}
float DivPlatformSMS::getGain(int ch, int vol) {
if (vol==0) return 0;
return 1.0/pow(10.0,(float)(15-vol)*2.0/20.0);
}
unsigned char* DivPlatformSMS::getRegisterPool() {
return regPool;
}

View file

@ -80,6 +80,7 @@ class DivPlatformSMS: public DivDispatch {
unsigned short getPan(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
int mapVelocity(int ch, float vel);
float getGain(int ch, int vol);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
void reset();

View file

@ -4680,7 +4680,7 @@ bool FurnaceGUI::loop() {
if (maxVol<1 || p->data[cursor.y][3]>maxVol) {
info=fmt::sprintf(_("Set volume: %d (%.2X, INVALID!)"),p->data[cursor.y][3],p->data[cursor.y][3]);
} else {
float realVol=e->mapVelocity(cursor.xCoarse,(float)p->data[cursor.y][3]/(float)maxVol);
float realVol=e->getGain(cursor.xCoarse,p->data[cursor.y][3]);
info=fmt::sprintf(_("Set volume: %d (%.2X, %d%%)"),p->data[cursor.y][3],p->data[cursor.y][3],(int)(realVol*100.0f/(float)maxVol));
}
hasInfo=true;