View Single Post
Old 05-10-2020, 08:12 PM   #41
PoP
 curly᷂͓̫̙᷊̥̮̾ͯͤͭͬͦͨ ʎʌɹnɔ
PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.
 
PoP's Avatar
 
Posts: 3,018
Karma: 50506927
Join Date: Dec 2010
Location: ♁ ᴺ₄₅°₃₀' ᵂ₇₃°₃₇' ±₆₀"
Device: K3₃.₄.₃ PW3&4₅.₁₃.₃
With this small change works fine on the PW3:
Code:
#!/bin/sh
# script to play a local file on pw4

# add required library

export LD_LIBRARY_PATH=/mnt/us/extensions/sox/library:$LD_LIBRARY_PATH

# get soxi data from file to be played

/mnt/us/extensions/sox/soxi "$1" >/var/tmp/soxidata.txt

# now to parse necessary information

Chan=$(awk -F: '/Channels/ {gsub(" ","");print $2}' /var/tmp/soxidata.txt)

Wide=$(awk -F: '/Precision/ {gsub(" ","");gsub("-bit","");print $2}' /var/tmp/soxidata.txt)

Rate=$(awk -F: '/Sample Rate/ {gsub(" ","");print $2}' /var/tmp/soxidata.txt)

rm /var/tmp/soxidata.txt

# now determine how to play it

driver="unknown"

which aplay>/dev/null && driver="alsa"

which gst-launch>/dev/null && driver="gst"

# now start playing

case "$driver" in

     alsa)

     /mnt/us/extensions/sox/sox "$1" -t wav - -- |  aplay
     ;;

     gst)

     /mnt/us/extensions/sox/sox "$1" -t raw - -- |  /usr/bin/gst-launch \
     filesrc location=/dev/stdin \
     ! audio/x-raw-int, \
        endianness='(int)'1234, \
        signed='(boolean)'true, \
        width='(int)'$Wide, \
        depth='(int)'$Wide, \
        rate='(int)'$Rate, \
        channels='(int)'$Chan \
     ! queue \
     ! mixersink&
     ;;

     *)

     echo "Unknown sound driver, cannot play media."
     ;;
esac
PoP is offline   Reply With Quote