shithub: dumb

Download patch

ref: 0120570de7ff3b444b08aa4fa628c5484f3731d1
parent: 561985c1b35f2230587878711727db3cf08ce499
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Mar 5 06:18:12 EST 2021

moddec: fix usage, add -n option to skip audio

--- a/examples/moddec.c
+++ b/examples/moddec.c
@@ -15,7 +15,7 @@
 static void
 usage(void)
 {
-	fprint(2, "usage: %s [FILE]\n", argv0);
+	fprint(2, "usage: %s [-n] [-s SECONDS]\n", argv0);
 	exits("usage");
 }
 
@@ -23,10 +23,10 @@
 main(int argc, char **argv)
 {
 	DUMB_IT_SIGRENDERER *itren;
+	int n, sz, r, noaudio;
 	DUH_SIGRENDERER *ren;
 	sample_t **samp;
 	char *data, *t;
-	int n, sz, r;
 	double pos;
 	long nsamp;
 	DUH *f;
@@ -33,8 +33,12 @@
 
 	setfcr(getfcr() & ~(FPINVAL|FPOVFL));
 
+	noaudio = 0;
 	pos = 0.0;
 	ARGBEGIN{
+	case 'n':
+		noaudio = 1;
+		break;
 	case 's':
 		pos = atof(EARGF(usage()));
 		break;
@@ -59,11 +63,13 @@
 			break;
 	}
 
-	if((f = dumb_read_any(dumbfile_open_memory(data, sz), 1, 0)) == nil)
+	if((f = dumb_read_any(dumbfile_open_memory(data, sz), 0, 0)) == nil)
 		sysfatal("unknown/invalid mod");
 	if((t = (char*)duh_get_tag(f, "TITLE")) != nil && *t)
 		fprint(2, "%s\n", t);
 	fprint(2, "duration: %g\n", duh_get_length(f)*RATIO/100000.0);
+	if(noaudio)
+		exits(nil);
 	ren = duh_start_sigrenderer(f, 0, 2, pos*100000.0/RATIO);
 	itren = duh_get_it_sigrenderer(ren);
 	dumb_it_set_loop_callback(itren, dumb_it_callback_terminate, nil);