ref: 72315513cf30bd581715a0ba32675fbe3d89992b
parent: 9e6e5760761f29ed4be78b08e87fd47c2af0e26a
author: qwx <qwx@sciops.net>
date: Mon Aug 19 06:39:03 EDT 2024
add tab key shortcut: switch first (or mono) channel displayed
--- a/dat.h
+++ b/dat.h
@@ -38,7 +38,7 @@
Drawall = 1<<2,
};
-extern int stereo;
+extern int stereo, chan;
extern int debug, paused;
extern int debugdraw;
--- a/draw.c
+++ b/draw.c
@@ -141,7 +141,7 @@
if(Dx(rr) > slen / 2)
rr.max.x = rr.min.x + slen / 2;
rx = rr;
- for(l=graph[0]+2*rx.min.x, e=l+2*Dx(rr); l<e; l+=2, rx.min.x++){
+ for(l=graph[chan]+2*rx.min.x, e=l+2*Dx(rr); l<e; l+=2, rx.min.x++){
rx.min.y = rr.min.y + bgscalyl - l[1] / bgscalf;
rx.max.x = rx.min.x + sampwidth;
rx.max.y = rr.min.y + bgscalyl - l[0] / bgscalf;
@@ -157,7 +157,7 @@
rx = rectaddpt(rr, Pt(Dy(view->r)/2,0));
//fprint(2, "→ %R\n", rx);
- for(r=graph[1]+2*rx.min.x, e=r+2*Dx(rr); r<e; r+=2, rx.min.x++){
+ for(r=graph[chan+1&1]+2*rx.min.x, e=r+2*Dx(rr); r<e; r+=2, rx.min.x++){
rx.min.y = rr.min.y + bgscalyr - r[1] / bgscalf;
rx.max.x = rx.min.x + sampwidth;
rx.max.y = rr.min.y + bgscalyr - r[0] / bgscalf;
@@ -303,22 +303,18 @@
lmin = s;
else if(s > lmax)
lmax = s;
- if(stereo){
- s = (s16int)(p[3] << 8 | p[2]);
- if(s < rmin)
- rmin = s;
- else if(s > rmax)
- rmax = s;
- }
+ s = (s16int)(p[3] << 8 | p[2]);
+ if(s < rmin)
+ rmin = s;
+ else if(s > rmax)
+ rmax = s;
}
n -= k;
}
*l++ = lmin;
*l++ = lmax;
- if(stereo){
- *r++ = rmin;
- *r++ = rmax;
- }
+ *r++ = rmin;
+ *r++ = rmax;
}
working--;
refresh(Drawrender);
--- a/pplay.c
+++ b/pplay.c
@@ -9,7 +9,7 @@
extern QLock lsync;
-int stereo;
+int stereo, chan;
int debug, paused, notriob;
static Keyboardctl *kc;
@@ -175,6 +175,7 @@
case 'b': setjump(dot.from); break;
case Kesc: setrange(0, dot.totalsz); break;
case '\n': zoominto(dot.from, dot.to); break;
+ case '\t': chan = chan + 1 & 1; break;
case 'z': zoominto(0, dot.totalsz); break;
case '-': setzoom(-1, 0); break;
case '=': setzoom(1, 0); break;