From 86557d9cf438b6910f412b041e607a01f7f53830 Mon Sep 17 00:00:00 2001 From: Wirlaburla Date: Wed, 1 May 2024 00:42:53 -0500 Subject: [PATCH] scope adjustments --- src/main.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ee6f14e..4b0fa23 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -607,7 +607,7 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) { if (showEffects) { char f1; - if ((efxmemtable[event.fxt] || event.fxp != 0) && (f1 = efxtable[event.fxt]) != NULL) snprintf(efx, 4, "%c%02X", f1, event.fxp); + if ((efxmemtable[event.fxt] || event.fxp != 0) && (f1 = efxtable[event.fxt])) snprintf(efx, 4, "%c%02X", f1, event.fxp); else snprintf(efx, 4, "..."); sprintf(lnbuf, "|%s %s %s %s", note, ins, vol, efx); } else sprintf(lnbuf, "|%s %s %s", note, ins, vol); @@ -631,11 +631,12 @@ int lerp (int a, int b, float f) { } #include +std::vector bufbuf; void displayScope(xmp_module_info *mi, xmp_frame_info *fi) { const char* xbuf = (char*)fi->buffer; int percol = (fi->buffer_size/(COLS-2)); + bufbuf.resize(COLS-2); - wmove(dis, 0, 0); for (int s = 0; s < COLS-2; s++) { int colsum = 0; for (int v = 0; v < percol; v++) { @@ -644,14 +645,24 @@ void displayScope(xmp_module_info *mi, xmp_frame_info *fi) { int l = (colsum / percol)*2; if (l >= 0x80) l = 0x80; else if (l <= -0x80) l = -0x80; - int r = (1.0*(l+0x80)/0xFF)*(LINES-4); + bufbuf[s] = l; + } + wmove(dis, 0, 0); + wprintw(dis, "%i", percol); + for (int t = 0; t < COLS-2; t++) { + //int r = (1.0*(bufbuf[t]+0x80)/0xFF)*(LINES-4); + int r = (1.0*(lerp(bufbuf[t-1], bufbuf[t], 0.5f)+0x80)/0xFF)*(LINES-4); - for (int j = 0; j != l; j+=(l>0?1:-1)) { - wmove(dis, (1.0*(j+0x80)/0xFF)*(LINES-4), s); - waddch(dis, '#'); - } - wmove(dis, r, s); - waddch(dis, '='); + wmove(dis, r, t); + chtype pixpair = COLOR_PAIR(10); + if (std::abs(bufbuf[t-1] - bufbuf[t]) > 64) + pixpair = COLOR_PAIR(12); + else if (std::abs(bufbuf[t-1] - bufbuf[t]) > 32) + pixpair = COLOR_PAIR(11); + + wattron(dis, pixpair); + waddch(dis, ' '); + wattroff(dis, pixpair); } }