libalaudio  2.1.0.18
/home/opennao/work/master/sdk/libnaoqi/libalaudio/alaudio/alsoundextractor.h
Go to the documentation of this file.
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 AUDIOCHANNELTYPE
00044 {
00045   ALLCHANNELS  = 0,
00046   LEFTCHANNEL  = 1,
00047   RIGHTCHANNEL = 2,
00048   FRONTCHANNEL = 3,
00049   REARCHANNEL  = 4,
00050   FIRSTCHANNEL = LEFTCHANNEL,
00051   SECONDCHANNEL= RIGHTCHANNEL,
00052   THIRDCHANNEL = FRONTCHANNEL,
00053   FOURTHCHANNEL= REARCHANNEL
00054 };
00055 
00056 class ALSoundExtractor: public ALExtractor
00057 {
00058 public:
00059   ALSoundExtractor( boost::shared_ptr<AL::ALBroker> pBroker, std::string pName );
00060 
00061   virtual ~ALSoundExtractor();
00062 
00063   virtual std::string version(void) {return "";}
00064   virtual void startDetection(void);
00065   virtual void stopDetection(void);
00066 
00072   QI_API_DEPRECATED void setDebugMode(const bool &pbSetOrUnset = true)
00073   {
00074     qiLogWarning("audio.alsoundextractor", "The call to setDebugMode() is "
00075                  "now deprectated. This functionnality is now handled by qi/log");
00076     fbDebugMode = pbSetOrUnset;
00077   }
00078 
00083   QI_API_DEPRECATED inline bool getDebugMode(void)
00084   {
00085     qiLogWarning("audio.alsoundextractor", "The call to getDebugMode() is "
00086                  "now deprectated. This functionnality is now handled by qi/log");
00087     return fbDebugMode;
00088   }
00089 
00090 
00091   virtual void process(const int & nbOfChannels,
00092                        const int & nbrOfSamplesByChannel,
00093                        const AL_SOUND_FORMAT * buffer,
00094                        const ALValue & timestamp);
00095 
00096 
00097   QI_API_DEPRECATED virtual void processSound(const int nbOfChannels,
00098                                           const int nbrOfSamplesByChannel,
00099                                           const AL_SOUND_FORMAT* buffer);
00100 
00101   QI_API_DEPRECATED virtual void processSoundRemote(const int & nbOfChannels,
00102                                   const int & nbrOfSamplesByChannel,
00103                                   const ALValue & buffer);
00104 
00105 private:
00106   void processRemote(const int & nbOfChannels,
00107                      const int & nbrOfSamplesByChannel,
00108                      const ALValue & timestamp,
00109                      const ALValue & buffer);
00110 
00111   void xStartDetection(const int pPeriod,
00112                        const float pPrecision)
00113   {
00114     startDetection();
00115   }
00116 
00117   virtual void xUpdateParameters(const int pPeriod,
00118                                  const float pPrecision){}
00119 
00120   void xStopDetection(void)
00121   {
00122     stopDetection();
00123   }
00124 
00125   virtual std::vector<std::string> getOutputNames();
00126 
00127 protected:
00128 
00129   bool fIsRunning;
00130   bool fbDebugMode;
00131   boost::shared_ptr<ALProxy>  audioDevice;
00132   ALValue fNullTimestamp;
00133 };
00134 
00135 }
00136 
00137 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines