Skip to content

Instantly share code, notes, and snippets.

@tomtastic
Last active April 24, 2023 12:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomtastic/f8b8fcfa4113e0e8cabc7788a3ddc3c4 to your computer and use it in GitHub Desktop.
Save tomtastic/f8b8fcfa4113e0e8cabc7788a3ddc3c4 to your computer and use it in GitHub Desktop.
[root@kindle root]# cat /mnt/us/extensions/sox/playfile.sh
#!/bin/sh
# script to play a local file on pw4
# first get soxi data from file to be played
export LD_LIBRARY_PATH=/mnt/us/extensions/sox/library:$LD_LIBRARY_PATH
/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)
echo "Chan=$Chan"
Wide=$(awk -F: '/Precision/ {gsub(" ","");gsub("-bit","");print $2}' /var/tmp/soxidata.txt)
echo "Wide=$Wide"
Rate=$(awk -F: '/Sample Rate/ {gsub(" ","");print $2}' /var/tmp/soxidata.txt)
echo "Rate=$Rate"
rm /var/tmp/soxidata.txt
# now start playing
/mnt/us/extensions/sox/sox $1 -t raw - -- | /usr/bin/gst-launch -v \
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
trcm@leela~ $ kindle
Welcome to Kindle!
#################################################
# N O T I C E * N O T I C E * N O T I C E #
#################################################
Rootfs is mounted read-only. Invoke mntroot rw to
switch back to a writable rootfs.
#################################################
[root@kindle root]# cd /mnt/us/extensions/sox/
[root@kindle sox]# ./playfile.sh /mnt/us/music/01-Diamond_Star.mp3
Chan=2
Wide=16
Rate=48000
Setting pipeline to PAUSED ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)2
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)2
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)2
/GstPipeline:pipeline0/MixerSink:mixersink0.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)2
/mnt/us/extensions/sox/sox WARN sox: `-' output clipped 2314 samples; decrease volume?
Got EOS from element "pipeline0".
Execution ended after 868344182770 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
/GstPipeline:pipeline0/MixerSink:mixersink0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = NULL
Setting pipeline to NULL ...
Freeing pipeline ...
[root@kindle sox]#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment