ref: b3f96670b78750193039bef394414890836b8dbe
parent: 8204f3beedf0fb9a46a8062e217057d2c068158d
author: qwx <[email protected]>
date: Fri Oct 11 23:31:02 EDT 2024
draw: always show loop points and which one is currently selected
--- a/cmd.c
+++ b/cmd.c
@@ -7,7 +7,7 @@
extern Channel *pidc;
Dot dot;
-int bound = 1;
+int bound = Bend;
static int epfd[2];
--- a/dat.h
+++ b/dat.h
@@ -29,6 +29,10 @@
Chunk *norris;
};
extern Dot dot;
+enum{
+ Bstart,
+ Bend,
+};
extern int bound;
extern QLock lsync;
--- a/draw.c
+++ b/draw.c
@@ -150,12 +150,6 @@
}
if(!stereo)
return;
-
-/*
-FIXME: wrong midpoint.
-rendersamples 0x410450 [0 0] [1365 187] view [0 0] [1365 375]→ [187 0] [1552 187]
-*/
-
rx = rectaddpt(rr, Pt(0, Dy(view->r)/2));
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;
@@ -188,7 +182,7 @@
static void
drawstat(void)
{
- char s[256];
+ char s[256], *b[3];
Point p;
draw(screen, statr, col[Cbg], nil, ZP);
@@ -196,10 +190,18 @@
stereo ? "" : chan==0?"Left ":"Right ",
T / Sampsz, dot.cur);
p = string(screen, statr.min, col[Ctext], ZP, font, s);
- if(dot.from > 0 || dot.to < dot.totalsz){
- seprint(s, s+sizeof s, " from %τ to %τ", dot.from, dot.to);
- p = string(screen, p, col[Cloop], ZP, font, s);
+ if(bound == Bstart){
+ b[0] = "[";
+ b[1] = "] ";
+ b[2] = " ";
+ }else{
+ b[0] = " ";
+ b[1] = " [";
+ b[2] = "]";
}
+ seprint(s, s+sizeof s, " %sfrom %τ%sto %τ%s",
+ b[0], dot.from, b[1], dot.to, b[2]);
+ p = string(screen, p, col[Cloop], ZP, font, s);
if(dot.off != dot.from && dot.off >= 0){
seprint(s, s+sizeof s, " last %τ", dot.off);
p = string(screen, p, col[Cins], ZP, font, s);
@@ -486,7 +488,7 @@
werrstr("invalid range");
return -1;
}
- if(bound == 0)
+ if(bound == Bstart)
setrange(off, dot.to);
else
setrange(dot.from, off);
--- a/pplay.c
+++ b/pplay.c
@@ -217,8 +217,8 @@
case '=': setzoom(20.0, mo.xy.x - screen->r.min.x); m.xy.x = mo.xy.x; break;
case '_': setzoom(-1.0, mo.xy.x - screen->r.min.x); m.xy.x = mo.xy.x; break;
case '+': setzoom(1.0, mo.xy.x - screen->r.min.x); m.xy.x = mo.xy.x; break;
- case '1': bound = 0; break;
- case '2': bound = 1; break;
+ case '1': bound = Bstart; break;
+ case '2': bound = Bend; break;
case 'S': stereo ^= 1; redraw(1); break;
case 'b': setjump(dot.from); break;
case 't': samptime ^= 1; break;
--- a/pplay.man
+++ b/pplay.man
@@ -43,11 +43,12 @@
.I T
the sample period (stereo samples per pixel),
then the current playback position,
-and, if set, the start and end loop points and cursor (last left click).
+the start and end loop points, and cursor (last left click) if set.
Timestamps are displayed in
[hh:mm:ss.tt] format (see
.IR tmdate (2)),
or the number of stereo samples so far if toggled.
+The loop point currently armed is shown inside brackets.
.PP
The view can be moved horizontally with the cursor keys,
or by holding the right mouse button.