Robot Simulator of the Robotics Group for Self-Organization of Control: sound.h Source File

# sound.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024
    00025 #ifndef         SOUND_H_
    00026 # define        SOUND_H_
    00027
    00028 #include "pos.h"
    00029
    00030 namespace lpzrobots {
    00031
    00032   class OSGSphere;
    00033   class OsgHandle;
    00034
    00035   /// Object that represents a sound signal in the simulator
    00036   class Sound {
    00037   public:
    00038     Sound(double time, const Pos& pos, float intensity, float frequency, void* sender)
    00039       : time(time), pos(pos),
    00040       intensity(intensity), frequency(frequency), sender(sender),
    00041       visual(0) {}
    00042
    00043     ~Sound();
    00044
    00045     /// nice predicate function for finding old sound signals
    00046     struct older_than : public std::unary_function<const Sound&, bool> {
    00047       older_than(double time) : time(time) {}
    00048       double time;
    00049       bool operator()(const Sound& s) { return s.time < time; }
    00050     };
    00051
    00052     void render(const OsgHandle& osgHandle);
    00053
    00054     double time;
    00055     Pos pos;    ///< emission position
    00056     float intensity; ///< intensity -1..1
    00057     float frequency; ///< frequency -1..1
    00058     void* sender;    ///< pointer to the sender (can be used for self
    00059                      ///detection)
    00060
    00061   private:
    00062     OSGSphere* visual;
    00063   };
    00064
    00065 } // end namespace
    00066
    00067 #endif      /* !SOUND_H_ */