shithub: plan9front

Download patch

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

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

--- a/sys/src/cmd/audio/libtags/mkfile	Fri Apr 23 05:20:30 2021
+++ b/sys/src/cmd/audio/libtags/mkfile	Sat Apr 24 10:07:24 2021
@@ -9,6 +9,7 @@
 	id3v2.$O\
 	it.$O\
 	m4a.$O\
+	mod.$O\
 	opus.$O\
 	s3m.$O\
 	tags.$O\
--- /dev/null	Sun Oct 31 09:33:26 2021
+++ b/sys/src/cmd/audio/libtags/mod.c	Sat Apr 24 10:07:24 2021
@@ -0,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	Fri Apr 23 05:20:30 2021
+++ b/sys/src/cmd/audio/libtags/tags.c	Sat Apr 24 10:07:24 2021
@@ -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	Fri Apr 23 05:20:30 2021
+++ b/sys/src/cmd/audio/libtags/tags.h	Sat Apr 24 10:07:24 2021
@@ -33,6 +33,7 @@
 	Fit,
 	Fxm,
 	Fs3m,
+	Fmod,
 
 	Fmax,
 };
--- a/sys/src/cmd/audio/zuke/mkplist.c	Fri Apr 23 05:20:30 2021
+++ b/sys/src/cmd/audio/zuke/mkplist.c	Sat Apr 24 10:07:24 2021
@@ -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);