code: plan9front

Download patch

ref: b0e2ea4e5ffaec335c2a61ee98d2c5d3f1052569
parent: 83277da30948858da8203961d77330b7c05dc2f4
author: Sigrid <ftrvxmtrx@gmail.com>
date: Sat Apr 24 12:07:24 EDT 2021

libtags, zuke: add *.mod support (thanks kemal)

--- a/sys/src/cmd/audio/libtags/mkfile
+++ b/sys/src/cmd/audio/libtags/mkfile
@@ -9,6 +9,7 @@
 	id3v2.$O\
 	it.$O\
 	m4a.$O\
+	mod.$O\
 	opus.$O\
 	s3m.$O\
 	tags.$O\
--- /dev/null
+++ b/sys/src/cmd/audio/libtags/mod.c
@@ -1,0 +1,46 @@
+#include "tagspriv.h"
+
+/* insane. */
+static char* variants[] =
+{
+	"M.K.",
+	"M!K!",
+	"M&K!",
+	"N.T.",
+	"NSMS",
+	"FLT4",
+	"M\0\0\0",
+	"8\0\0\0",
+	"FEST",
+	"FLT8",
+	"CD81",
+	"OCTA",
+	"OKTA",
+	"16CN",
+	"32CN",
+	nil,
+};
+
+int
+tagmod(Tagctx *ctx)
+{
+	char d[20+1];
+	int i;
+
+	if (ctx->seek(ctx, 1080, 0) != 1080)
+		return -1;
+	if (ctx->read(ctx, d, 4) != 4)
+		return -1;
+	for (i = 0; ; i++)
+		if (variants[i] == nil)
+			return -1;
+		else if (memcmp(d, variants[i], 4) == 0)
+			break;
+	memset(d, 0, sizeof d);
+	if (ctx->seek(ctx, 0, 0) != 0)
+		return -1;
+	if (ctx->read(ctx, d, 20) != 20)
+		return -1;
+	txtcb(ctx, Ttitle, "", d);
+	return 0;
+}
--- a/sys/src/cmd/audio/libtags/tags.c
+++ b/sys/src/cmd/audio/libtags/tags.c
@@ -18,6 +18,7 @@
 extern int tagvorbis(Tagctx *ctx);
 extern int tagwav(Tagctx *ctx);
 extern int tagxm(Tagctx *ctx);
+extern int tagmod(Tagctx *ctx);
 
 static const Getter g[] =
 {
@@ -31,6 +32,7 @@
 	{tagit, Fit},
 	{tagxm, Fxm},
 	{tags3m, Fs3m},
+	{tagmod, Fmod},
 };
 
 void
--- a/sys/src/cmd/audio/libtags/tags.h
+++ b/sys/src/cmd/audio/libtags/tags.h
@@ -33,6 +33,7 @@
 	Fit,
 	Fxm,
 	Fs3m,
+	Fmod,
 
 	Fmax,
 };
--- a/sys/src/cmd/audio/zuke/mkplist.c
+++ b/sys/src/cmd/audio/zuke/mkplist.c
@@ -31,6 +31,7 @@
 	[Fit] = "mod",
 	[Fxm] = "mod",
 	[Fs3m] = "mod",
+	[Fmod] = "mod",
 };
 
 static Meta *
@@ -196,7 +197,10 @@
 	}
 
 	if(ctx.duration == 0){
-		if(ctx.format == Fit || ctx.format == Fxm || ctx.format == Fs3m)
+		if(ctx.format == Fit ||
+		ctx.format == Fxm ||
+		ctx.format == Fs3m ||
+		ctx.format == Fmod)
 			ctx.duration = modduration(path);
 		if(ctx.duration == 0)
 			fprint(2, "%s: no duration\n", path);