libalaudio  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
alsoundextractor.h
Go to the documentation of this file.
1 
7 #pragma once
8 #ifndef _LIBALAUDIO_ALAUDIO_ALSOUNDEXTRACTOR_H_
9 #define _LIBALAUDIO_ALAUDIO_ALSOUNDEXTRACTOR_H_
10 
12 #include <alvalue/alvalue.h>
13 #include <boost/shared_ptr.hpp>
14 #include <string>
15 #include <vector>
16 #include <qi/log.hpp>
17 #include <qi/macro.hpp>
18 
19 typedef signed short AL_SOUND_FORMAT; // ASSUME: sound data are in 16 bits
20 
21 // deprecated
22 // usable and practical logging system
23 
24 #define DESACTIVATE_ALL_DEV_INFO // define me to desactivate all debug or trace info (should be defined on public release version)
25 
26 #ifndef DESACTIVATE_ALL_DEV_INFO
27 # define AL_SOUND_EXTRACTOR_DEBUG_PRINTF(...) if ( getDebugMode() ) { printf(__VA_ARGS__); }
28 # define AL_SOUND_EXTRACTOR_DEBUG_LOG(onestr) if ( getDebugMode() ) { fLoggerProxy->debug( getName(), std::string( onestr ) ); }
29 # define AL_SOUND_EXTRACTOR_INFO_LOG(onestr) if ( getDebugMode() ) { fLoggerProxy->info( getName(), std::string( onestr ) ); }
30 # define AL_SOUND_EXTRACTOR_ERROR_LOG(onestr) if ( getDebugMode() ) { fLoggerProxy->error( getName(), std::string( onestr ) ); }
31 #else
32 # define AL_SOUND_EXTRACTOR_DEBUG_PRINTF(...) /* onestr */
33 # define AL_SOUND_EXTRACTOR_DEBUG_LOG(onestr) /* onestr */
34 # define AL_SOUND_EXTRACTOR_INFO_LOG(onestr) /* onestr */
35 # define AL_SOUND_EXTRACTOR_ERROR_LOG(onestr) /* onestr */
36 #endif
37 
38 namespace AL
39 {
40 class ALProxy;
41 class ALBroker;
42 
44 {
54 };
55 
57 {
58 public:
59  ALSoundExtractor( boost::shared_ptr<AL::ALBroker> pBroker, std::string pName );
60 
61  virtual ~ALSoundExtractor();
62 
63  virtual std::string version(void) {return "";}
64  virtual void startDetection(void);
65  virtual void stopDetection(void);
66 
72  QI_API_DEPRECATED void setDebugMode(const bool &pbSetOrUnset = true)
73  {
74  qiLogWarning("audio.alsoundextractor", "The call to setDebugMode() is "
75  "now deprectated. This functionnality is now handled by qi/log");
76  fbDebugMode = pbSetOrUnset;
77  }
78 
83  QI_API_DEPRECATED inline bool getDebugMode(void)
84  {
85  qiLogWarning("audio.alsoundextractor", "The call to getDebugMode() is "
86  "now deprectated. This functionnality is now handled by qi/log");
87  return fbDebugMode;
88  }
89 
90 
91  virtual void process(const int & nbOfChannels,
92  const int & nbrOfSamplesByChannel,
93  const AL_SOUND_FORMAT * buffer,
94  const ALValue & timestamp);
95 
96 
97  QI_API_DEPRECATED virtual void processSound(const int nbOfChannels,
98  const int nbrOfSamplesByChannel,
99  const AL_SOUND_FORMAT* buffer);
100 
101  QI_API_DEPRECATED virtual void processSoundRemote(const int & nbOfChannels,
102  const int & nbrOfSamplesByChannel,
103  const ALValue & buffer);
104 
105 private:
106  void processRemote(const int & nbOfChannels,
107  const int & nbrOfSamplesByChannel,
108  const ALValue & timestamp,
109  const ALValue & buffer);
110 
111  void xStartDetection(const int pPeriod,
112  const float pPrecision)
113  {
114  startDetection();
115  }
116 
117  virtual void xUpdateParameters(const int pPeriod,
118  const float pPrecision){}
119 
120  void xStopDetection(void)
121  {
122  stopDetection();
123  }
124 
125  virtual std::vector<std::string> getOutputNames();
126 
127 protected:
128 
131  boost::shared_ptr<ALProxy> audioDevice;
132  ALValue fNullTimestamp;
133 };
134 
135 }
136 
137 #endif
signed short AL_SOUND_FORMAT
virtual QI_API_DEPRECATED void processSound(const int nbOfChannels, const int nbrOfSamplesByChannel, const AL_SOUND_FORMAT *buffer)
virtual void startDetection(void)
QI_API_DEPRECATED bool getDebugMode(void)
ALSoundExtractor(boost::shared_ptr< AL::ALBroker > pBroker, std::string pName)
QI_API_DEPRECATED void setDebugMode(const bool &pbSetOrUnset=true)
AUDIOCHANNELTYPE
virtual void process(const int &nbOfChannels, const int &nbrOfSamplesByChannel, const AL_SOUND_FORMAT *buffer, const ALValue &timestamp)
boost::shared_ptr< ALProxy > audioDevice
virtual void stopDetection(void)
virtual QI_API_DEPRECATED void processSoundRemote(const int &nbOfChannels, const int &nbrOfSamplesByChannel, const ALValue &buffer)
virtual std::string version(void)