Add advances sound parameters
This commit is contained in:
parent
098c8ddf4a
commit
998766b004
@ -50,6 +50,18 @@ std::shared_ptr<const audio::Sound> audio::Sound::LoadFromFile(const std::string
|
||||
{
|
||||
iss >> sound->pitch_;
|
||||
}
|
||||
else if (cmd == "refdistance")
|
||||
{
|
||||
iss >> sound->ref_distance_;
|
||||
}
|
||||
else if (cmd == "rolloff")
|
||||
{
|
||||
iss >> sound->rolloff_ractor_;
|
||||
}
|
||||
else if (cmd == "maxdistance")
|
||||
{
|
||||
iss >> sound->max_distance_;
|
||||
}
|
||||
});
|
||||
|
||||
if (sound->category_name_.empty())
|
||||
|
||||
@ -20,6 +20,10 @@ public:
|
||||
float GetVolume() const { return volume_; }
|
||||
float GetPitch() const { return pitch_; }
|
||||
|
||||
float GetRefDistance() const { return ref_distance_; }
|
||||
float GetRolloffFactor() const { return rolloff_ractor_; }
|
||||
float GetMaxDistance() const { return max_distance_; }
|
||||
|
||||
~Sound();
|
||||
|
||||
private:
|
||||
@ -29,6 +33,10 @@ private:
|
||||
|
||||
float volume_ = 1.0f;
|
||||
float pitch_ = 1.0f;
|
||||
|
||||
float ref_distance_ = 1.0f;
|
||||
float rolloff_ractor_= 1.0f;
|
||||
float max_distance_ = 200.0f;
|
||||
};
|
||||
|
||||
} // namespace audio
|
||||
@ -12,6 +12,11 @@ audio::SoundSource::SoundSource(Player* player, std::shared_ptr<const Sound> sou
|
||||
SetPitch(1.0f);
|
||||
|
||||
alSourcei(source_, AL_BUFFER, sound_->GetBufferId());
|
||||
|
||||
// params
|
||||
alSourcef(source_, AL_REFERENCE_DISTANCE, sound_->GetRefDistance());
|
||||
alSourcef(source_, AL_ROLLOFF_FACTOR, sound_->GetRolloffFactor());
|
||||
alSourcef(source_, AL_MAX_DISTANCE, sound_->GetMaxDistance());
|
||||
}
|
||||
|
||||
void audio::SoundSource::SetLooping(bool looping)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user