Play Sound in YARP

From Wiki for iCub and Friends
Jump to: navigation, search

Play a wav in YARP?

You'll need the portaudio device compiled. If it is, then you can do something like this:

 #include <yarp/sig/SoundFile.h>
 using namespace yarp::sig::file;
 #include <yarp/dev/all.h>
 using namespace yarp::dev;
 Sound s;
 bool ok = read(s,"source.wav");
 if (!ok) { printf("FAIL\n"); exit(1); }
 PolyDriver dd;
 Property config;
 ... // may need to choose an output
 ok =;
 if (!ok) { printf("FAIL (device)\n"); exit(1); }
 IAudioRender *audio_out = NULL;
 ok = dd.view(audio_out);
 if (!ok) { printf("FAIL (interface)\n"); exit(1); }