X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fsound%2Fxmlsound.hxx;h=576ead7b13084e804621f03ce2a871572268b885;hb=d179fccfcbce8a03a2569b390414f180ef6efc85;hp=ced1e046d3d629d2608a929bb4018a40404ca31f;hpb=c2c0e19305ea3bcf8da63a42a05a70d106c394ae;p=simgear.git diff --git a/simgear/sound/xmlsound.hxx b/simgear/sound/xmlsound.hxx index ced1e046..576ead7b 100644 --- a/simgear/sound/xmlsound.hxx +++ b/simgear/sound/xmlsound.hxx @@ -1,43 +1,44 @@ -// sound.hxx -- Sound class implementation +///@file +/// Sound class implementation +/// +/// Provides a class to manage a single sound event including things like +/// looping, volume and pitch changes. // // Started by Erik Hofman, February 2002 // // Copyright (C) 2002 Erik Hofman - erik@ehofman.com // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. // -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. +// Library General Public License for more details. // -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// $Id$ - -/** - * \file sound.hxx - * Provides a class to manage a single sound event including things - * like looping, volume and pitch changes. - */ +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef _SG_SOUND_HXX #define _SG_SOUND_HXX 1 -#ifndef __cplusplus -# error This library requires C++ -#endif +#include +#include + #include -#include -#include "sample_openal.hxx" -#include "soundmgr_openal.hxx" +#include +#include + +// forward decls +class SGSampleGroup; +class SGSoundSample; +class SGCondition; +class SGPath; static const double MAX_TRANSIT_TIME = 0.1; // 100 ms. @@ -61,14 +62,15 @@ public: /** * Initialize the sound event. * - * Prior to initialization of the sound event the propgrams property root + * Prior to initialization of the sound event the program's property root * has to be defined, the sound configuration XML tree has to be loaded * and a sound manager class has to be defined. * * A sound configuration file would look like this: + * @code{xml} * * - * Define the name of the event. For refference only. + * Define the name of the event. For reference only. * Either: * looped: play this sound looped. * in-transit: play looped while the event is happening. @@ -76,8 +78,9 @@ public: * The relative path to the audio file. * Take action if this property becomes true. * Take action if this condition becomes true. + * Time after which the sound should be played. * or Define volume or pitch settings. - * Take the value of this property as a refference for the + * Take the value of this property as a reference for the * result. * Either: * dt_start: the time elapsed since this sound is playing. @@ -92,18 +95,23 @@ public: * * * + * @endcode * - * @param root The root node of the programs property tree. - * @param child A pointer to the location of the current event as defined - * in the configuration file. - * @param sndmgr A pointer to a pre-initialized sound manager class. - * @param path The path where the audio files remain. + * @param root The root node of the programs property tree. + * @param child A pointer to the location of the current event as + * defined in the configuration file. + * @param sgrp A pointer to a pre-initialized sample group class. + * @param avionics A pointer to the pre-initialized avionics sample group. + * @param path The path where the audio files remain. */ - virtual void init (SGPropertyNode *, SGPropertyNode *, SGSoundMgr *, - const string &); + virtual void init( SGPropertyNode *root, + SGPropertyNode *child, + SGSampleGroup *sgrp, + SGSampleGroup *avionics, + const SGPath& path ); /** - * Check wheter an event has happened and if action has to be taken. + * Check whether an event has happened and if action has to be taken. */ virtual void update (double dt); @@ -132,24 +140,25 @@ protected: private: - SGSoundMgr * _mgr; + SGSampleGroup * _sgrp; SGSharedPtr _sample; - SGCondition * _condition; + SGSharedPtr _condition; SGPropertyNode_ptr _property; bool _active; - string _name; + std::string _name; int _mode; double _prev_value; double _dt_play; double _dt_stop; - double _stopping; // time after the sound should have stopped. - // This is usefull for lost packets in in-trasit mode. - - vector<_snd_prop> _volume; - vector<_snd_prop> _pitch; + double _delay; // time after which the sound should be started (default: 0) + double _stopping; // time after the sound should have stopped. + // This is useful for lost packets in in-transit mode. + bool _initialized; + std::vector<_snd_prop> _volume; + std::vector<_snd_prop> _pitch; }; #endif // _SG_SOUND_HXX