prepare to add function for mapping vol to percent

This commit is contained in:
tildearrow 2024-07-14 19:58:33 -05:00
parent 7a6e41f482
commit 482f5de0fe
2 changed files with 13 additions and 0 deletions

View file

@ -681,6 +681,14 @@ class DivDispatch {
*/ */
virtual int mapVelocity(int ch, float vel); virtual int mapVelocity(int ch, float vel);
/**
* map chip volume to gain.
* @param ch the chip channel. -1 means N/A.
* @param vol input volume.
* @return output gain fron 0.0 to 1.0.
*/
virtual float getGain(int ch, int vol);
/** /**
* get the lowest note in a portamento. * get the lowest note in a portamento.
* @param ch the channel in question. * @param ch the channel in question.

View file

@ -107,6 +107,11 @@ int DivDispatch::mapVelocity(int ch, float vel) {
return round(vel*volMax); return round(vel*volMax);
} }
float DivDispatch::getGain(int ch, int vol) {
const float volMax=MAX(1,dispatch(DivCommand(DIV_CMD_GET_VOLMAX,MAX(ch,0))));
return (float)vol/volMax;
}
int DivDispatch::getPortaFloor(int ch) { int DivDispatch::getPortaFloor(int ch) {
return 0x00; return 0x00;
} }