I have this .sh:
#!/bin/bash
cd /home/pi/Desktop/PiFmRds/src
for f in $(ls -1 /home/pi/Desktop/Music/Acapella/*.mp3|sort -R); do sox -t mp3 "$f" -t wav -r 44100 - | sudo ./pi_fm_rds -freq 102.1 -audio - -ps WZSFM -rt "ZSFM"; done
Basically, it plays through all the files in a directory in a random order, converts them from mp3 to wav on-the-fly, and then pipes that into pifm. Pifm is a program that can broadcast on fm radio. The thing is, since I am using a forloop there is a bit of static on the radio in between each file, because since it is running the pifm command to broadcast for each individual file, it makes a bit of static between when the pifm command stops after one file and starts for the next. Is there a way to have the forloop only going on the first part of the command, which picks the random song, but not on the pifm part, which actually broadcasts? This would make it that the pifm command is always broadcasting, and the forloop only applys to the part of the command shuffling through the files.
Also, I tried this:
#!/bin/bash
cd /home/pi/Desktop/PiFmRds/src
for f in $(ls -1 /home/pi/Desktop/Music/Acapella/*.mp3|sort -R); do sox -t mp3 "$f" -t wav -r 44100 - ; done | sudo ./pi_fm_rds -freq 102.1 -audio - -ps WZSFM -rt "ZSFM"
But it stopped after playing one file.
EDIT: I have summed up the problem as this: The reason there is static between files is because the pifm command is broadcasting each file, but stops and reruns for each iteration of the forloop, so there is just static in between iterations. How can I have it cycle through each file INDIVIDUALLY (kinda necessary, or else I end up with a bunch more problems), but still have it boradcasting the whole time?
ls
(and what to do instead)? – cas Jul 05 '21 at 01:48