chanOsc automatic columns + fix chanOsc channel note text (#1305)

* chanOsc note name

* chanOsc auto cols

* lowercase c for consistency

* fix chan note text

* change int to short

* simplify

* visible chan count for calculation

* cleanup

* cleanup 2 (not removing the comma yet)

* remove extra spaces

* add id
This commit is contained in:
Eknous 2023-08-03 14:25:26 +04:00 committed by GitHub
parent 69c4c58cc5
commit cafc6f391d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 2 deletions

View file

@ -41,6 +41,13 @@ const char* chanOscRefs[]={
"Note Trigger"
};
const char* autoColsTypes[]={
"Off",
"Mode 1",
"Mode 2",
"Mode 3"
};
float FurnaceGUI::computeGradPos(int type, int chan) {
switch (type) {
case GUI_OSCREF_NONE:
@ -146,6 +153,19 @@ void FurnaceGUI::drawChanOsc() {
centerSettingReset=true;
}
ImGui::TableNextColumn();
ImGui::Text("Automatic columns");
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
const char* previewColType = autoColsTypes[chanOscAutoColsType&3];
if (ImGui::BeginCombo("##AutoCols",previewColType)) {
for (int j=0; j<4; j++) {
const bool isSelected=(chanOscAutoColsType==j);
if (ImGui::Selectable(autoColsTypes[j],isSelected)) chanOscAutoColsType=j;
if (isSelected) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::EndTable();
}
@ -346,6 +366,16 @@ void FurnaceGUI::drawChanOsc() {
oscChans.push_back(i);
}
}
switch (chanOscAutoColsType) {
case 1: chanOscCols=sqrt(oscChans.size()); break;
case 2: chanOscCols=sqrt(oscChans.size()+1); break;
case 3: chanOscCols=sqrt(oscChans.size())+1; break;
default: break;
}
if (chanOscCols<1) chanOscCols=1;
if (chanOscCols>64) chanOscCols=64;
int rows=(oscBufs.size()+(chanOscCols-1))/chanOscCols;
for (size_t i=0; i<oscBufs.size(); i++) {
@ -543,7 +573,10 @@ void FurnaceGUI::drawChanOsc() {
case 'n': {
DivChannelState* chanState=e->getChanState(ch);
if (chanState==NULL || !(chanState->keyOn)) break;
text+=fmt::sprintf("%s",noteName(short (chanState->note),0));
short tempNote=chanState->note; //all of this conversion is necessary because notes 100-102 are special chars
short noteMod=tempNote%12+12; //also note 0 is a BUG, hence +12 on the note and -1 on the octave
short oct=tempNote/12-1;
text+=fmt::sprintf("%s",noteName(noteMod,oct));
break;
}
case '%':

View file

@ -6126,6 +6126,7 @@ bool FurnaceGUI::init() {
pianoInputPadMode=e->getConfInt("pianoInputPadMode",pianoInputPadMode);
chanOscCols=e->getConfInt("chanOscCols",3);
chanOscAutoColsType=e->getConfInt("chanOscAutoColsType",0);
chanOscColorX=e->getConfInt("chanOscColorX",GUI_OSCREF_CENTER);
chanOscColorY=e->getConfInt("chanOscColorY",GUI_OSCREF_CENTER);
chanOscTextX=e->getConfFloat("chanOscTextX",0.0f);
@ -6643,6 +6644,7 @@ void FurnaceGUI::commitState() {
// commit per-chan osc state
e->setConf("chanOscCols",chanOscCols);
e->setConf("chanOscAutoColsType",chanOscAutoColsType);
e->setConf("chanOscColorX",chanOscColorX);
e->setConf("chanOscColorY",chanOscColorY);
e->setConf("chanOscTextX",chanOscTextX);
@ -7086,6 +7088,7 @@ FurnaceGUI::FurnaceGUI():
oscWindowSize(20.0f),
oscZoomSlider(false),
chanOscCols(3),
chanOscAutoColsType(0),
chanOscColorX(GUI_OSCREF_CENTER),
chanOscColorY(GUI_OSCREF_CENTER),
chanOscWindowSize(20.0f),

View file

@ -1970,7 +1970,7 @@ class FurnaceGUI {
bool oscZoomSlider;
// per-channel oscilloscope
int chanOscCols, chanOscColorX, chanOscColorY;
int chanOscCols, chanOscAutoColsType, chanOscColorX, chanOscColorY;
float chanOscWindowSize, chanOscTextX, chanOscTextY, chanOscAmplify;
bool chanOscWaveCorr, chanOscOptions, updateChanOscGradTex, chanOscUseGrad, chanOscNormalize;
String chanOscTextFormat;