turn volume slider into mix slider
it's far more useful
This commit is contained in:
parent
a6d06d3728
commit
64b8a8f714
4 changed files with 49 additions and 13 deletions
|
|
@ -199,6 +199,10 @@ void DivFilePlayer::mix(float** buf, int chans, unsigned int size) {
|
|||
return;
|
||||
}
|
||||
|
||||
float actualVolume=volume+1.0f;
|
||||
if (actualVolume<0.0f) actualVolume=0.0f;
|
||||
if (actualVolume>1.0f) actualVolume=1.0f;
|
||||
|
||||
if (wantBlock!=DIV_NO_BLOCK) {
|
||||
cacheCV.notify_one();
|
||||
}
|
||||
|
|
@ -234,7 +238,7 @@ void DivFilePlayer::mix(float** buf, int chans, unsigned int size) {
|
|||
x[5]*t1[1]+
|
||||
x[6]*t1[2]+
|
||||
x[7]*t1[3]
|
||||
)*volume;
|
||||
)*actualVolume;
|
||||
|
||||
for (int j=0; j<chans; j++) {
|
||||
buf[j][i]=s;
|
||||
|
|
@ -257,7 +261,7 @@ void DivFilePlayer::mix(float** buf, int chans, unsigned int size) {
|
|||
x[5]*t1[1]+
|
||||
x[6]*t1[2]+
|
||||
x[7]*t1[3]
|
||||
)*volume;
|
||||
)*actualVolume;
|
||||
}
|
||||
|
||||
// advance
|
||||
|
|
@ -463,6 +467,14 @@ void DivFilePlayer::setVolume(float vol) {
|
|||
volume=vol;
|
||||
}
|
||||
|
||||
bool DivFilePlayer::getActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
void DivFilePlayer::setActive(bool active) {
|
||||
isActive=active;
|
||||
}
|
||||
|
||||
DivFilePlayer::DivFilePlayer():
|
||||
discardBuf(NULL),
|
||||
blocks(NULL),
|
||||
|
|
@ -474,11 +486,12 @@ DivFilePlayer::DivFilePlayer():
|
|||
wantBlock(DIV_NO_BLOCK),
|
||||
outRate(44100),
|
||||
rateAccum(0),
|
||||
volume(1.0f),
|
||||
volume(0.0f),
|
||||
playing(false),
|
||||
fileError(false),
|
||||
quitThread(false),
|
||||
threadHasQuit(false),
|
||||
isActive(false),
|
||||
cacheThread(NULL) {
|
||||
memset(&si,0,sizeof(SF_INFO));
|
||||
sincTable=DivFilterTables::getSincTable8();
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ class DivFilePlayer {
|
|||
bool fileError;
|
||||
bool quitThread;
|
||||
bool threadHasQuit;
|
||||
bool isActive;
|
||||
|
||||
std::thread* cacheThread;
|
||||
std::mutex cacheMutex;
|
||||
|
|
@ -89,6 +90,8 @@ class DivFilePlayer {
|
|||
void setOutputRate(int rate);
|
||||
float getVolume();
|
||||
void setVolume(float vol);
|
||||
bool getActive();
|
||||
void setActive(bool active);
|
||||
|
||||
DivFilePlayer();
|
||||
~DivFilePlayer();
|
||||
|
|
|
|||
|
|
@ -3287,6 +3287,18 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
}
|
||||
}
|
||||
|
||||
// calculate volume of reference file player (so we can attenuate the rest according to the mix slider)
|
||||
// -1 to 0: player volume goes from 0% to 100%
|
||||
// 0 to +1: tracker volume goes from 100% to 0%
|
||||
float refPlayerVol=1.0f;
|
||||
if (curFilePlayer!=NULL) {
|
||||
// only if the player window is open
|
||||
if (curFilePlayer->getActive()) {
|
||||
refPlayerVol=1.0f-curFilePlayer->getVolume();
|
||||
if (refPlayerVol>1.0f) refPlayerVol=1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// now mix everything (resolve patchbay)
|
||||
for (unsigned int i: song.patchbay) {
|
||||
// there are 4096 portsets. each portset may have up to 16 outputs (subports).
|
||||
|
|
@ -3308,7 +3320,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
// chip outputs
|
||||
if (srcPortSet<song.systemLen && playing && !halted) {
|
||||
if (srcSubPort<disCont[srcPortSet].dispatch->getOutputCount()) {
|
||||
float vol=song.systemVol[srcPortSet]*disCont[srcPortSet].dispatch->getPostAmp()*song.masterVol;
|
||||
float vol=song.systemVol[srcPortSet]*disCont[srcPortSet].dispatch->getPostAmp()*song.masterVol*refPlayerVol;
|
||||
|
||||
// apply volume and panning
|
||||
switch (destSubPort&3) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue