commit 2e12698eb0ed56f03b462a0a364079c507304b78
parent 939aaf00a856fbab7a16933e13b8c41f211ddaa4
Author: glenda <glenda@device>
Date: Mon, 24 Oct 2022 21:00:17 +0000
add src/audio/extract
Diffstat:
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/src/audio/extract.c b/src/audio/extract.c
@@ -0,0 +1,20 @@
+/*
+ * Extracts first channel from 16-bit stereo PCM input.
+ * Output is 16-bit mono, naturally.
+ */
+
+#include<u.h>
+#include<libc.h>
+
+void
+main(void)
+{
+ long i, n;
+ s16int buf[4096];
+ while ((n = read(0, buf, 4096 * sizeof(s16int))) > 0) {
+ for (i = 0; i <= n / sizeof(s16int) / 2; i += 1) {
+ buf[i] = buf[i * 2];
+ }
+ if (write(1, buf, n / 2) <= 0) exits("can't write");
+ }
+}
diff --git a/src/audio/mkfile b/src/audio/mkfile
@@ -0,0 +1,8 @@
+</$objtype/mkfile
+
+TARG=\
+ extract
+
+BIN=/$objtype/bin/audio
+
+</sys/src/cmd/mkmany