Hi folks.
I am wondering if I could make myself clear with the headline for this
thread. Anyhow I try to be a bit more descriptive.
Below script extract is supposed to outline my challenge.
I'd like to play multiple audio files sequentially. I'll store them
all on /dev/shm during playback.
The upsampling with sox I don't want to do in realtime. This is actually the issue causing all this.
The sox sample rate conversion takes in the range of 10 to 20 seconds
depending on the file size.
The exercise: I 'd like to avoid such a long gap between the playback
of two songs, which obviously will exist if I run the script as outlined below.
I would like to convert the 2nd file of the filelist in $file in the background while the first playback is started/ongoing.
And I always want to have max 2 files + one temporary file on the ramdisk.
How would you guys do this?
THX a lot.
Code:
file=$1 # can be a directory
tmpfile=foo.wav
musicdir=`pwd`
ramdir=/dev/shm
ls -1 "$file" | grep 'wav' | sort | while read I ; do
cp -f "$I" $ramdir
cd $ramdir
sox "$I" $tmpfile rate -v -s 96000
mv $tmpfile "$playfile"
play "$playfile"
rm "$playfile"
cd $musicdir
done