Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how long the audio will repeat #162

Open
zhouhaohua opened this issue Feb 8, 2021 · 1 comment
Open

how long the audio will repeat #162

zhouhaohua opened this issue Feb 8, 2021 · 1 comment

Comments

@zhouhaohua
Copy link

any parameter to enable the loop number, I have tried
sudo ./pi_fm_rds -audio sound.wav

it run forever, actually I want control the repeat time , how to do that?

@Lucstay11
Copy link

Lucstay11 commented Feb 5, 2023

Hi I was in the same situation as you I wanted to play the sound only once because by default it is played in an infinite loop. So I inspected the code and I understood the problem.
At line 487 of the src/pi_fm_rds.c file, it makes an infinite loop that goes through the song file like this: for (;;) { code...}
So I tested several techniques to stop the sound file when it is finished and I found to loop up to the size in KO of the file so replace the (;;) by (int i=1; i<ppm; i++).
The ppm variable is an argument variable that we hardly ever use so I took it.
So once that change you have to recompile all that in the src folder:

$ src/
sudo make clean
sudo make

So now use that like this:

size_file=$(du song.wav | awk '{print $1}')// Store sound file size in a variable
sudo ./pi_fm_rds -freq 105 -ps "Hacked!" -rt "Hello word" -ppm $size_file -audio song.wav

And hop the sound stops at the last second.
And if you want to play it 2,3,... times, you just need to multiply the size by the number of times!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants