shithub: pplay

Download patch

ref: 08bd7a56ac0ec16adc86bbd106f8731b8d271b11
parent: d00975a6111403531f47e0fe01ad26b3990de4c0
author: qwx <qwx@sciops.net>
date: Sat Aug 24 12:58:33 EDT 2024

add t shortcut: swap between time display in samples and ctime

--- a/dat.h
+++ b/dat.h
@@ -21,11 +21,11 @@
 	Chunk *right;
 };
 struct Dot{
-	usize from;
-	usize to;
-	usize cur;
+	ssize from;
+	ssize to;
+	ssize cur;
 	ssize off;
-	usize totalsz;
+	ssize totalsz;
 	Chunk *norris;
 };
 extern Dot dot;
@@ -40,7 +40,7 @@
 
 extern int stereo, chan;
 extern int debug, paused;
-extern int debugdraw;
+extern int samptime;
 
 #define MIN(x,y)	((x) < (y) ? (x) : (y))
 #define MAX(x,y)	((x) > (y) ? (x) : (y))
--- a/draw.c
+++ b/draw.c
@@ -6,7 +6,7 @@
 #include "fns.h"
 
 QLock lsync;
-int debugdraw = 1;
+int samptime;
 
 enum{
 	Cbg,
@@ -81,8 +81,10 @@
 	if(p > dot.totalsz)
 		return fmtstrcpy(fmt, "-∞");
 	b2t(p, &th, &tm, &ts, &tμ);
-	return fmtprint(fmt, "%02d:%02d:%02d.%03d (%zd)",
-		th, tm, ts, tμ, p / Sampsz);
+	if(samptime)
+		return fmtprint(fmt, "%zd", p / Sampsz);
+	else
+		return fmtprint(fmt, "%02d:%02d:%02d.%03d", th, tm, ts, tμ);
 }
 
 static int
@@ -120,8 +122,7 @@
 static void
 rendermarks(void)
 {
-	if(debugdraw)
-		renderchunks();
+	renderchunks();
 	renderpos(dot.from, col[Cloop], 0);
 	renderpos(dot.to, col[Cloop], 0);
 	if(dot.off != dot.from)
@@ -191,14 +192,14 @@
 	Point p;
 
 	draw(screen, statr, col[Cbg], nil, ZP);
-	seprint(s, s+sizeof s, "T %zd @ %τ", T / Sampsz, dot.cur);
+	seprint(s, s+sizeof s, "T=%zd @ %τ", 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, " ↺ %τ - %τ", dot.from, dot.to);
+		seprint(s, s+sizeof s, " from %τ to %τ", dot.from, dot.to);
 		p = string(screen, p, col[Cloop], ZP, font, s);
 	}
-	if(dot.off != dot.from){
-		seprint(s, s+sizeof s, " ‡ %τ", dot.off);
+	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);
 	}
 	statr.max.x = p.x;
--- a/fns.h
+++ b/fns.h
@@ -38,4 +38,4 @@
 #pragma	varargck	argpos	dprint	2
 #pragma	varargck	type	"χ"	Chunk*
 #pragma	varargck	type	"Δ"	Dot*
-#pragma	varargck	type	"τ"	usize
+#pragma	varargck	type	"τ"	ssize
--- a/pplay.c
+++ b/pplay.c
@@ -167,20 +167,20 @@
 			break;
 		case 2:
 			switch(r){
-			case Kdel:
-			case 'q': threadexitsall(nil);
-			case 'D': debugdraw ^= 1; refresh(Drawrender); break;
-			case 'S': stereo ^= 1; redraw(1); break;
 			case ' ': toggleplay(); break;
-			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;
 			case '_': setzoom(-1, 1); break;
 			case '+': setzoom(1, 1); break;
+			case 'S': stereo ^= 1; redraw(1); break;
+			case Kdel:
+			case 'q': threadexitsall(nil);
+			case 'b': setjump(dot.from); break;
+			case 't': samptime ^= 1; break;
+			case 'z': zoominto(0, dot.totalsz); break;
 			case Kleft: setpage(-1); break;
 			case Kright: setpage(1); break;
 			default: