Compare commits
No commits in common. "master" and "0.5.2" have entirely different histories.
|
@ -3,7 +3,6 @@ project(trakker)
|
|||
SET(CMAKE_CXX_STANDARD 17)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
SET(CMAKE_CXX_FLAGS "-O3")
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
find_package(Git)
|
||||
find_package(ALSA REQUIRED)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Maintainer: Nick G. <wirlaburla@worlio.com>
|
||||
|
||||
pkgname=trakker-git
|
||||
pkgver=0.5.2.r3.gf97e506
|
||||
pkgver=0.5.1
|
||||
pkgrel=1
|
||||
pkgdesc='A terminal-based tracker interface for libxmp.'
|
||||
arch=('x86_64')
|
||||
|
|
109
src/main.cpp
109
src/main.cpp
|
@ -16,8 +16,8 @@
|
|||
#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. Scope", "4. Piano Roll", "5. Config", "6. Help" };
|
||||
static const char* device = "default";
|
||||
static std::string pages[] = { "1. Info", "2. Pattern", "3. Bars", "4. Piano Roll", "5. Config", "6. Help" };
|
||||
static char* device = "default";
|
||||
|
||||
char* file;
|
||||
bool colorMode = 0; // 0 - Auto, 1 - Monochrome, 2 - 8-bit, 3 - Full
|
||||
|
@ -38,7 +38,6 @@ bool loop;
|
|||
bool ptnChans = true;
|
||||
bool dynamicRoll = true;
|
||||
bool ptnOrder = true;
|
||||
bool showEffects = false;
|
||||
std::map<int, char> efxtable;
|
||||
std::map<int, bool> efxmemtable;
|
||||
|
||||
|
@ -49,13 +48,12 @@ int main(int argc, char *argv[]) {
|
|||
printf("\n");
|
||||
printf("Help\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(" 0 Auto (default)\n");
|
||||
printf(" 1 Monochrome\n");
|
||||
printf(" 2 8bit\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");
|
||||
exit(0);
|
||||
} else if (strcmp(argv[a], "-d") == 0) {
|
||||
|
@ -70,22 +68,6 @@ int main(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[a], "-c") == 0) {
|
||||
colorMode = atoi(argv[a+1]);
|
||||
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) {
|
||||
int newmix = atoi(argv[a+1]);
|
||||
if (newmix > 100 || newmix < 0)
|
||||
|
@ -349,9 +331,6 @@ int main(int argc, char *argv[]) {
|
|||
case '3':
|
||||
ptnOrder = !ptnOrder;
|
||||
break;
|
||||
case '4':
|
||||
showEffects = !showEffects;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -458,7 +437,7 @@ void displayHeader(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
} else if (display == 1) {
|
||||
displayPatterns(mi, fi);
|
||||
} else if (display == 2) {
|
||||
displayScope(mi, fi);
|
||||
displayVolumes(mi, fi);
|
||||
} else if (display == 3) {
|
||||
displayNoteRoll(mi, fi);
|
||||
} else if (display == 4) {
|
||||
|
@ -493,7 +472,7 @@ void displayInfo(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
}
|
||||
|
||||
void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
|
||||
int chnsize = showEffects?15:11;
|
||||
int chnsize = 15;
|
||||
if (ptnOrder) {
|
||||
for (int j = 0; j < mi->mod->len; j++) {
|
||||
if (mi->mod->xxo[j] == 0xFF) continue;
|
||||
|
@ -524,14 +503,12 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
if (voll >= 16) wattron(dis, vollo);
|
||||
mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
|
||||
wattroff(dis, vollo);
|
||||
if (showEffects) {
|
||||
if (voll >= 8) wattron(dis, vollo);
|
||||
mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
|
||||
wattroff(dis, vollo);
|
||||
if (voll > 0) wattron(dis, vollo);
|
||||
mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
|
||||
wattroff(dis, vollo);
|
||||
}
|
||||
|
||||
wattron(dis, chnvw);
|
||||
mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
|
||||
|
@ -544,14 +521,12 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
wattroff(dis, chnvw);
|
||||
|
||||
int volr = (cinfo.volume * cinfo.pan/256);
|
||||
if (showEffects) {
|
||||
if (volr > 0) wattron(dis, vollo);
|
||||
mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
|
||||
wattroff(dis, vollo);
|
||||
if (volr >= 8) wattron(dis, vollo);
|
||||
mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
|
||||
wattroff(dis, vollo);
|
||||
}
|
||||
if (volr >= 16) wattron(dis, vollo);
|
||||
mvwaddch(dis, 0, (cxpos++)-hOffset, ' ');
|
||||
wattroff(dis, vollo);
|
||||
|
@ -605,12 +580,10 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
snprintf(vol, 4, "v40");
|
||||
else snprintf(vol, 4, "...");
|
||||
|
||||
if (showEffects) {
|
||||
char f1;
|
||||
if ((efxmemtable[event.fxt] || event.fxp != 0) && (f1 = efxtable[event.fxt])) snprintf(efx, 4, "%c%02X", f1, event.fxp);
|
||||
if ((efxmemtable[event.fxt] || event.fxp != 0) && (f1 = efxtable[event.fxt]) != NULL) 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);
|
||||
for (int z = 0; z < chnsize; z++) {
|
||||
if (((i*chnsize)+2+z)-hOffset < 2) continue;
|
||||
mvwaddch(dis, y, ((i*chnsize)+2+z)-hOffset, lnbuf[z]);
|
||||
|
@ -626,42 +599,22 @@ void displayPatterns(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
const char* xbuf = (char*)fi->buffer;
|
||||
int percol = (fi->buffer_size/(COLS-2));
|
||||
bufbuf.resize(COLS-2);
|
||||
|
||||
for (int s = 0; s < COLS-2; s++) {
|
||||
int colsum = 0;
|
||||
for (int v = 0; v < percol; v++) {
|
||||
colsum += xbuf[(s*percol)+v];
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,12 +622,12 @@ void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
int ins = mi->mod->ins;
|
||||
chtype no_pair = COLOR_PAIR(5);
|
||||
if (dynamicRoll) {
|
||||
for (int l = 1; l <= 8; l++) {
|
||||
for (int l = 0; l < (96/12); l++) {
|
||||
int cnote = (l*12);
|
||||
if (cnote <= prMin && l == (prMin / 12)) {
|
||||
if (cnote < prMin && l == (prMin / 12)) {
|
||||
wmove(dis, 0, 0);
|
||||
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);
|
||||
wprintw(dis, "%i", l);
|
||||
}
|
||||
|
@ -682,8 +635,8 @@ void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
}
|
||||
for (int y = vOffset; y < ins; y++) {
|
||||
if (!dynamicRoll) { prMin = 0; prMax = 144; }
|
||||
if (y > (LINES - (5+dynamicRoll))+vOffset || y < 0) continue;
|
||||
wmove(dis, (y-vOffset)+dynamicRoll, 0);
|
||||
if (y > (LINES - 5)+vOffset || y < 0) continue;
|
||||
wmove(dis, (y-vOffset)+1, 0);
|
||||
wattron(dis, no_pair);
|
||||
wprintw(dis, "%02X", y+1);
|
||||
wattroff(dis, no_pair);
|
||||
|
@ -701,12 +654,12 @@ void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi) {
|
|||
int note = ((cinfo.note - prMin) * (COLS - 5)) / (dynamicRoll?(prMax - prMin):96);
|
||||
if (cinfo.instrument != y) continue;
|
||||
|
||||
wmove(dis, (y-vOffset)+dynamicRoll, note+3);
|
||||
wmove(dis, (y-vOffset)+1, note+3);
|
||||
if (cinfo.volume >= 32)
|
||||
waddstr(dis, "#");
|
||||
else if (cinfo.volume >= 16 && (char)mvwinch(dis, (y-vOffset)+dynamicRoll, note+3) != '#')
|
||||
else if (cinfo.volume >= 16 && (char)mvwinch(dis, (y-vOffset)+1, note+3) != '#')
|
||||
waddstr(dis, "=");
|
||||
else if (cinfo.volume > 0 && ((char)mvwinch(dis, (y-vOffset)+dynamicRoll, note+3) != '-' || (char)mvwinch(dis, (y-vOffset)+dynamicRoll, note+3) != '#'))
|
||||
else if (cinfo.volume > 0 && ((char)mvwinch(dis, (y-vOffset)+1, note+3) != '-' || (char)mvwinch(dis, (y-vOffset)+1, note+3) != '#'))
|
||||
waddstr(dis, "-");
|
||||
}
|
||||
wmove(dis, y, COLS-4);
|
||||
|
@ -722,7 +675,6 @@ void displayPlayer() {
|
|||
mvwaddstr(dis, 5-vOffset, 1, "1. Pattern Channels");
|
||||
mvwaddstr(dis, 6-vOffset, 1, "2. Dynamic Note Roll");
|
||||
mvwaddstr(dis, 7-vOffset, 1, "3. Pattern Order");
|
||||
mvwaddstr(dis, 8-vOffset, 1, "4. Pattern Effects");
|
||||
wattroff(dis, A_BOLD);
|
||||
|
||||
mvwaddstr(dis, 1-vOffset, 20, loop?"[ #] YES":"[# ] NO");
|
||||
|
@ -732,7 +684,6 @@ void displayPlayer() {
|
|||
mvwaddstr(dis, 5-vOffset, 22, ptnChans?"[ #] YES":"[# ] NO");
|
||||
mvwaddstr(dis, 6-vOffset, 22, dynamicRoll?"[ #] YES":"[# ] NO");
|
||||
mvwaddstr(dis, 7-vOffset, 22, ptnOrder?"[ #] YES":"[# ] NO");
|
||||
mvwaddstr(dis, 8-vOffset, 22, showEffects?"[ #] YES":"[# ] NO");
|
||||
}
|
||||
|
||||
void displayHelp() {
|
||||
|
@ -983,7 +934,7 @@ void addToEffects(int id, char efx, bool mem) {
|
|||
efxmemtable[id] = mem;
|
||||
}
|
||||
|
||||
bool isPartOf(char* w1, const char* w2) {
|
||||
bool isPartOf(char* w1, char* w2) {
|
||||
int i=0;
|
||||
int j=0;
|
||||
while(w1[i]!='\0'){
|
||||
|
|
|
@ -12,12 +12,12 @@ 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 displayScope(xmp_module_info *mi, xmp_frame_info *fi);
|
||||
void displayVolumes(xmp_module_info *mi, xmp_frame_info *fi);
|
||||
void displayNoteRoll(xmp_module_info *mi, xmp_frame_info *fi);
|
||||
void displayPlayer();
|
||||
void displayHelp();
|
||||
void generateEffectsTable(char* type);
|
||||
void addToEffects(int id, char efx, bool mem);
|
||||
bool isPartOf(char* w1, const char* w2);
|
||||
bool isPartOf(char* w1, char* w2);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user