0
$\begingroup$

Rosanswers logo

hi everyone. I want to play a sound file on a C++ node with sound_play. I have downloaded the audio_common package already , but I don't know how to use it to realize my purpose. Please anyone can give me a detailed tutorial . I use indigo catkin ubuntu 14.04


Originally posted by Joy.Lin on ROS Answers with karma: 7 on 2016-05-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

From the 'Code API' link on the sound_play wiki page you can get to the documentation and example for the C++ SoundPlay client.

The function you probably want to use is playWaveFromPkg; it should look something like this:

int main(int argc, char ** argv) {
    ros::init(argc, argv, "example");

    ros::NodeHandle nh;
    sound_play::SoundClient sc;

    sc.playWaveFromPkg("sound_play", "sounds/BACKINGUP.ogg");

    ros::spin();
}

Originally posted by ahendrix with karma: 47576 on 2016-05-10

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Joy.Lin on 2016-05-14:
Thank you very much . I can play the sound file successfully!! However, I can't control its volume, it's always too low.

Comment by rodrigobdz on 2016-06-11:
The documentation and example links are broken

Comment by rodrigobdz on 2016-06-11:
The links are now found under the docs directory for each distribution

Comment by ahendrix on 2016-06-11:
Fixed the links; thanks for catching that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.