replace channel bar page with scope/waveform

This commit is contained in:
Wirlaburla 2024-03-20 19:07:36 -05:00
parent f97e50612f
commit a4e3734568
3 changed files with 29 additions and 21 deletions

View File

@ -1,7 +1,7 @@
# Maintainer: Nick G. <wirlaburla@worlio.com>
pkgname=trakker-git
pkgver=0.5.1
pkgver=0.5.2.r3.gf97e506
pkgrel=1
pkgdesc='A terminal-based tracker interface for libxmp.'
arch=('x86_64')

View File

@ -16,7 +16,7 @@
#define BUFFER_SIZE 250000
static std::string note_name[] = { "C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#", "A ", "A#", "B " };
static std::string pages[] = { "1. Info", "2. Pattern", "3. Bars", "4. Piano Roll", "5. Config", "6. Help" };
static std::string pages[] = { "1. Info", "2. Pattern", "3. Scope", "4. Piano Roll", "5. Config", "6. Help" };
static char* device = "default";
char* file;
@ -437,7 +437,7 @@ void displayHeader(xmp_module_info *mi, xmp_frame_info *fi) {
} else if (display == 1) {
displayPatterns(mi, fi);
} else if (display == 2) {
displayVolumes(mi, fi);
displayScope(mi, fi);
} else if (display == 3) {
displayNoteRoll(mi, fi);
} else if (display == 4) {
@ -599,22 +599,30 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
}
}
void displayVolumes(xmp_module_info *mi, xmp_frame_info *fi) {
int chns = mi->mod->chn;
chtype no_pair = COLOR_PAIR(5);
for (int y = vOffset; y < chns; y++) {
if (y > (LINES - 4)+vOffset || y < 0) continue;
struct xmp_channel_info cinfo = fi->channel_info[y];
if (y > (LINES - 3)+vOffset) break;
wmove(dis, y-vOffset, 0);
int cvol = (cinfo.volume * (COLS - 5)) / (64 * (vol / 100));
wattron(dis, no_pair);
wprintw(dis, "%02X", y);
wattroff(dis, no_pair);
for (int c = 0; c < COLS - 5; c++) {
if (c < cvol) waddstr(dis, "#");
else waddstr(dis, " ");
int lerp (int a, int b, float f) {
return a + f * (b - a);
}
#include <vector>
std::vector<int> bufbuf;
void displayScope(xmp_module_info *mi, xmp_frame_info *fi) {
bufbuf.resize(fi->buffer_size);
const char* xbuf = (char*)fi->buffer;
float nxcol = 0;
int rate = 2;
int midLine = (LINES-4)/2;
int horzInc = 1;
for (int s = 0; s < fi->buffer_size; s++) {
if (nxcol >= COLS-2) break;
int l = lerp(bufbuf[s], xbuf[s], 0.2f);
int newpos = ((l+0x80) * (LINES - 4)) / 0xFF;
horzInc = (newpos < midLine)?-1:1;
for (int j = midLine; j != newpos; j+=horzInc) {
wmove(dis, j, (int)nxcol);
waddch(dis, '|');
}
nxcol+=(1.0*(COLS-2)/fi->buffer_size);
bufbuf[s] = l;
}
}

View File

@ -12,7 +12,7 @@ void createWindows();
void displayHeader(xmp_module_info *mi, xmp_frame_info *fi);
void displayInfo(xmp_module_info *mi, xmp_frame_info *fi);
void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi);
void displayVolumes(xmp_module_info *mi, xmp_frame_info *fi);
void displayScope(xmp_module_info *mi, xmp_frame_info *fi);
void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi);
void displayPlayer();
void displayHelp();