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   //!constructor
00011   PitchEvent(unsigned int sid, EventTypeID_t type, const float freq_, const char *name_, const float amplitude_, const unsigned int duration_, const float confidence_) 
00012   : EventBase(EventBase::micPitchEGID, sid, type,duration_,name_,(type==deactivateETID) ? 0 : confidence_*amplitude_), freq(freq_), amplitude(amplitude_), confidence(confidence_)
00013   {}
00014 
00015   //! copy constructor (does what you'd expect, explicit to satisify compiler warning)
00016   PitchEvent(const PitchEvent &p)
00017   : EventBase(p), freq(p.freq), amplitude(p.amplitude), confidence(p.confidence)
00018   {}
00019   
00020   //! assignment operator (does what you'd expect, explicit to satisify compiler warning)
00021   PitchEvent & operator=(const PitchEvent &p) {
00022     EventBase::operator=(p); freq=p.freq; amplitude=p.amplitude; confidence=p.confidence;
00023     return *this;
00024   }
00025   
00026   virtual EventBase* clone() const { return new PitchEvent(*this); }
00027   
00028   virtual std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00029 
00030   virtual unsigned int getBinSize() const;
00031   virtual unsigned int loadBinaryBuffer(const char buf[], unsigned int len);
00032   virtual unsigned int saveBinaryBuffer(char buf[], unsigned int len) const;
00033   virtual void loadXML(xmlNode* node);
00034   virtual void saveXML(xmlNode * node) const;
00035   
00036   float getFreq(void) const { return freq; } //!< returns #freq
00037   float getAmplitude(void) const { return amplitude; } //!< returns #amplitude
00038   float getConfidence(void) const { return confidence; } //!< returns #confidence
00039   
00040 protected:
00041   float freq; //!< the frequency (Hz) being detected
00042   float amplitude; //!< indicates how loud the signal is -- can be both loud and noisy, loud doesn't necessarily mean "strong"
00043   float confidence; //!< indicates how much variance is being detected
00044 };
00045 
00046 /*! @file
00047  * @brief Describes PitchEvent, which provides information about a tone detected from the microphone(s)
00048  * @author Matus Telgarsky and Jonah Sherman (Creators)
00049  * @author Ethan Tira-Thompson (imported into framework)
00050  *
00051  * Originally written as a part of a final project at Carnegie Mellon (15-494 Cognitive Robotics, Spring 2006)
00052  *
00053  * $Author: ejt $
00054  * $Name: tekkotsu-3_0 $
00055  * $Revision: 1.3 $
00056  * $State: Exp $
00057  * $Date: 2006/09/25 20:49:24 $
00058  */
00059 
00060 #endif

Tekkotsu v3.0
Generated Wed Oct 4 00:03:45 2006 by Doxygen 1.4.7