Merge pull request #26868 from NilsIrl/master
Add Attenuation Model "NO" for AudioStreamPlayer3D
This commit is contained in:
commit
886afa9b76
|
@ -60,7 +60,7 @@
|
||||||
Amount how much the filter affects the loudness, in dB.
|
Amount how much the filter affects the loudness, in dB.
|
||||||
</member>
|
</member>
|
||||||
<member name="attenuation_model" type="int" setter="set_attenuation_model" getter="get_attenuation_model" enum="AudioStreamPlayer3D.AttenuationModel">
|
<member name="attenuation_model" type="int" setter="set_attenuation_model" getter="get_attenuation_model" enum="AudioStreamPlayer3D.AttenuationModel">
|
||||||
Decides if audio should get quieter with distance linearly, quadratically or logarithmically.
|
Decides if audio should get quieter with distance linearly, quadratically, logarithmically, or not be affected by distance, effectively disabling attenuation.
|
||||||
</member>
|
</member>
|
||||||
<member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled">
|
<member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled">
|
||||||
If [code]true[/code], audio plays when added to scene tree. Default value: [code]false[/code].
|
If [code]true[/code], audio plays when added to scene tree. Default value: [code]false[/code].
|
||||||
|
@ -124,6 +124,9 @@
|
||||||
<constant name="ATTENUATION_LOGARITHMIC" value="2" enum="AttenuationModel">
|
<constant name="ATTENUATION_LOGARITHMIC" value="2" enum="AttenuationModel">
|
||||||
Logarithmic dampening of loudness according to distance.
|
Logarithmic dampening of loudness according to distance.
|
||||||
</constant>
|
</constant>
|
||||||
|
<constant name="ATTENUATION_DISABLED" value="3" enum="AttenuationModel">
|
||||||
|
No dampening of loudness according to distance.
|
||||||
|
</constant>
|
||||||
<constant name="OUT_OF_RANGE_MIX" value="0" enum="OutOfRangeMode">
|
<constant name="OUT_OF_RANGE_MIX" value="0" enum="OutOfRangeMode">
|
||||||
Mix this audio in, even when it's out of range.
|
Mix this audio in, even when it's out of range.
|
||||||
</constant>
|
</constant>
|
||||||
|
|
|
@ -224,6 +224,7 @@ float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
|
||||||
case ATTENUATION_LOGARITHMIC: {
|
case ATTENUATION_LOGARITHMIC: {
|
||||||
att = -20 * Math::log(p_distance / unit_size + CMP_EPSILON);
|
att = -20 * Math::log(p_distance / unit_size + CMP_EPSILON);
|
||||||
} break;
|
} break;
|
||||||
|
case ATTENUATION_DISABLED: break;
|
||||||
default: {
|
default: {
|
||||||
ERR_PRINT("Unknown attenuation type");
|
ERR_PRINT("Unknown attenuation type");
|
||||||
break;
|
break;
|
||||||
|
@ -831,7 +832,7 @@ float AudioStreamPlayer3D::get_attenuation_filter_db() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlayer3D::set_attenuation_model(AttenuationModel p_model) {
|
void AudioStreamPlayer3D::set_attenuation_model(AttenuationModel p_model) {
|
||||||
ERR_FAIL_INDEX(p_model, 3);
|
ERR_FAIL_INDEX((int)p_model, 4);
|
||||||
attenuation_model = p_model;
|
attenuation_model = p_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,7 +963,7 @@ void AudioStreamPlayer3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_bus_layout_changed"), &AudioStreamPlayer3D::_bus_layout_changed);
|
ClassDB::bind_method(D_METHOD("_bus_layout_changed"), &AudioStreamPlayer3D::_bus_layout_changed);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "attenuation_model", PROPERTY_HINT_ENUM, "Inverse,InverseSquare,Log"), "set_attenuation_model", "get_attenuation_model");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "attenuation_model", PROPERTY_HINT_ENUM, "Inverse,InverseSquare,Log,Disabled"), "set_attenuation_model", "get_attenuation_model");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db");
|
||||||
|
@ -987,6 +988,7 @@ void AudioStreamPlayer3D::_bind_methods() {
|
||||||
BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_DISTANCE);
|
BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_DISTANCE);
|
||||||
BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_SQUARE_DISTANCE);
|
BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_SQUARE_DISTANCE);
|
||||||
BIND_ENUM_CONSTANT(ATTENUATION_LOGARITHMIC);
|
BIND_ENUM_CONSTANT(ATTENUATION_LOGARITHMIC);
|
||||||
|
BIND_ENUM_CONSTANT(ATTENUATION_DISABLED);
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(OUT_OF_RANGE_MIX);
|
BIND_ENUM_CONSTANT(OUT_OF_RANGE_MIX);
|
||||||
BIND_ENUM_CONSTANT(OUT_OF_RANGE_PAUSE);
|
BIND_ENUM_CONSTANT(OUT_OF_RANGE_PAUSE);
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
ATTENUATION_INVERSE_DISTANCE,
|
ATTENUATION_INVERSE_DISTANCE,
|
||||||
ATTENUATION_INVERSE_SQUARE_DISTANCE,
|
ATTENUATION_INVERSE_SQUARE_DISTANCE,
|
||||||
ATTENUATION_LOGARITHMIC,
|
ATTENUATION_LOGARITHMIC,
|
||||||
|
ATTENUATION_DISABLED,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OutOfRangeMode {
|
enum OutOfRangeMode {
|
||||||
|
|
Loading…
Reference in New Issue