forked from robotology/yarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsound_loopback.cpp
49 lines (39 loc) · 1003 Bytes
/
sound_loopback.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Copyright: (C) 2010 RobotCub Consortium
* Authors: Paul Fitzpatrick, Francesco Nori
* CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
*/
#include <stdio.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/AudioGrabberInterfaces.h>
#include <yarp/os/Property.h>
#include <yarp/os/Network.h>
#include <yarp/os/Port.h>
using namespace yarp::os;
using namespace yarp::sig;
using namespace yarp::dev;
int main(int argc, char *argv[]) {
// Open the network
Network yarp;
// Get an audio device.
Property conf;
conf.put("device","portaudio");
PolyDriver poly(conf);
IAudioGrabberSound *get;
IAudioRender *put;
// Make sure we can both read and write sound
poly.view(get);
poly.view(put);
if (get==NULL&&put==NULL) {
printf("cannot open interface\n");
return 1;
}
//Grab and render
Sound s;
while (true)
{
get->getSound(s);
put->renderSound(s);
}
return 0;
}