test.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2009, Willow Garage, Inc.
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the Willow Garage nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 
00035 #include <sound_play/sound_play.h>
00036 #include <unistd.h>
00037 
00038 void sleepok(int t, ros::NodeHandle &nh)
00039 {
00040   if (nh.ok())
00041                 sleep(t);
00042 }
00043 
00044 int main(int argc, char **argv)
00045 {
00046   ros::init(argc, argv, "sound_play_test");
00047 
00048   ros::NodeHandle nh;
00049   sound_play::SoundClient sc;
00050 
00051   sleepok(1, nh);
00052   
00053   while(nh.ok())
00054   {
00055     sc.say("Hello world!");
00056     sleepok(2, nh);
00057 
00058     const char *str1 = "I am annoying.";
00059     sc.repeat(str1);
00060     sleepok(4, nh);
00061     sc.stopSaying(str1);
00062 
00063     sc.playWave("/usr/share/xemacs21/xemacs-packages/etc/sounds/boing.wav");
00064     sleepok(2, nh);
00065 
00066     const char *str2 = "/usr/share/xemacs21/xemacs-packages/etc/sounds/piano-beep.wav";
00067     sc.startWave(str2);
00068     sleepok(4, nh);
00069     sc.stopWave(str2);
00070 
00071     sc.play(sound_play::SoundRequest::NEEDS_UNPLUGGING);
00072     sleepok(2, nh);
00073 
00074     sc.start(sound_play::SoundRequest::BACKINGUP);
00075     sleepok(4, nh);
00076     sc.stop(sound_play::SoundRequest::BACKINGUP);
00077 
00078                 sleepok(2, nh);
00079                 sound_play::Sound s1 = sc.waveSound("/usr/share/xemacs21/xemacs-packages/etc/sounds/boing.wav");
00080                 s1.repeat();
00081                 sleepok(1, nh);
00082                 s1.stop();
00083                 
00084                 sleepok(2, nh);
00085                 sound_play::Sound s2 = sc.voiceSound("This is a really long sentence that will get cut off.");
00086                 s2.play();
00087                 sleepok(1, nh);
00088                 s2.stop();
00089 
00090                 sleepok(2, nh);
00091                 sound_play::Sound s3 = sc.builtinSound(sound_play::SoundRequest::NEEDS_UNPLUGGING_BADLY);
00092                 s3.play();
00093                 sleepok(1, nh);
00094                 s3.stop();
00095 
00096                 sleepok(2, nh);
00097                 sound_play::Sound s4 = sc.waveSoundFromPkg("sound_play", "sounds/BACKINGUP.ogg");
00098                 s4.play();
00099                 sleepok(1, nh);
00100                 s4.stop();
00101   }
00102 }


sound_play
Author(s): Blaise Gassend
autogenerated on Thu Jun 6 2019 20:32:43