24# pragma warning( disable: 4355 )
41#include <simgear/debug/logstream.hxx>
42#include <simgear/sound/soundmgr.hxx>
43#include <simgear/sound/sample_group.hxx>
44#include <simgear/structure/exception.hxx>
58#define ADD_VOICE(Var,Sample,Twice) \
59 { make_voice(&Var);append(Var,Sample);\
60 if (Twice) append(Var,Sample); }
62#define test_bits(_bits, _test) (((_bits) & (_test)) != 0)
69: _sample(sample), _volume(volume)
76 if (_sample && (volume > 0.05)) {
set_volume(volume); _sample->play_once(); }
81 if (_sample) _sample->stop();
86 return _sample ? _sample->is_playing() :
false;
91 if (_sample) _sample->set_volume(volume * _volume);
102 tie(node,
"volume", &
volume);
103 tie(node,
"pitch", &pitch);
109 map< string, SGSharedPtr<SGSoundSample> >::iterator iter;
110 for (iter = player->samples.begin(); iter != player->samples.end(); iter++)
112 SGSoundSample *sample = (*iter).second;
114 sample->set_pitch(pitch);
118 player->voice->volume_changed();
123 for (iter = elements.begin(); iter != elements.end(); iter++)
131 iter = elements.begin();
148 iter = elements.end() - 1;
163 element->set_volume(get_volume());
173 if (++iter == elements.end())
187speaker(this,properties_handler)
194 vector<Voice *>::iterator iter1;
204 dir_prefix = node->getStringValue(
"voice/file-prefix", default_dir_prefix);
211 auto smgr =
globals->get_subsystem<SGSoundMgr>();
212 _sgr = smgr->find(
"avionics",
true);
213 _sgr->tie_to_listener();
214 speaker.update_configuration();
248 SGSoundSample *sample =
_sgr->find(refname);
252 sample =
new SGSoundSample(filename.c_str(), SGPath());
254 _sgr->add(sample, refname);
307 voice->volume_changed();
319 if (!
voice->element ||
voice->element->silence)
332 if (!
voice->element)
void update_configuration()
void bind(SGPropertyNode *node)
SampleElement(SGSharedPtr< SGSoundSample > sample, float volume=1.0)
virtual bool is_playing()
virtual void play(float volume)
virtual void set_volume(float volume)
void set_volume(float _volume)
SGSharedPtr< SGSampleGroup > _sgr
void set_volume(float _volume)
void bind(SGPropertyNode *node, const char *default_dir_prefix)
SGSoundSample * get_sample(const char *name)
void append(Voice *voice, Voice::Element *element)
void play(Voice *_voice, unsigned int flags=0)
std::map< std::string, SGSharedPtr< SGSoundSample > > samples
std::vector< Voice * > _voices
FGVoicePlayer(PropertiesHandler *properties_handler, std::string _dev_name)
void stop(unsigned int flags=0)
#define test_bits(_bits, _test)