libalaudio  1.14.5
alaudio/alsoundextractor.h
00001 
00007 #pragma once
00008 #ifndef _LIBALAUDIO_ALAUDIO_ALSOUNDEXTRACTOR_H_
00009 #define _LIBALAUDIO_ALAUDIO_ALSOUNDEXTRACTOR_H_
00010 
00011 #include <alextractor/alextractor.h>
00012 #include <alvalue/alvalue.h>
00013 #include <boost/shared_ptr.hpp>
00014 #include <string>
00015 #include <vector>
00016 #include <qi/log.hpp>
00017 #include <qi/macro.hpp>
00018 
00019 typedef signed short AL_SOUND_FORMAT; // ASSUME: sound data are in 16 bits
00020 
00021 // deprecated
00022 // usable and practical logging system
00023 
00024 #define DESACTIVATE_ALL_DEV_INFO          // define me to desactivate all debug or trace info (should be defined on public release version)
00025 
00026 #ifndef DESACTIVATE_ALL_DEV_INFO
00027 # define AL_SOUND_EXTRACTOR_DEBUG_PRINTF(...)    if ( getDebugMode() ) { printf(__VA_ARGS__); }
00028 # define AL_SOUND_EXTRACTOR_DEBUG_LOG(onestr)    if ( getDebugMode() ) { fLoggerProxy->debug( getName(), std::string( onestr ) ); }
00029 # define AL_SOUND_EXTRACTOR_INFO_LOG(onestr)     if ( getDebugMode() ) { fLoggerProxy->info( getName(), std::string( onestr ) ); }
00030 # define AL_SOUND_EXTRACTOR_ERROR_LOG(onestr)    if ( getDebugMode() ) { fLoggerProxy->error( getName(), std::string( onestr ) ); }
00031 #else
00032 # define AL_SOUND_EXTRACTOR_DEBUG_PRINTF(...)    /* onestr */
00033 # define AL_SOUND_EXTRACTOR_DEBUG_LOG(onestr)    /* onestr */
00034 # define AL_SOUND_EXTRACTOR_INFO_LOG(onestr)     /* onestr */
00035 # define AL_SOUND_EXTRACTOR_ERROR_LOG(onestr)    /* onestr */
00036 #endif
00037 
00038 namespace AL
00039 {
00040 class ALProxy;
00041 class ALBroker;
00042 
00043 enum
00044 {
00045   ALLCHANNELS = 0,
00046   LEFTCHANNEL,
00047   RIGHTCHANNEL,
00048   FRONTCHANNEL,
00049   REARCHANNEL
00050 };
00051 
00052 class ALSoundExtractor: public ALExtractor
00053 {
00054 public:
00055   ALSoundExtractor( boost::shared_ptr<AL::ALBroker> pBroker, std::string pName );
00056 
00057   virtual ~ALSoundExtractor();
00058 
00059   virtual std::string version(void) {return "";}
00060   virtual void startDetection(void);
00061   virtual void stopDetection(void);
00062 
00068   QI_API_DEPRECATED void setDebugMode(const bool &pbSetOrUnset = true)
00069   {
00070     qiLogWarning("audio.alsoundextractor", "The call to setDebugMode() is "
00071                  "now deprectated. This functionnality is now handled by qi/log");
00072     fbDebugMode = pbSetOrUnset;
00073   }
00074 
00079   QI_API_DEPRECATED inline bool getDebugMode(void)
00080   {
00081     qiLogWarning("audio.alsoundextractor", "The call to getDebugMode() is "
00082                  "now deprectated. This functionnality is now handled by qi/log");
00083     return fbDebugMode;
00084   }
00085 
00086 
00087   virtual void process(const int & nbOfChannels,
00088                        const int & nbrOfSamplesByChannel,
00089                        const AL_SOUND_FORMAT * buffer,
00090                        const ALValue & timestamp){}
00091 
00092 
00093   QI_API_DEPRECATED virtual void processSound(const int nbOfChannels,
00094                                           const int nbrOfSamplesByChannel,
00095                                           const AL_SOUND_FORMAT* buffer);
00096 
00097   QI_API_DEPRECATED virtual void processSoundRemote(const int & nbOfChannels,
00098                                   const int & nbrOfSamplesByChannel,
00099                                   const ALValue & buffer);
00100 
00101 
00102 private:
00103   void processRemote(const int & nbOfChannels,
00104                      const int & nbrOfSamplesByChannel,
00105                      const ALValue & timestamp,
00106                      const ALValue & buffer);
00107 
00108   void xStartDetection(const int pPeriod,
00109                        const float pPrecision)
00110   {
00111     startDetection();
00112   }
00113 
00114   virtual void xUpdateParameters(const int pPeriod,
00115                                  const float pPrecision){}
00116 
00117   void xStopDetection(void)
00118   {
00119     stopDetection();
00120   }
00121 
00122   virtual std::vector<std::string> getOutputNames();
00123 
00124 protected:
00125 
00126   bool fIsRunning;
00127   bool fbDebugMode;
00128   boost::shared_ptr<ALProxy>  audioDevice;
00129   ALValue fNullTimestamp;
00130 };
00131 
00132 }
00133 
00134 #endif
 All Classes Files Functions