chan color in piano and real volume chan feedback (w/ gamma correction)

now i can recreate the bee video! :>
This commit is contained in:
Eknous-P 2025-11-14 18:37:23 +04:00
parent 44ec4f70da
commit f93dd893c8
5 changed files with 50 additions and 14 deletions

View file

@ -9385,7 +9385,7 @@ FurnaceGUI::FurnaceGUI():
memset(lastAudioLoads,0,sizeof(float)*120);
memset(pianoKeyHit,0,sizeof(float)*180);
memset(pianoKeyHit,0,sizeof(pianoKeyState)*180); // posiblly repace with a for loop
memset(pianoKeyPressed,0,sizeof(bool)*180);
memset(queryReplaceEffectMode,0,sizeof(int)*8);

View file

@ -2090,6 +2090,7 @@ class FurnaceGUI {
int sampleImportInstDetune;
int mixerStyle;
int mixerLayout;
float channelFeedbackGamma;
String mainFontPath;
String headFontPath;
String patFontPath;
@ -2344,6 +2345,7 @@ class FurnaceGUI {
sampleImportInstDetune(0),
mixerStyle(1),
mixerLayout(0),
channelFeedbackGamma(1.0f),
mainFontPath(""),
headFontPath(""),
patFontPath(""),
@ -2839,7 +2841,11 @@ class FurnaceGUI {
int pianoOctaves, pianoOctavesEdit;
bool pianoOptions, pianoSharePosition, pianoOptionsSet;
float pianoKeyHit[180];
struct pianoKeyState {
float value;
int chan;
};
pianoKeyState pianoKeyHit[180];
bool pianoKeyPressed[180];
bool pianoReadonly;
int pianoOffset, pianoOffsetEdit;

View file

@ -666,7 +666,8 @@ void FurnaceGUI::drawPattern() {
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note]=1.0;
pianoKeyHit[note].value=1.0;
pianoKeyHit[note].chan=i;
}
}
}
@ -679,7 +680,8 @@ void FurnaceGUI::drawPattern() {
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note]=amount;
pianoKeyHit[note].value=amount;
pianoKeyHit[note].chan=i;
}
}
} else if (settings.channelFeedbackStyle==3 && e->isRunning()) {
@ -688,7 +690,19 @@ void FurnaceGUI::drawPattern() {
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note]=active?1.0f:0.0f;
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 (!e->getChanState(i)->keyOn) amount=0.0f;
keyHit[i]=amount*0.2f;
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note].value=amount;
pianoKeyHit[note].chan=i;
}
}
}

View file

@ -297,12 +297,12 @@ void FurnaceGUI::drawPiano() {
int note=i+12*off;
if (note<0) continue;
if (note>=180) continue;
float pkh=pianoKeyHit[note];
float pkh=pianoKeyHit[note].value;
ImVec4 color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM];
if (pianoKeyPressed[note]) {
color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE];
} else {
ImVec4 colorHit=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT];
ImVec4 colorHit=1?channelColor(pianoKeyHit[note].chan):(isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT]);
color.x+=(colorHit.x-color.x)*pkh;
color.y+=(colorHit.y-color.y)*pkh;
color.z+=(colorHit.z-color.z)*pkh;
@ -355,12 +355,12 @@ void FurnaceGUI::drawPiano() {
if (note<0) continue;
if (note>=180) continue;
float pkh=pianoKeyHit[note];
float pkh=pianoKeyHit[note].value;
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM];
if (pianoKeyPressed[note]) {
color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE];
} else {
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT];
ImVec4 colorHit=1?channelColor(pianoKeyHit[note].chan):uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT];
color.x+=(colorHit.x-color.x)*pkh;
color.y+=(colorHit.y-color.y)*pkh;
color.z+=(colorHit.z-color.z)*pkh;
@ -383,12 +383,12 @@ void FurnaceGUI::drawPiano() {
int note=topKeyNotes[j]+12*(i+off);
if (note<0) continue;
if (note>=180) continue;
float pkh=pianoKeyHit[note];
float pkh=pianoKeyHit[note].value;
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_TOP];
if (pianoKeyPressed[note]) {
color=uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE];
} else {
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT];
ImVec4 colorHit=1?channelColor(pianoKeyHit[note].chan):uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT];
color.x+=(colorHit.x-color.x)*pkh;
color.y+=(colorHit.y-color.y)*pkh;
color.z+=(colorHit.z-color.z)*pkh;
@ -407,8 +407,8 @@ void FurnaceGUI::drawPiano() {
const float reduction=ImGui::GetIO().DeltaTime*60.0f*0.12;
for (int i=0; i<180; i++) {
pianoKeyHit[i]-=reduction;
if (pianoKeyHit[i]<0) pianoKeyHit[i]=0;
pianoKeyHit[i].value-=reduction;
if (pianoKeyHit[i].value<0) pianoKeyHit[i].value=0;
}
}

View file

@ -3505,6 +3505,19 @@ void FurnaceGUI::drawSettings() {
settings.channelFeedbackStyle=3;
settingsChanged=true;
}
if (ImGui::RadioButton(_("Volume (Real)##CHF4"),settings.channelFeedbackStyle==4)) {
settings.channelFeedbackStyle=4;
settingsChanged=true;
}
if (settings.channelFeedbackStyle==4) {
ImGui::Indent();
if (ImGui::SliderFloat(_("Gamma##CHF"),&settings.channelFeedbackGamma,0.0f,2.0f)) {
if (settings.channelFeedbackGamma<0.0f) settings.channelFeedbackGamma=0.0f;
if (settings.channelFeedbackGamma>2.0f) settings.channelFeedbackGamma=2.0f;
settingsChanged=true;
}
ImGui::Unindent();
}
ImGui::Unindent();
ImGui::Text(_("Channel font:"));
@ -5123,6 +5136,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
settings.channelStyle=conf.getInt("channelStyle",1);
settings.channelVolStyle=conf.getInt("channelVolStyle",0);
settings.channelFeedbackStyle=conf.getInt("channelFeedbackStyle",1);
settings.channelFeedbackGamma=conf.getFloat("channelFeedbackGamma",1.0f);
settings.channelFont=conf.getInt("channelFont",1);
settings.channelTextCenter=conf.getInt("channelTextCenter",1);
@ -5399,7 +5413,8 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
clampSetting(settings.channelTextColors,0,2);
clampSetting(settings.channelStyle,0,5);
clampSetting(settings.channelVolStyle,0,4);
clampSetting(settings.channelFeedbackStyle,0,3);
clampSetting(settings.channelFeedbackStyle,0,4);
clampSetting(settings.channelFeedbackGamma,0.0f,2.0f);
clampSetting(settings.channelFont,0,1);
clampSetting(settings.channelTextCenter,0,1);
clampSetting(settings.maxRecentFile,0,30);
@ -5711,6 +5726,7 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
conf.set("channelStyle",settings.channelStyle);
conf.set("channelVolStyle",settings.channelVolStyle);
conf.set("channelFeedbackStyle",settings.channelFeedbackStyle);
conf.set("channelFeedbackGamma",settings.channelFeedbackGamma);
conf.set("channelFont",settings.channelFont);
conf.set("channelTextCenter",settings.channelTextCenter);