Add volume (2 levels)
This commit is contained in:
parent
30448dd09c
commit
6d5328beb3
|
@ -50,6 +50,11 @@ void DivPlatformPV1000::acquire(short** buf, size_t len) {
|
||||||
void DivPlatformPV1000::tick(bool sysTick) {
|
void DivPlatformPV1000::tick(bool sysTick) {
|
||||||
for (int i=0; i<3; i++) {
|
for (int i=0; i<3; i++) {
|
||||||
chan[i].std.next();
|
chan[i].std.next();
|
||||||
|
if (chan[i].std.vol.had) {
|
||||||
|
chan[i].outVol=VOL_SCALE_LINEAR(chan[i].std.vol.val,chan[i].vol,1);
|
||||||
|
if (chan[i].outVol<0) chan[i].outVol=0;
|
||||||
|
chan[i].writeVol=true;
|
||||||
|
}
|
||||||
if (NEW_ARP_STRAT) {
|
if (NEW_ARP_STRAT) {
|
||||||
chan[i].handleArp();
|
chan[i].handleArp();
|
||||||
} else if (chan[i].std.arp.had) {
|
} else if (chan[i].std.arp.had) {
|
||||||
|
@ -73,10 +78,10 @@ void DivPlatformPV1000::tick(bool sysTick) {
|
||||||
if (chan[i].freq>62) chan[i].freq=62;
|
if (chan[i].freq>62) chan[i].freq=62;
|
||||||
if (isMuted[i]) chan[i].keyOn=false;
|
if (isMuted[i]) chan[i].keyOn=false;
|
||||||
if (chan[i].keyOn) {
|
if (chan[i].keyOn) {
|
||||||
rWrite(i,chan[i].freq);
|
rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq);
|
||||||
chan[i].keyOn=false;
|
chan[i].keyOn=false;
|
||||||
} else if (chan[i].freqChanged && chan[i].active && !isMuted[i]) {
|
} else if (chan[i].freqChanged && chan[i].active && !isMuted[i]) {
|
||||||
rWrite(i,chan[i].freq);
|
rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq);
|
||||||
}
|
}
|
||||||
if (chan[i].keyOff) {
|
if (chan[i].keyOff) {
|
||||||
rWrite(i,0);
|
rWrite(i,0);
|
||||||
|
@ -85,6 +90,12 @@ void DivPlatformPV1000::tick(bool sysTick) {
|
||||||
chan[i].freqChanged=false;
|
chan[i].freqChanged=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i=0; i<3; i++) {
|
||||||
|
if (chan[i].writeVol) {
|
||||||
|
rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq);
|
||||||
|
chan[i].writeVol=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivPlatformPV1000::dispatch(DivCommand c) {
|
int DivPlatformPV1000::dispatch(DivCommand c) {
|
||||||
|
@ -97,6 +108,7 @@ int DivPlatformPV1000::dispatch(DivCommand c) {
|
||||||
chan[c.chan].note=c.value;
|
chan[c.chan].note=c.value;
|
||||||
}
|
}
|
||||||
chan[c.chan].active=true;
|
chan[c.chan].active=true;
|
||||||
|
chan[c.chan].writeVol=true;
|
||||||
chan[c.chan].keyOn=true;
|
chan[c.chan].keyOn=true;
|
||||||
chan[c.chan].macroInit(ins);
|
chan[c.chan].macroInit(ins);
|
||||||
break;
|
break;
|
||||||
|
@ -115,6 +127,17 @@ int DivPlatformPV1000::dispatch(DivCommand c) {
|
||||||
chan[c.chan].ins=c.value;
|
chan[c.chan].ins=c.value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case DIV_CMD_VOLUME:
|
||||||
|
if (chan[c.chan].vol!=c.value) {
|
||||||
|
chan[c.chan].vol=c.value;
|
||||||
|
if (!chan[c.chan].std.vol.has) {
|
||||||
|
chan[c.chan].outVol=c.value;
|
||||||
|
}
|
||||||
|
if (chan[c.chan].active) {
|
||||||
|
chan[c.chan].writeVol=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DIV_CMD_GET_VOLUME:
|
case DIV_CMD_GET_VOLUME:
|
||||||
return chan[c.chan].vol;
|
return chan[c.chan].vol;
|
||||||
break;
|
break;
|
||||||
|
@ -158,7 +181,7 @@ int DivPlatformPV1000::dispatch(DivCommand c) {
|
||||||
chan[c.chan].inPorta=c.value;
|
chan[c.chan].inPorta=c.value;
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_GET_VOLMAX:
|
case DIV_CMD_GET_VOLMAX:
|
||||||
return 15;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_MACRO_OFF:
|
case DIV_CMD_MACRO_OFF:
|
||||||
chan[c.chan].std.mask(c.value,true);
|
chan[c.chan].std.mask(c.value,true);
|
||||||
|
@ -181,6 +204,7 @@ void DivPlatformPV1000::muteChannel(int ch, bool mute) {
|
||||||
chan[ch].keyOff=true;
|
chan[ch].keyOff=true;
|
||||||
} else if (chan[ch].active) {
|
} else if (chan[ch].active) {
|
||||||
chan[ch].keyOn=true;
|
chan[ch].keyOn=true;
|
||||||
|
chan[ch].writeVol=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,10 @@
|
||||||
|
|
||||||
class DivPlatformPV1000: public DivDispatch {
|
class DivPlatformPV1000: public DivDispatch {
|
||||||
struct Channel: public SharedChannel<int> {
|
struct Channel: public SharedChannel<int> {
|
||||||
|
bool writeVol;
|
||||||
Channel():
|
Channel():
|
||||||
SharedChannel<int>(15) {}
|
SharedChannel<int>(1),
|
||||||
|
writeVol(false) {}
|
||||||
};
|
};
|
||||||
Channel chan[3];
|
Channel chan[3];
|
||||||
DivDispatchOscBuffer* oscBuf[3];
|
DivDispatchOscBuffer* oscBuf[3];
|
||||||
|
|
Loading…
Reference in New Issue