Ask Your Question
0

Playing Sound Files .wav [closed]

asked 2014-03-23 13:22:22 -0500

Zayin gravatar image

updated 2014-03-23 14:59:56 -0500

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...

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Zayin
close date 2014-03-23 17:19:15

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-03-23 15:46:12 -0500

demmeln gravatar image

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.

edit flag offensive delete link more

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...

Zayin gravatar image Zayin  ( 2014-03-23 17:18:33 -0500 )edit

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.

demmeln gravatar image demmeln  ( 2014-03-28 01:25:51 -0500 )edit

You could hit `accept` for my answer, so people see it is solved.

demmeln gravatar image demmeln  ( 2014-03-28 01:26:06 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-03-23 13:22:22 -0500

Seen: 566 times

Last updated: Mar 23 '14