#define test_bits(_bits, _test) (((_bits) & (_test)) != 0)
+/////////////////////////////////////////////////////////////////////////
+// FGVoicePlayer::Voice::SampleElement ///////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+FGVoicePlayer::Voice::SampleElement::SampleElement (SGSharedPtr<SGSoundSample> sample, float volume)
+: _sample(sample), _volume(volume)
+{
+ silence = false;
+}
+
+void FGVoicePlayer::Voice::SampleElement::play (float volume)
+{
+ if (_sample && (volume > 0.05)) { set_volume(volume); _sample->play_once(); }
+}
+
+void FGVoicePlayer::Voice::SampleElement::stop ()
+{
+ if (_sample) _sample->stop();
+}
+
+bool FGVoicePlayer::Voice::SampleElement::is_playing ()
+{
+ return _sample ? _sample->is_playing() : false;
+}
+
+void FGVoicePlayer::Voice::SampleElement::set_volume (float volume)
+{
+ if (_sample) _sample->set_volume(volume * _volume);
+}
+
///////////////////////////////////////////////////////////////////////////////
// FGVoicePlayer //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
: volume(1.0), voice(NULL), next_voice(NULL), paused(false),
dev_name(_dev_name), dir_prefix(""),
speaker(this,properties_handler)
-{}
+{
+ _sgr = NULL;
+}
FGVoicePlayer::~FGVoicePlayer ()
{
}
}
}
+
+void
+FGVoicePlayer::append (Voice *voice, const char *sample_name)
+{
+ voice->append(new Voice::SampleElement(get_sample(sample_name)));
+}
+