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