Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nlsdvl committed Mar 22, 2024
1 parent 1ebd310 commit c168459
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Runtime/Scripts/Schema/MpegAudioSpatial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MpegAudioSpatialSource
public float pregain = 0;
public float playbackSpeed = 1;

public string attenuation = "linear_distance";
public string attenuation = "linearDistance";

public float referenceDistance = 1;
public float[]? attenuationParameters;
Expand Down
9 changes: 5 additions & 4 deletions Runtime/Scripts/SpatialAudioSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void Start()

aSrc.dopplerLevel = 0; // doppler results in annoying audio artifacts if improperly configured, 0 disables it.

aSrc.spatialBlend = attenuationType == "no_attenuation" ? 0 : 1;
aSrc.spatialBlend = attenuationType == "noAttenuation" ? 0 : 1;

if (attenuationType == "linear_distance")
if (attenuationType == "linearDistance")
{
aSrc.spatialBlend = 1;
aSrc.rolloffMode = AudioRolloffMode.Linear;
Expand All @@ -57,7 +57,7 @@ void Start()
}
// rooloffFactor is not supported in Unity's builtin RollOff modes
}
else if (attenuationType == "exponential_distance")
else if (attenuationType == "exponentialDistance")
{
aSrc.spatialBlend = 1;
aSrc.rolloffMode = AudioRolloffMode.Logarithmic;
Expand All @@ -71,6 +71,7 @@ void Start()
else
{
Debug.LogWarning("Unsupported audio attenuation mode " + attenuationType);
Debug.LogWarning("Using noAttenuation instead.");
}

if (clip_ != null)
Expand Down Expand Up @@ -116,7 +117,7 @@ public void Configure(MpegAudioSpatialSource srcDef, int bufferId)
{
throw new Exception("HOA audio source currently not implemented");
}
attenuationType = srcDef.attenuation ?? "linear_distance";
attenuationType = srcDef.attenuation ?? "linearDistance";
referenceDistance = srcDef.referenceDistance;
attenuationParams = srcDef.attenuationParameters ?? new float[]{ 100 };
}
Expand Down

0 comments on commit c168459

Please sign in to comment.