- Aldebaran documentation |
- C++ Libraries |
- index

libalaudio 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
alsoundextractor.cpp
Go to the documentation of this file.
1
7 #include <alaudio/alsoundextractor.h>
8 #include <alproxies/almemoryproxy.h>
9 #include <alcommon/alproxy.h>
10 #include <alcommon/albroker.h>
11 #include <iostream>
12
13 namespace AL
14 {
15
16 ALSoundExtractor::ALSoundExtractor(boost::shared_ptr<ALBroker> pBroker,
17 std::string pName)
18 : ALExtractor(pBroker, pName)
19 , fIsRunning(false)
20 , fbDebugMode(false)
21 , audioDevice()
22 {
23 functionName("setDebugMode",
24 "ALSoundExtractor",
25 "enable/disable the printing of some debug information");
26 addParam("bSetOrUnset",
27 "enable the functionnality when true.");
28 BIND_METHOD(ALSoundExtractor::setDebugMode);
29
30 functionName("processRemote",
31 "ALSoundExtractor",
32 "enable/disable the printing of some debug information");
33 addParam("nbOfChannels",
34 "Provides the number of channels of the buffer.");
35 addParam("nbOfSamplesByChannel",
36 "Provides the number of samples by channel.");
37 addParam("timestamp",
38 "Provides the timestamp of the buffer.");
39 addParam("buffer",
40 "Provides the audio buffer as an ALValue.");
41 BIND_METHOD(ALSoundExtractor::processRemote);
42
43 functionName("processSoundRemote",
44 "ALSoundExtractor",
45 "enable/disable the printing of some debug information");
46 addParam("nbOfChannels",
47 "Provides the number of channels of the buffer.");
48 addParam("nbOfSamplesByChannel",
49 "Provides the number of samples by channel.");
50 addParam("buffer",
51 "Provides the audio buffer as an ALValue.");
52 BIND_METHOD(ALSoundExtractor::processSoundRemote);
53
54
55 try
56 {
57 audioDevice = getParentBroker()->getProxy("ALAudioDevice");
58 }
59 catch(const ALError& e)
60 {
61 qiLogWarning("audio.alsoundextractor") << e.what()
62 << " Sound capture will not work.";
63 }
64
65 fNullTimestamp.arrayReserve(2);
66 fNullTimestamp.arrayPush(0);
67 fNullTimestamp.arrayPush(0);
68 }
69
70 ALSoundExtractor::~ALSoundExtractor()
71 {
72 stopDetection();
73 }
74
75 void ALSoundExtractor::startDetection()
76 {
77 if(!fIsRunning)
78 {
79 qiLogVerbose("audio.alsoundextractor", "ALSoundExtractor : startDetection");
80 try
81 {
82 if(!audioDevice)
83 audioDevice = getParentBroker()->getProxy("ALAudioDevice");
84 audioDevice->callVoid("subscribe", this->getName());
85 }
86 catch(ALError & error)
87 {
88 fIsRunning = false;
89 throw ALError(getName(), "startDetection", error.what());
90 }
91
92 fIsRunning = true;
93 }
94 }
95
96 void ALSoundExtractor::stopDetection()
97 {
98 if(fIsRunning)
99 {
100 qiLogVerbose("audio.alsoundextractor", "ALSoundExtractor : stopDetection");
101 fIsRunning = false;
102 audioDevice->callVoid("unsubscribe", this->getName());
103 }
104 }
105
106 void ALSoundExtractor::process(const int & nbOfChannels,
107 const int & nbrOfSamplesByChannel,
108 const AL_SOUND_FORMAT * buffer,
109 const ALValue & timestamp)
110 {
111 /* Since ALAudioDevice CLient is only calling the process method,
112 * we call the deprecated method processSound here.
113 */
114
115 processSound(nbOfChannels, nbrOfSamplesByChannel, buffer);
116 }
117
118 void ALSoundExtractor::processSound(const int pNbOfInputChannels,
119 const int pNbrSamples,
120 const AL_SOUND_FORMAT * bBuffer)
121 {
122 }
123
124 void ALSoundExtractor::processSoundRemote(const int & pNbOfInputChannels,
125 const int & pNbrSamples,
126 const ALValue & pBuffer)
127 {
128 }
129
130
131 void ALSoundExtractor::processRemote(const int & pNbOfInputChannels,
132 const int & pNbrSamples,
133 const ALValue & timestamp,
134 const ALValue & buffer)
135 {
136 process(pNbOfInputChannels,
137 pNbrSamples,
138 (const AL_SOUND_FORMAT *)buffer.GetBinary(),
139 timestamp);
140
141 processSoundRemote(pNbOfInputChannels,
142 pNbrSamples,
143 (const AL_SOUND_FORMAT *)buffer.GetBinary());
144 }
145
146 std::vector<std::string> ALSoundExtractor::getOutputNames(void)
147 {
148 return getParentBroker()->getProxy("ALMemory")->
149 call<std::vector<std::string> >("getExtractorEvent", getName());
150 }
151
152 } // namespace AL
AL_SOUND_FORMAT
signed short AL_SOUND_FORMAT
Definition: alsoundextractor.h:19
AL::ALSoundExtractor::processSound
virtual QI_API_DEPRECATED void processSound(const int nbOfChannels, const int nbrOfSamplesByChannel, const AL_SOUND_FORMAT *buffer)
Definition: alsoundextractor.cpp:118
AL::ALSoundExtractor::~ALSoundExtractor
virtual ~ALSoundExtractor()
Definition: alsoundextractor.cpp:70
AL::ALSoundExtractor::fIsRunning
bool fIsRunning
Definition: alsoundextractor.h:129
AL::ALSoundExtractor::startDetection
virtual void startDetection(void)
Definition: alsoundextractor.cpp:75
alsoundextractor.h
AL::ALSoundExtractor::ALSoundExtractor
ALSoundExtractor(boost::shared_ptr< AL::ALBroker > pBroker, std::string pName)
Definition: alsoundextractor.cpp:16
AL::ALSoundExtractor::fNullTimestamp
ALValue fNullTimestamp
Definition: alsoundextractor.h:132
AL::ALSoundExtractor::setDebugMode
QI_API_DEPRECATED void setDebugMode(const bool &pbSetOrUnset=true)
Definition: alsoundextractor.h:72
AL::ALSoundExtractor::process
virtual void process(const int &nbOfChannels, const int &nbrOfSamplesByChannel, const AL_SOUND_FORMAT *buffer, const ALValue &timestamp)
Definition: alsoundextractor.cpp:106
AL::ALSoundExtractor::audioDevice
boost::shared_ptr< ALProxy > audioDevice
Definition: alsoundextractor.h:131
AL::ALSoundExtractor::stopDetection
virtual void stopDetection(void)
Definition: alsoundextractor.cpp:96
AL::ALSoundExtractor::processSoundRemote
virtual QI_API_DEPRECATED void processSoundRemote(const int &nbOfChannels, const int &nbrOfSamplesByChannel, const ALValue &buffer)
Definition: alsoundextractor.cpp:124
AL::ALExtractor