diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a9ef298ca..eb0d42717 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5048,6 +5048,7 @@ bool FurnaceGUI::loop() { } MEASURE(calcChanOsc,calcChanOsc()); + updateKeyHitPre(); if (mobileUI) { globalWinFlags=ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoBringToFrontOnFocus; @@ -5194,10 +5195,7 @@ bool FurnaceGUI::loop() { } } - for (int i=0; igetTotalChannelCount(); i++) { - keyHit1[i]-=0.08f; - if (keyHit1[i]<0.0f) keyHit1[i]=0.0f; - } + updateKeyHitPost(); if (inspectorOpen) ImGui::ShowMetricsWindow(&inspectorOpen); diff --git a/src/gui/gui.h b/src/gui/gui.h index e8df00eec..a475dd6dd 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -3022,6 +3022,9 @@ class FurnaceGUI { ImVec2 mapSelPoint(const SelectionPoint& s, float lineHeight); void patternRow(int i, bool isPlaying, float lineHeight, int chans, int ord, const DivPattern** patCache, bool inhibitSel); + void updateKeyHitPre(); + void updateKeyHitPost(); + void drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float availableWidth, int index); void drawMacros(std::vector& macros, FurnaceGUIMacroEditState& state, DivInstrument* ins); void alterSampleMap(int column, int val); diff --git a/src/gui/newPattern.cpp b/src/gui/newPattern.cpp index 551f5c46f..254b34ec7 100644 --- a/src/gui/newPattern.cpp +++ b/src/gui/newPattern.cpp @@ -358,7 +358,6 @@ void FurnaceGUI::drawPatternNew() { if (!e->curSubSong->chanShow[i]) continue; ImGui::SetCursorScreenPos(ImVec2(topHeaders.x+patChanX[i]+sizeRows.x,topHeaders.y)); // skip off-screen channels - // TODO: may cause issues with keyHit. test! if (ImGui::GetCursorScreenPos().x>winRect.Max.x) break; if (ImGui::GetCursorScreenPos().x+patChanX[i+1]-patChanX[i]keyHit[i]) { - keyHit1[i]=1.0f; - - if (chanOscRandomPhase) { - chanOscChan[i].phaseOff=(float)rand()/(float)RAND_MAX; - } else { - chanOscChan[i].phaseOff=0.0f; - } - - if (settings.channelFeedbackStyle==1) { - keyHit[i]=0.2; - if (!muted) { - int note=e->getChanState(i)->note+60; - if (note>=0 && note<180) { - pianoKeyHit[note].value=1.0; - pianoKeyHit[note].chan=i; - } - } - } - e->keyHit[i]=false; - } - if (settings.channelFeedbackStyle==2 && e->isRunning()) { - float amount=((float)(e->getChanState(i)->volume>>8)/(float)e->getMaxVolumeChan(i)); - if (e->getChanState(i)->keyOff) amount=0.0f; - keyHit[i]=amount*0.2f; - if (!muted && e->getChanState(i)->keyOn) { - int note=e->getChanState(i)->note+60; - if (note>=0 && note<180) { - pianoKeyHit[note].value=amount; - pianoKeyHit[note].chan=i; - } - } - } else if (settings.channelFeedbackStyle==3 && e->isRunning()) { - bool active=e->getChanState(i)->keyOn; - keyHit[i]=active?0.2f:0.0f; - if (!muted) { - int note=e->getChanState(i)->note+60; - if (note>=0 && note<180) { - pianoKeyHit[note].value=active?1.0f:0.0f; - pianoKeyHit[note].chan=i; - } - } - } else if (settings.channelFeedbackStyle==4 && e->isRunning()) { - float amount=powf(chanOscVol[i],settings.channelFeedbackGamma); - if (isnan(amount)) amount=0; // how is it nan tho?? - if (e->getChanState(i)->keyOff) amount=0.0f; - keyHit[i]=amount*0.2f; - if (!muted && e->getChanState(i)->keyOn) { - int note=e->getChanState(i)->note+60; - if (note>=0 && note<180) { - pianoKeyHit[note].value=amount; - pianoKeyHit[note].chan=i; - } - } - } // set key hit colors if (settings.guiColorsBase) { chanHead.x*=1.0-keyHit[i]; chanHead.y*=1.0-keyHit[i]; chanHead.z*=1.0-keyHit[i]; @@ -438,8 +381,7 @@ void FurnaceGUI::drawPatternNew() { chanHeadActive.x*=0.8; chanHeadActive.y*=0.8; chanHeadActive.z*=0.8; chanHeadHover.x*=0.4+keyHit[i]; chanHeadHover.y*=0.4+keyHit[i]; chanHeadHover.z*=0.4+keyHit[i]; } - keyHit[i]-=((settings.channelStyle==0)?0.02:0.01)*60.0*ImGui::GetIO().DeltaTime; - if (keyHit[i]<0) keyHit[i]=0; + // push colors ImGui::PushStyleColor(ImGuiCol_Header,chanHead); ImGui::PushStyleColor(ImGuiCol_HeaderActive,chanHeadActive); @@ -707,11 +649,6 @@ void FurnaceGUI::drawPatternNew() { float xLeft=0.0f; float xRight=1.0f; - if (e->keyHit[i]) { - keyHit1[i]=1.0f; - e->keyHit[i]=false; - } - if (e->isRunning()) { DivChannelState* cs=e->getChanState(i); unsigned short chanPan=e->getChanPan(i); @@ -2196,3 +2133,75 @@ void FurnaceGUI::drawPatternNew() { ImGui::End(); } +void FurnaceGUI::updateKeyHitPre() { + for (int i=0; igetTotalChannelCount(); i++) { + bool muted=e->isChannelMuted(i); + + // update key hit + if (e->keyHit[i]) { + keyHit1[i]=1.0f; + + if (chanOscRandomPhase) { + chanOscChan[i].phaseOff=(float)rand()/(float)RAND_MAX; + } else { + chanOscChan[i].phaseOff=0.0f; + } + + if (settings.channelFeedbackStyle==1) { + keyHit[i]=0.2; + if (!muted) { + int note=e->getChanState(i)->note+60; + if (note>=0 && note<180) { + pianoKeyHit[note].value=1.0; + pianoKeyHit[note].chan=i; + } + } + } + e->keyHit[i]=false; + } + if (settings.channelFeedbackStyle==2 && e->isRunning()) { + float amount=((float)(e->getChanState(i)->volume>>8)/(float)e->getMaxVolumeChan(i)); + if (e->getChanState(i)->keyOff) amount=0.0f; + keyHit[i]=amount*0.2f; + if (!muted && e->getChanState(i)->keyOn) { + int note=e->getChanState(i)->note+60; + if (note>=0 && note<180) { + pianoKeyHit[note].value=amount; + pianoKeyHit[note].chan=i; + } + } + } else if (settings.channelFeedbackStyle==3 && e->isRunning()) { + bool active=e->getChanState(i)->keyOn; + keyHit[i]=active?0.2f:0.0f; + if (!muted) { + int note=e->getChanState(i)->note+60; + if (note>=0 && note<180) { + pianoKeyHit[note].value=active?1.0f:0.0f; + pianoKeyHit[note].chan=i; + } + } + } else if (settings.channelFeedbackStyle==4 && e->isRunning()) { + float amount=powf(chanOscVol[i],settings.channelFeedbackGamma); + if (isnan(amount)) amount=0; // how is it nan tho?? + if (e->getChanState(i)->keyOff) amount=0.0f; + keyHit[i]=amount*0.2f; + if (!muted && e->getChanState(i)->keyOn) { + int note=e->getChanState(i)->note+60; + if (note>=0 && note<180) { + pianoKeyHit[note].value=amount; + pianoKeyHit[note].chan=i; + } + } + } + } +} + +void FurnaceGUI::updateKeyHitPost() { + for (int i=0; igetTotalChannelCount(); i++) { + keyHit[i]-=((settings.channelStyle==0)?0.02:0.01)*60.0*ImGui::GetIO().DeltaTime; + if (keyHit[i]<0) keyHit[i]=0; + + keyHit1[i]-=0.08f; + if (keyHit1[i]<0.0f) keyHit1[i]=0.0f; + } +}