speaker.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************
00022  ** Started on  Mon Oct 15 18:01:12 2007 Georg Martius
00023  ** Last update Mon Oct 15 18:01:12 2007 Georg Martius
00024  *                                                                         *
00025  *  DESCRIPTION                                                            *
00026  *                                                                         *
00027  *   $Log: speaker.h,v $
00028  *   Revision 1.1  2007/11/07 13:17:40  martius
00029  *   motors in a general sense (like sound, light,...)
00030  *
00031  *
00032  *                                                                 *
00033  ***************************************************************************/
00034 #ifndef         SPEAKER_H_
00035 # define        SPEAKER_H_
00036 
00037 #include "motor.h"
00038 
00039 namespace lpzrobots {
00040   
00041   class Speaker: public Motor {
00042   public: 
00043     Speaker(float frequency)
00044       : frequency(frequency) {
00045     }
00046     virtual ~Speaker() {};
00047     
00048     virtual void init(Primitive* own){
00049       this->own=own;
00050     }
00051 
00052     virtual int getMotorNumber() const{
00053       return 1;
00054     };
00055 
00056     virtual bool act(GlobalData& globaldata){
00057       globaldata.sounds.push_back(Sound(globaldata.time, own->getPosition(),
00058                                         intensity,frequency, (void*)own));
00059       return true;
00060     }
00061 
00062     virtual int set(const motor* values, int length){
00063       if(length>0)
00064         intensity=values[0];
00065       return 1;
00066     };    
00067     
00068   private:
00069     Primitive* own;
00070     float frequency;    
00071     float intensity;
00072   };
00073 
00074 }
00075 
00076 #endif      /* !SPEAKER_H_ */

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7