/usr/include/simgear/sound/xmlsound.hxx is in libsimgear-dev 3.0.0-6+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | // sound.hxx -- Sound class implementation
//
// 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 program 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.
//
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
/**
* \file sound.hxx
* Provides a class to manage a single sound event including things
* like looping, volume and pitch changes.
*/
#ifndef _SG_SOUND_HXX
#define _SG_SOUND_HXX 1
#include <vector>
#include <string>
#include <simgear/compiler.h>
#include <simgear/props/propsfwd.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
// forward decls
class SGSampleGroup;
class SGSoundSample;
class SGCondition;
class SGPath;
static const double MAX_TRANSIT_TIME = 0.1; // 100 ms.
/**
* Class for handling one sound event.
*
* This class handles everything for a particular sound event, by
* scanning an a pre-loaded property tree structure for sound
* settings, setting up its internal states, and managing sound
* playback whenever such an event happens.
*/
class SGXmlSound
{
public:
SGXmlSound();
virtual ~SGXmlSound();
/**
* Initialize the sound event.
*
* 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:
* <fx>
* <event_name>
* <name/> Define the name of the event. For reference only.
* <mode/> Either:
* looped: play this sound looped.
* in-transit: play looped while the event is happening.
* once: play this sound once.
* <path/> The relative path to the audio file.
* <property/> Take action if this property becomes true.
* <condition/> Take action if this condition becomes true.
* <delay-sec/> Time after which the sound should be played.
* <volume> or <pitch> Define volume or pitch settings.
* <property/> Take the value of this property as a reference for the
* result.
* <internal/> Either:
* dt_start: the time elapsed since this sound is playing.
* dt_stop: the time elapsed since this sound has stopped.
* <offset/> Add this value to the result.
* <factor/> Multiply the result by this factor.
* <min/> Make sure the value is never less than this value.
* <max/> Make sure the value is never larger than this value.
* </volume> or </pitch>
* </event_name>
*
* <event_name>
* </event_name>
* </fx>
*
* @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 *, SGSampleGroup *,
SGSampleGroup *, const SGPath& currentDir);
/**
* Check whether an event has happened and if action has to be taken.
*/
virtual void update (double dt);
/**
* Stop taking action on the pre-defined events.
*/
void stop();
protected:
enum { MAXPROP=5 };
enum { ONCE=0, LOOPED, IN_TRANSIT };
enum { LEVEL=0, INVERTED, FLIPFLOP };
// SGXmlSound properties
typedef struct {
SGPropertyNode_ptr prop;
double (*fn)(double);
double *intern;
double factor;
double offset;
double min;
double max;
bool subtract;
} _snd_prop;
private:
SGSampleGroup * _sgrp;
SGSharedPtr<SGSoundSample> _sample;
SGSharedPtr<SGCondition> _condition;
SGPropertyNode_ptr _property;
bool _active;
std::string _name;
int _mode;
double _prev_value;
double _dt_play;
double _dt_stop;
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
|