mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Add control to the sound attenuation by distance.
This commit is contained in:
@@ -26,7 +26,7 @@ namespace audio
|
||||
{
|
||||
namespace null
|
||||
{
|
||||
Audio::Audio()
|
||||
Audio::Audio() : distanceModel(DISTANCE_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -151,6 +151,16 @@ namespace null
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Audio::DistanceModel Audio::getDistanceModel() const
|
||||
{
|
||||
return this->distanceModel;
|
||||
}
|
||||
|
||||
void Audio::setDistanceModel(DistanceModel distanceModel)
|
||||
{
|
||||
this->distanceModel = distanceModel;
|
||||
}
|
||||
|
||||
} // null
|
||||
} // audio
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace null
|
||||
{
|
||||
private:
|
||||
float volume;
|
||||
DistanceModel distanceModel;
|
||||
public:
|
||||
|
||||
Audio();
|
||||
@@ -74,6 +75,9 @@ namespace null
|
||||
love::sound::SoundData * stopRecording(bool returnData);
|
||||
bool canRecord();
|
||||
|
||||
DistanceModel getDistanceModel() const;
|
||||
void setDistanceModel(DistanceModel distanceModel);
|
||||
|
||||
}; // Audio
|
||||
|
||||
} // null
|
||||
|
||||
@@ -149,6 +149,56 @@ namespace null
|
||||
{
|
||||
return (type == TYPE_STATIC);
|
||||
}
|
||||
|
||||
void Source::setMinVolume(float volume)
|
||||
{
|
||||
this->minVolume = volume;
|
||||
}
|
||||
|
||||
float Source::getMinVolume() const
|
||||
{
|
||||
return this->minVolume;
|
||||
}
|
||||
|
||||
void Source::setMaxVolume(float volume)
|
||||
{
|
||||
this->maxVolume = volume;
|
||||
}
|
||||
|
||||
float Source::getMaxVolume() const
|
||||
{
|
||||
return this->maxVolume;
|
||||
}
|
||||
|
||||
void Source::setReferenceDistance(float distance)
|
||||
{
|
||||
this->referenceDistance = distance;
|
||||
}
|
||||
|
||||
float Source::getReferenceDistance() const
|
||||
{
|
||||
return this->referenceDistance;
|
||||
}
|
||||
|
||||
void Source::setRolloffFactor(float factor)
|
||||
{
|
||||
this->rolloffFactor = factor;
|
||||
}
|
||||
|
||||
float Source::getRolloffFactor() const
|
||||
{
|
||||
return this->rolloffFactor;
|
||||
}
|
||||
|
||||
void Source::setMaxDistance(float distance)
|
||||
{
|
||||
this->maxDistance = distance;
|
||||
}
|
||||
|
||||
float Source::getMaxDistance() const
|
||||
{
|
||||
return this->maxDistance;
|
||||
}
|
||||
|
||||
} // null
|
||||
} // audio
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace null
|
||||
float pitch;
|
||||
float volume;
|
||||
bool looping;
|
||||
float minVolume;
|
||||
float maxVolume;
|
||||
float referenceDistance;
|
||||
float rolloffFactor;
|
||||
float maxDistance;
|
||||
|
||||
public:
|
||||
Source();
|
||||
@@ -68,6 +73,16 @@ namespace null
|
||||
void setLooping(bool looping);
|
||||
bool isLooping() const;
|
||||
bool isStatic() const;
|
||||
virtual void setMinVolume(float volume);
|
||||
virtual float getMinVolume() const;
|
||||
virtual void setMaxVolume(float volume);
|
||||
virtual float getMaxVolume() const;
|
||||
virtual void setReferenceDistance(float distance);
|
||||
virtual float getReferenceDistance() const;
|
||||
virtual void setRolloffFactor(float factor);
|
||||
virtual float getRolloffFactor() const;
|
||||
virtual void setMaxDistance(float distance);
|
||||
virtual float getMaxDistance() const;
|
||||
|
||||
}; // Source
|
||||
|
||||
|
||||
Reference in New Issue
Block a user