ref: 76deaed451d3e636633f058862f9c4ef53a5d9f9
parent: c5936ada17dd938ec011fb94328118b91f02e397
author: qwx <qwx@sciops.net>
date: Sun Jan 12 11:52:55 EST 2020
add scripts for transcoding to opus (and mp3) and filename standardization (from fn)
--- /dev/null
+++ b/2mp3
@@ -1,0 +1,4 @@
+#!/bin/rc
+play -o /fd/1 >[2]/dev/null |\
+ audio/pcmconv -i s16r1c1 -o S16r1c1 |\
+ audio/mp3enc -r -v -q 0
--- /dev/null
+++ b/2opus
@@ -1,0 +1,15 @@
+#!/bin/rc
+l=(--bitrate 128)
+if(~ $1 -l){
+ l=()
+ shift
+}
+play -o /fd/1 >[2]/dev/null |\
+ audio/opusenc \
+ --quiet \
+ --music \
+ --downmix-stereo \
+ --raw \
+ --raw-rate 44100 \
+ $l \
+ - -
--- /dev/null
+++ b/aconv
@@ -1,0 +1,11 @@
+#!/bin/rc
+parm=()
+if(~ $1 -l){
+ parm=(-l)
+ shift
+}
+pref=$1
+for(i in $*(2-)){
+ echo $i
+ 2opus $*(2-) <$i >`{echo $i | mfmt $pref opus}
+}
--- a/fn
+++ b/fn
@@ -1,10 +1,6 @@
# audio
-# convert audio file to mp3
-fn 2mp3{ play -o /fd/1 >[2]/dev/null | audio/pcmconv -i s16r1c1 -o S16r1c1 | audio/mp3enc -q 0 }
# playback samples from microphone (needs setup)
fn admp{ dd -bs 4x441 </dev/audio >/dev/audio }
-# audio file name standardization
-fn mfmt{ sed $"*^';s/^''//;s/''$//;s/[\[\]\!,\(\)''\$\*\?:\;=]//g;s/\&/and/g;s/ - /./g;s/\.[^\.]+$/.mp3/;s/ /./g;s/\.\././g' | tr A-Z a-z }
# decode audio files(s) and visualize with pplay(1)
fn pcm{ @{o=(); while(~ $1 -?) o=($o $1) && shift; play -o /fd/1 $* >[2]/dev/null | pplay $o}}
# same, without temporary viariables (???)
--- /dev/null
+++ b/mfmt
@@ -1,0 +1,15 @@
+#!/bin/rc
+pref=$1
+fmt=$2
+sed \
+ $pref^'
+ s/^''//
+ s/''$//
+ s/[\[\]\!,\(\)''\$\*\?:\;=]//g
+ s/\&/and/g
+ s/( - | |_)/./g
+ s/\.[^\.]+$/.'^$fmt^'/
+ s/ /./g
+ s/\.\././g
+' |\
+ tr A-Z a-z