libalaudio  1.14
 All Classes Files Functions Pages
alsoundextractor.h
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 
43 enum
44 {
45  ALLCHANNELS = 0,
46  LEFTCHANNEL,
47  RIGHTCHANNEL,
48  FRONTCHANNEL,
49  REARCHANNEL
50 };
51 
53 {
54 public:
55  ALSoundExtractor( boost::shared_ptr<AL::ALBroker> pBroker, std::string pName );
56 
57  virtual ~ALSoundExtractor();
58 
59  virtual std::string version(void) {return "";}
60  virtual void startDetection(void);
61  virtual void stopDetection(void);
62 
68  QI_API_DEPRECATED void setDebugMode(const bool &pbSetOrUnset = true)
69  {
70  qiLogWarning("audio.alsoundextractor", "The call to setDebugMode() is "
71  "now deprectated. This functionnality is now handled by qi/log");
72  fbDebugMode = pbSetOrUnset;
73  }
74 
79  QI_API_DEPRECATED inline bool getDebugMode(void)
80  {
81  qiLogWarning("audio.alsoundextractor", "The call to getDebugMode() is "
82  "now deprectated. This functionnality is now handled by qi/log");
83  return fbDebugMode;
84  }
85 
86 
87  virtual void process(const int & nbOfChannels,
88  const int & nbrOfSamplesByChannel,
89  const AL_SOUND_FORMAT * buffer,
90  const ALValue & timestamp){}
91 
92 
93  QI_API_DEPRECATED virtual void processSound(const int nbOfChannels,
94  const int nbrOfSamplesByChannel,
95  const AL_SOUND_FORMAT* buffer);
96 
97  QI_API_DEPRECATED virtual void processSoundRemote(const int & nbOfChannels,
98  const int & nbrOfSamplesByChannel,
99  const ALValue & buffer);
100 
101 
102 private:
103  void processRemote(const int & nbOfChannels,
104  const int & nbrOfSamplesByChannel,
105  const ALValue & timestamp,
106  const ALValue & buffer);
107 
108  void xStartDetection(const int pPeriod,
109  const float pPrecision)
110  {
111  startDetection();
112  }
113 
114  virtual void xUpdateParameters(const int pPeriod,
115  const float pPrecision){}
116 
117  void xStopDetection(void)
118  {
119  stopDetection();
120  }
121 
122  virtual std::vector<std::string> getOutputNames();
123 
124 protected:
125 
126  bool fIsRunning;
127  bool fbDebugMode;
128  boost::shared_ptr<ALProxy> audioDevice;
129  ALValue fNullTimestamp;
130 };
131 
132 }
133 
134 #endif