diff --git a/src/engine/filePlayer.cpp b/src/engine/filePlayer.cpp index 1c4394d7a..2b2b493ca 100644 --- a/src/engine/filePlayer.cpp +++ b/src/engine/filePlayer.cpp @@ -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; jgetActive()) { + 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 (srcPortSetgetOutputCount()) { - 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) { diff --git a/src/gui/refPlayer.cpp b/src/gui/refPlayer.cpp index 32190735e..c2099f163 100644 --- a/src/gui/refPlayer.cpp +++ b/src/gui/refPlayer.cpp @@ -23,15 +23,16 @@ #include "IconsFontAwesome4.h" void FurnaceGUI::drawRefPlayer() { + DivFilePlayer* fp=e->getFilePlayer(); if (nextWindow==GUI_WINDOW_REF_PLAYER) { refPlayerOpen=true; ImGui::SetNextWindowFocus(); nextWindow=GUI_WINDOW_NOTHING; } + fp->setActive(refPlayerOpen); if (!refPlayerOpen) return; - if (ImGui::Begin("Music Player",&refPlayerOpen,globalWinFlags,_("Music Player"))) { - DivFilePlayer* fp=e->getFilePlayer(); + if (ImGui::Begin("Music Player",&refPlayerOpen,globalWinFlags,_("Music Player"))) { bool playPosNegative=false; ssize_t playPos=fp->getPos(); if (playPos<0) { @@ -85,23 +86,30 @@ void FurnaceGUI::drawRefPlayer() { } popToggleColors(); e->setFilePlayerSync(filePlayerSync); + + ImGui::SameLine(); + ImGui::Text(_("Mix:")); float vol=fp->getVolume(); ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::SliderFloat("##Volume",&vol,0.0f,1.0f)) { - if (vol<0.0f) vol=0.0f; + if (ImGui::SliderFloat("##Volume",&vol,-1.0f,1.0f,_("<-- Tracker / Reference -->"))) { + if (vol<-1.0f) vol=-1.0f; if (vol>1.0f) vol=1.0f; fp->setVolume(vol); } + if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { + fp->setVolume(0.0f); + } //ImGui::Text("Memory usage: %" PRIu64 "K",fp->getMemUsage()>>10); - - if (!refPlayerOpen) { - fp->stop(); - e->setFilePlayerSync(false); - } } if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_REF_PLAYER; ImGui::End(); + + + if (!refPlayerOpen) { + fp->stop(); + e->setFilePlayerSync(false); + } }