Compare commits

..

15 Commits

4 changed files with 100 additions and 50 deletions

View File

@ -3,6 +3,7 @@ project(trakker)
SET(CMAKE_CXX_STANDARD 17) SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED True) SET(CMAKE_CXX_STANDARD_REQUIRED True)
SET(CMAKE_CXX_FLAGS "-O3") SET(CMAKE_CXX_FLAGS "-O3")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR})
find_package(Git) find_package(Git)
find_package(ALSA REQUIRED) find_package(ALSA REQUIRED)

View File

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

View File

@ -16,8 +16,8 @@
#define BUFFER_SIZE 250000 #define BUFFER_SIZE 250000
static std::string note_name[] = { "C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#", "A ", "A#", "B " }; 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"; static const char* device = "default";
char* file; char* file;
bool colorMode = 0; // 0 - Auto, 1 - Monochrome, 2 - 8-bit, 3 - Full bool colorMode = 0; // 0 - Auto, 1 - Monochrome, 2 - 8-bit, 3 - Full
@ -38,6 +38,7 @@ bool loop;
bool ptnChans = true; bool ptnChans = true;
bool dynamicRoll = true; bool dynamicRoll = true;
bool ptnOrder = true; bool ptnOrder = true;
bool showEffects = false;
std::map<int, char> efxtable; std::map<int, char> efxtable;
std::map<int, bool> efxmemtable; std::map<int, bool> efxmemtable;
@ -48,12 +49,13 @@ int main(int argc, char *argv[]) {
printf("\n"); printf("\n");
printf("Help\n"); printf("Help\n");
printf("-h Show this message.\n"); printf("-h Show this message.\n");
printf("-d <num> Start on the specified panel.\n");
printf("-c <num> Force terminal color mode.\n"); printf("-c <num> Force terminal color mode.\n");
printf(" 0 Auto (default)\n"); printf(" 0 Auto (default)\n");
printf(" 1 Monochrome\n"); printf(" 1 Monochrome\n");
printf(" 2 8bit\n"); printf(" 2 8bit\n");
printf(" 3 Full\n"); printf(" 3 Full\n");
printf("-d <num> Start on the specified panel.\n");
printf("-o <num> Toggle player options\n");
printf("-s <num> Stereo Seperation\n"); printf("-s <num> Stereo Seperation\n");
exit(0); exit(0);
} else if (strcmp(argv[a], "-d") == 0) { } else if (strcmp(argv[a], "-d") == 0) {
@ -68,6 +70,22 @@ int main(int argc, char *argv[]) {
} else if (strcmp(argv[a], "-c") == 0) { } else if (strcmp(argv[a], "-c") == 0) {
colorMode = atoi(argv[a+1]); colorMode = atoi(argv[a+1]);
a++; a++;
} else if (strcmp(argv[a], "-o") == 0) {
switch (atoi(argv[a+1])) {
case 1:
ptnChans = !ptnChans;
break;
case 2:
dynamicRoll = !dynamicRoll;
break;
case 3:
ptnOrder = !ptnOrder;
break;
case 4:
showEffects = !showEffects;
break;
}
a++;
} else if (strcmp(argv[a], "-s") == 0) { } else if (strcmp(argv[a], "-s") == 0) {
int newmix = atoi(argv[a+1]); int newmix = atoi(argv[a+1]);
if (newmix > 100 || newmix < 0) if (newmix > 100 || newmix < 0)
@ -331,6 +349,9 @@ int main(int argc, char *argv[]) {
case '3': case '3':
ptnOrder = !ptnOrder; ptnOrder = !ptnOrder;
break; break;
case '4':
showEffects = !showEffects;
break;
} }
} }
break; break;
@ -437,7 +458,7 @@ void displayHeader(xmp_module_info *mi, xmp_frame_info *fi) {
} else if (display == 1) { } else if (display == 1) {
displayPatterns(mi, fi); displayPatterns(mi, fi);
} else if (display == 2) { } else if (display == 2) {
displayVolumes(mi, fi); displayScope(mi, fi);
} else if (display == 3) { } else if (display == 3) {
displayNoteRoll(mi, fi); displayNoteRoll(mi, fi);
} else if (display == 4) { } else if (display == 4) {
@ -472,7 +493,7 @@ void displayInfo(xmp_module_info *mi, xmp_frame_info *fi) {
} }
void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) { void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
int chnsize = 15; int chnsize = showEffects?15:11;
if (ptnOrder) { if (ptnOrder) {
for (int j = 0; j < mi->mod->len; j++) { for (int j = 0; j < mi->mod->len; j++) {
if (mi->mod->xxo[j] == 0xFF) continue; if (mi->mod->xxo[j] == 0xFF) continue;
@ -503,12 +524,14 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
if (voll >= 16) wattron(dis, vollo); if (voll >= 16) wattron(dis, vollo);
mvwaddch(dis, 0, (cxpos++)-hOffset, ' '); mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
wattroff(dis, vollo); wattroff(dis, vollo);
if (voll >= 8) wattron(dis, vollo); if (showEffects) {
mvwaddch(dis, 0, (cxpos++)-hOffset, ' '); if (voll >= 8) wattron(dis, vollo);
wattroff(dis, vollo); mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
if (voll > 0) wattron(dis, vollo); wattroff(dis, vollo);
mvwaddch(dis, 0, (cxpos++)-hOffset, ' '); if (voll > 0) wattron(dis, vollo);
wattroff(dis, vollo); mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
wattroff(dis, vollo);
}
wattron(dis, chnvw); wattron(dis, chnvw);
mvwaddch(dis, 0, (cxpos++)-hOffset, ' '); mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
@ -521,12 +544,14 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
wattroff(dis, chnvw); wattroff(dis, chnvw);
int volr = (cinfo.volume * cinfo.pan/256); int volr = (cinfo.volume * cinfo.pan/256);
if (volr > 0) wattron(dis, vollo); if (showEffects) {
mvwaddch(dis, 0, (cxpos++)-hOffset, ' '); if (volr > 0) wattron(dis, vollo);
wattroff(dis, vollo); mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
if (volr >= 8) wattron(dis, vollo); wattroff(dis, vollo);
mvwaddch(dis, 0, (cxpos++)-hOffset, ' '); if (volr >= 8) wattron(dis, vollo);
wattroff(dis, vollo); mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
wattroff(dis, vollo);
}
if (volr >= 16) wattron(dis, vollo); if (volr >= 16) wattron(dis, vollo);
mvwaddch(dis, 0, (cxpos++)-hOffset, ' '); mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
wattroff(dis, vollo); wattroff(dis, vollo);
@ -580,10 +605,12 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
snprintf(vol, 4, "v40"); snprintf(vol, 4, "v40");
else snprintf(vol, 4, "..."); else snprintf(vol, 4, "...");
char f1; if (showEffects) {
if ((efxmemtable[event.fxt] || event.fxp != 0) && (f1 = efxtable[event.fxt]) != NULL) snprintf(efx, 4, "%c%02X", f1, event.fxp); char f1;
else snprintf(efx, 4, "..."); if ((efxmemtable[event.fxt] || event.fxp != 0) && (f1 = efxtable[event.fxt])) snprintf(efx, 4, "%c%02X", f1, event.fxp);
sprintf(lnbuf, "|%s %s %s %s", note, ins, vol, efx); else snprintf(efx, 4, "...");
sprintf(lnbuf, "|%s %s %s %s", note, ins, vol, efx);
} else sprintf(lnbuf, "|%s %s %s", note, ins, vol);
for (int z = 0; z < chnsize; z++) { for (int z = 0; z < chnsize; z++) {
if (((i*chnsize)+2+z)-hOffset < 2) continue; if (((i*chnsize)+2+z)-hOffset < 2) continue;
mvwaddch(dis, y, ((i*chnsize)+2+z)-hOffset, lnbuf[z]); mvwaddch(dis, y, ((i*chnsize)+2+z)-hOffset, lnbuf[z]);
@ -599,22 +626,42 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
} }
} }
void displayVolumes(xmp_module_info *mi, xmp_frame_info *fi) { int lerp (int a, int b, float f) {
int chns = mi->mod->chn; return a + f * (b - a);
chtype no_pair = COLOR_PAIR(5); }
for (int y = vOffset; y < chns; y++) {
if (y > (LINES - 4)+vOffset || y < 0) continue; #include <vector>
struct xmp_channel_info cinfo = fi->channel_info[y]; std::vector<int> bufbuf;
if (y > (LINES - 3)+vOffset) break; void displayScope(xmp_module_info *mi, xmp_frame_info *fi) {
wmove(dis, y-vOffset, 0); const char* xbuf = (char*)fi->buffer;
int cvol = (cinfo.volume * (COLS - 5)) / (64 * (vol / 100)); int percol = (fi->buffer_size/(COLS-2));
wattron(dis, no_pair); bufbuf.resize(COLS-2);
wprintw(dis, "%02X", y);
wattroff(dis, no_pair); for (int s = 0; s < COLS-2; s++) {
for (int c = 0; c < COLS - 5; c++) { int colsum = 0;
if (c < cvol) waddstr(dis, "#"); for (int v = 0; v < percol; v++) {
else waddstr(dis, " "); colsum += xbuf[(s*percol)+v];
} }
int l = (colsum / percol)*2;
if (l >= 0x80) l = 0x80;
else if (l <= -0x80) l = -0x80;
bufbuf[s] = l;
}
wmove(dis, 0, 0);
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);
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);
} }
} }
@ -622,12 +669,12 @@ void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi) {
int ins = mi->mod->ins; int ins = mi->mod->ins;
chtype no_pair = COLOR_PAIR(5); chtype no_pair = COLOR_PAIR(5);
if (dynamicRoll) { if (dynamicRoll) {
for (int l = 0; l < (96/12); l++) { for (int l = 1; l <= 8; l++) {
int cnote = (l*12); int cnote = (l*12);
if (cnote < prMin && l == (prMin / 12)) { if (cnote <= prMin && l == (prMin / 12)) {
wmove(dis, 0, 0); wmove(dis, 0, 0);
wprintw(dis, "<%i", l); wprintw(dis, "<%i", l);
} else if (cnote <= prMax && cnote >= prMin) { } else if (cnote < prMax && cnote > prMin) {
wmove(dis, 0, (((cnote - prMin) * (COLS - 5)) / (prMax - prMin))+3); wmove(dis, 0, (((cnote - prMin) * (COLS - 5)) / (prMax - prMin))+3);
wprintw(dis, "%i", l); wprintw(dis, "%i", l);
} }
@ -635,8 +682,8 @@ void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi) {
} }
for (int y = vOffset; y < ins; y++) { for (int y = vOffset; y < ins; y++) {
if (!dynamicRoll) { prMin = 0; prMax = 144; } if (!dynamicRoll) { prMin = 0; prMax = 144; }
if (y > (LINES - 5)+vOffset || y < 0) continue; if (y > (LINES - (5+dynamicRoll))+vOffset || y < 0) continue;
wmove(dis, (y-vOffset)+1, 0); wmove(dis, (y-vOffset)+dynamicRoll, 0);
wattron(dis, no_pair); wattron(dis, no_pair);
wprintw(dis, "%02X", y+1); wprintw(dis, "%02X", y+1);
wattroff(dis, no_pair); wattroff(dis, no_pair);
@ -654,12 +701,12 @@ void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi) {
int note = ((cinfo.note - prMin) * (COLS - 5)) / (dynamicRoll?(prMax - prMin):96); int note = ((cinfo.note - prMin) * (COLS - 5)) / (dynamicRoll?(prMax - prMin):96);
if (cinfo.instrument != y) continue; if (cinfo.instrument != y) continue;
wmove(dis, (y-vOffset)+1, note+3); wmove(dis, (y-vOffset)+dynamicRoll, note+3);
if (cinfo.volume >= 32) if (cinfo.volume >= 32)
waddstr(dis, "#"); waddstr(dis, "#");
else if (cinfo.volume >= 16 && (char)mvwinch(dis, (y-vOffset)+1, note+3) != '#') else if (cinfo.volume >= 16 && (char)mvwinch(dis, (y-vOffset)+dynamicRoll, note+3) != '#')
waddstr(dis, "="); waddstr(dis, "=");
else if (cinfo.volume > 0 && ((char)mvwinch(dis, (y-vOffset)+1, note+3) != '-' || (char)mvwinch(dis, (y-vOffset)+1, note+3) != '#')) else if (cinfo.volume > 0 && ((char)mvwinch(dis, (y-vOffset)+dynamicRoll, note+3) != '-' || (char)mvwinch(dis, (y-vOffset)+dynamicRoll, note+3) != '#'))
waddstr(dis, "-"); waddstr(dis, "-");
} }
wmove(dis, y, COLS-4); wmove(dis, y, COLS-4);
@ -675,6 +722,7 @@ void displayPlayer() {
mvwaddstr(dis, 5-vOffset, 1, "1. Pattern Channels"); mvwaddstr(dis, 5-vOffset, 1, "1. Pattern Channels");
mvwaddstr(dis, 6-vOffset, 1, "2. Dynamic Note Roll"); mvwaddstr(dis, 6-vOffset, 1, "2. Dynamic Note Roll");
mvwaddstr(dis, 7-vOffset, 1, "3. Pattern Order"); mvwaddstr(dis, 7-vOffset, 1, "3. Pattern Order");
mvwaddstr(dis, 8-vOffset, 1, "4. Pattern Effects");
wattroff(dis, A_BOLD); wattroff(dis, A_BOLD);
mvwaddstr(dis, 1-vOffset, 20, loop?"[ #] YES":"[# ] NO"); mvwaddstr(dis, 1-vOffset, 20, loop?"[ #] YES":"[# ] NO");
@ -684,6 +732,7 @@ void displayPlayer() {
mvwaddstr(dis, 5-vOffset, 22, ptnChans?"[ #] YES":"[# ] NO"); mvwaddstr(dis, 5-vOffset, 22, ptnChans?"[ #] YES":"[# ] NO");
mvwaddstr(dis, 6-vOffset, 22, dynamicRoll?"[ #] YES":"[# ] NO"); mvwaddstr(dis, 6-vOffset, 22, dynamicRoll?"[ #] YES":"[# ] NO");
mvwaddstr(dis, 7-vOffset, 22, ptnOrder?"[ #] YES":"[# ] NO"); mvwaddstr(dis, 7-vOffset, 22, ptnOrder?"[ #] YES":"[# ] NO");
mvwaddstr(dis, 8-vOffset, 22, showEffects?"[ #] YES":"[# ] NO");
} }
void displayHelp() { void displayHelp() {
@ -934,7 +983,7 @@ void addToEffects(int id, char efx, bool mem) {
efxmemtable[id] = mem; efxmemtable[id] = mem;
} }
bool isPartOf(char* w1, char* w2) { bool isPartOf(char* w1, const char* w2) {
int i=0; int i=0;
int j=0; int j=0;
while(w1[i]!='\0'){ while(w1[i]!='\0'){

View File

@ -12,12 +12,12 @@ void createWindows();
void displayHeader(xmp_module_info *mi, xmp_frame_info *fi); void displayHeader(xmp_module_info *mi, xmp_frame_info *fi);
void displayInfo(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 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 displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi);
void displayPlayer(); void displayPlayer();
void displayHelp(); void displayHelp();
void generateEffectsTable(char* type); void generateEffectsTable(char* type);
void addToEffects(int id, char efx, bool mem); void addToEffects(int id, char efx, bool mem);
bool isPartOf(char* w1, char* w2); bool isPartOf(char* w1, const char* w2);
#endif #endif