ref: 561985c1b35f2230587878711727db3cf08ce499
parent: a3edc4c2416e94486f5408436baf26d37d210535
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Mar 5 06:13:05 EST 2021
moddec: print mod duration
--- a/examples/moddec.c
+++ b/examples/moddec.c
@@ -4,7 +4,7 @@
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
-#define SRATE 44100.0f
+#define RATIO (65536.0/44100.0)
enum {
Nsamp = 4096,
@@ -63,7 +63,8 @@
sysfatal("unknown/invalid mod");
if((t = (char*)duh_get_tag(f, "TITLE")) != nil && *t)
fprint(2, "%s\n", t);
- ren = duh_start_sigrenderer(f, 0, 2, pos*100000.0*SRATE/65536.0);
+ fprint(2, "duration: %g\n", duh_get_length(f)*RATIO/100000.0);
+ 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);
dumb_it_set_xm_speed_zero_callback(itren, dumb_it_callback_terminate, nil);
@@ -73,7 +74,7 @@
n = 0;
for(;;){
- n = duh_render_int(ren, &samp, &nsamp, 16, 0, 1.0, 65536.0f/SRATE, MAX(n, Nsamp), b);
+ n = duh_render_int(ren, &samp, &nsamp, 16, 0, 1.0, RATIO, MAX(n, Nsamp), b);
if(n <= 0)
break;
if(write(1, b, n*2*2) != n*2*2)