Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

PitchEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_PitchEvent_h_
00003 #define INCLUDED_PitchEvent_h_
00004 
00005 #include "EventBase.h"
00006 
00007 //! Provides information about a tone detected from the microphone(s)
00008 class PitchEvent : public EventBase {
00009 public:
00010   //! default constructor, sets generator ID, but nothing else
00011   PitchEvent() : EventBase(), freq(), amplitude(), confidence() {genID=EventBase::micPitchEGID;}
00012   
00013   //!constructor
00014   PitchEvent(size_t sid, EventTypeID_t type, const float freq_, const char *name_, const float amplitude_, const unsigned int duration_, const float confidence_) 
00015   : EventBase(EventBase::micPitchEGID, sid, type,duration_,name_,(type==deactivateETID) ? 0 : confidence_*amplitude_), freq(freq_), amplitude(amplitude_), confidence(confidence_)
00016   {}
00017   
00018   //! copy constructor (does what you'd expect, explicit to satisify compiler warning)
00019   PitchEvent(const PitchEvent &p)
00020   : EventBase(p), freq(p.freq), amplitude(p.amplitude), confidence(p.confidence)
00021   {}
00022   
00023   //! assignment operator (does what you'd expect, explicit to satisify compiler warning)
00024   PitchEvent & operator=(const PitchEvent &p) {
00025     EventBase::operator=(p); freq=p.freq; amplitude=p.amplitude; confidence=p.confidence;
00026     return *this;
00027   }
00028   
00029   virtual EventBase* clone() const { return new PitchEvent(*this); }
00030   
00031   virtual std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00032 
00033   virtual unsigned int getBinSize() const;
00034   virtual unsigned int loadBinaryBuffer(const char buf[], unsigned int len);
00035   virtual unsigned int saveBinaryBuffer(char buf[], unsigned int len) const;
00036   virtual void loadXML(xmlNode* node);
00037   virtual void saveXML(xmlNode * node) const;
00038   
00039   float getFreq(void) const { return freq; } //!< returns #freq
00040   float getAmplitude(void) const { return amplitude; } //!< returns #amplitude
00041   float getConfidence(void) const { return confidence; } //!< returns #confidence
00042   
00043   virtual classTypeID_t getClassTypeID() const { return autoRegisterPitchEvent; }
00044 
00045 protected:
00046   float freq; //!< the frequency (Hz) being detected
00047   float amplitude; //!< indicates how loud the signal is -- can be both loud and noisy, loud doesn't necessarily mean "strong"
00048   float confidence; //!< indicates how much variance is being detected
00049 
00050   //! causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
00051   static const EventBase::classTypeID_t autoRegisterPitchEvent;
00052 };
00053 
00054 /*! @file
00055  * @brief Describes PitchEvent, which provides information about a tone detected from the microphone(s)
00056  * @author Matus Telgarsky and Jonah Sherman (Creators)
00057  * @author Ethan Tira-Thompson (imported into framework)
00058  *
00059  * Originally written as a part of a final project at Carnegie Mellon (15-494 Cognitive Robotics, Spring 2006)
00060  */
00061 
00062 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:46 2016 by Doxygen 1.6.3