Skip to content

Commit fc188ae

Browse files
committed
Renderer: add debug infos to set list settings panel.
1 parent 0f5a0db commit fc188ae

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

src/rendering/Renderer.cpp

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,6 @@ void Renderer::showSetEditor(){
11601160

11611161
// For editing.
11621162
static SetOptions::KeyFrame newKey;
1163-
bool refreshSetOptions = false;
11641163

11651164
// Initial window position.
11661165
const ImVec2 & screenSize = ImGui::GetIO().DisplaySize;
@@ -1169,8 +1168,10 @@ void Renderer::showSetEditor(){
11691168

11701169
if(ImGui::Begin("Set List Editor", &_showSetListEditor)){
11711170

1171+
bool refreshSetOptions = false;
1172+
11721173
// Header
1173-
ImGui::Text("Control points will determine which range of notes belong to each set at a given time. All notes below the given key will be assigned to the specified set (except if a set with a lower number is defined). Control points will kept being applied until a new one is encountered for the set.");
1174+
ImGui::TextWrapped("Control points will determine which range of notes belong to each set at a given time. All notes below the given key will be assigned to the specified set (except if a set with a lower number is defined). Control points will kept being applied until a new one is encountered for the set.");
11741175

11751176
// Load/save as CSV.
11761177
if(ImGui::Button("Save control points...")){
@@ -1296,16 +1297,56 @@ void Renderer::showSetEditor(){
12961297
// If we are exiting, refresh the existing set.
12971298
refreshSetOptions = true;
12981299
}
1299-
}
1300-
ImGui::End();
13011300

1302-
// If refresh is needed, ensure the set options are rebuilt and the scene udpated for live preview.
1303-
if(refreshSetOptions){
1304-
_state.setOptions.rebuild();
1305-
if(_scene){
1306-
_scene->updateSets(_state.setOptions);
1301+
// If refresh is needed, ensure the set options are rebuilt and the scene udpated for live preview.
1302+
if(refreshSetOptions){
1303+
_state.setOptions.rebuild();
1304+
if(_scene){
1305+
_scene->updateSets(_state.setOptions);
1306+
}
1307+
}
1308+
1309+
if(_showDebug){
1310+
const double time = _timer * _state.scrollSpeed;
1311+
1312+
std::array<int, SETS_COUNT> firstNoteInSet;
1313+
std::array<int, SETS_COUNT> lastNoteInSet;
1314+
firstNoteInSet.fill(-1);
1315+
lastNoteInSet.fill(128);
1316+
int lastSet = -1;
1317+
for(int nid = 0; nid < 128; ++nid){
1318+
int newSet = _state.setOptions.apply(nid, 0, 0, time);
1319+
if(newSet != lastSet){
1320+
if(lastSet >= 0){
1321+
lastNoteInSet[lastSet] = nid - 1;
1322+
}
1323+
firstNoteInSet[newSet] = nid;
1324+
lastSet = newSet;
1325+
}
1326+
}
1327+
ImGui::Separator();
1328+
ImGui::Text("Debug: ");
1329+
ImGuiSameLine();
1330+
ImGui::TextDisabled("(press D to hide)");
1331+
ImGui::Text("At time %.3fs: ", time);
1332+
1333+
for(unsigned int sid = 0; sid < SETS_COUNT; ++sid){
1334+
int firstNote = firstNoteInSet[sid];
1335+
int lastNote = lastNoteInSet[sid];
1336+
1337+
if((firstNote != -1) || (lastNote != 128)){
1338+
firstNote = glm::clamp(firstNote, 0, 127);
1339+
lastNote = glm::clamp(lastNote, 0, 127);
1340+
1341+
ImGui::Text("* Set %u contains notes from %s to %s", sid, midiKeysStrings[firstNote], midiKeysStrings[lastNote]);
1342+
}
1343+
}
1344+
13071345
}
13081346
}
1347+
ImGui::End();
1348+
1349+
13091350
}
13101351

13111352
void Renderer::applyBackgroundColor(){

0 commit comments

Comments
 (0)