Playing Sound Files .wav
I am attempting to play basic wav files in one of my ROS nodes. I tried using system("canberra-gtk-play -f file.wav")
, but then I realized it negatively impacted the behaviour of my program. Why is that, precisely? I suppose that such system calls are not thread safe? Anyway, that is not my real question.
What would be the best way of playing a short wav file in ROS? I found the ROS sound_play package, but I would rather not rely on another ROS node if possible...
Asked by Zayin on 2014-03-23 13:22:22 UTC
Answers
Please explain what exactly you mean by it negatively impacted the behaviour of my program
.
There is no core ROS functionality to play sound. You will have to use some library or system calls or some other ROS package that implements this behaviour. Why not use sound_play
, if that provides the means to play sound on another node? I suggest to check out its documentation if you want to use it.
Otherwise, the question of how to to play sound in a Linux program is a bit off topic for this forum. I'm sure google will bring up a ton of info.
Asked by demmeln on 2014-03-23 15:46:12 UTC
Comments
Thanks for your reply. Explaining the negative effects is a bit complex. Basically, I'm developing a gesture recognition tool, and after adding system sounds, the gesture predictions became way off. I just got sound_play working, and it seems to be doing the job well-enough. Problem solved...
Asked by Zayin on 2014-03-23 17:18:33 UTC
Maybe the problem was the the system call is synchronous, i.e. it was blocking your program until the sound finished playing, such that you ran into timing issues. Maybe using asynchronous system calls or threads would have helped, but your have a solution.
Asked by demmeln on 2014-03-28 01:25:51 UTC
You could hit accept
for my answer, so people see it is solved.
Asked by demmeln on 2014-03-28 01:26:06 UTC
Comments