Skip to content

Commit

Permalink
0.0.1-preview.3 - 2019/03/15
Browse files Browse the repository at this point in the history
@2019.1
  • Loading branch information
ErikMoczi committed Mar 19, 2019
1 parent 4490197 commit a334dde
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 18 deletions.
5 changes: 5 additions & 0 deletions package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.0.1-preview.3] - 2019-03-15
- Fixed issues on XBox
- Fixed music layering system not recovering position properly from LocalToWorld
- Fixed vehicle fade out time being determined from relative and not absolute speed

## [0.0.1-preview.2] - 2019-03-14
- Added support for reinitialization of manager objects and ECS systems.

Expand Down
9 changes: 5 additions & 4 deletions package/Runtime/Components/VehicleSoundControllerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,14 @@ internal void OnUpdate(VehicleSoundController ctl, AudioManagerSystem audioManag
{
m_Speed = 1;
}

// turn down the volume when the car is moving forward at max speed;
// otherwise fade to full folume -- that's when volume is less than max, or the angles are non-zero
if (m_MasterVolumeTarget != 1
&& (math.abs(m_Speed - 1) > 0.1
|| math.abs(m_YawAngle) > 0.2
|| math.abs(m_PitchAngle) > 0.2
|| math.abs(m_RollAngle) > 0.2
&& (math.abs(prev - m_Speed) > 0.0017
|| math.abs(m_YawAngle) > 0.4
|| math.abs(m_PitchAngle) > 0.4
|| math.abs(m_RollAngle) > 0.4
)
)
{
Expand Down
44 changes: 44 additions & 0 deletions package/Runtime/DSP/StereoTo7Point1Node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Unity.Burst;
using Unity.Experimental.Audio;

namespace Unity.Audio.Megacity
{
[BurstCompile]
struct StereoTo7Point1NodeJob : IAudioJob<StereoTo7Point1NodeJob.Params, NoProvs>
{
public enum Params
{
}

public void Init(ParameterData<StereoTo7Point1NodeJob.Params> parameters)
{
}

public void Execute(ref ExecuteContext<StereoTo7Point1NodeJob.Params, NoProvs> ctx)
{
var inputBuffer = ctx.Inputs.GetSampleBuffer(0);
var outputBuffer = ctx.Outputs.GetSampleBuffer(0);

var numChannels = outputBuffer.Channels;
var sampleFrames = outputBuffer.Samples;

var src = inputBuffer.Buffer;
var dst = outputBuffer.Buffer;

int srcOffset = 0;
int dstOffset = 0;

for (uint n = 0; n < sampleFrames; n++)
{
dst[dstOffset++] = src[srcOffset++];
dst[dstOffset++] = src[srcOffset++];
dst[dstOffset++] = 0.0f;
dst[dstOffset++] = 0.0f;
dst[dstOffset++] = 0.0f;
dst[dstOffset++] = 0.0f;
dst[dstOffset++] = 0.0f;
dst[dstOffset++] = 0.0f;
}
}
}
}
11 changes: 11 additions & 0 deletions package/Runtime/DSP/StereoTo7Point1Node.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions package/Runtime/Systems/AudioManagerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ internal DSPCommandBlockInterceptor FrameBlock
{
get
{
if(!m_BlocksAlive)
if (!m_BlocksAlive)
throw new InvalidOperationException("Audio manager frame blocks not available at this time");

return m_Block;
}
}

DSPConnection m_ConverterConnection;
DSPNode m_ConverterNode;
DSPConnection m_MasterConnection;
DSPNode m_MasterGainNode;
DSPNode m_LimiterNode;
Expand All @@ -86,7 +88,19 @@ protected override void OnCreateManager()
m_Block.AddOutletPort(m_MasterGainNode, 2, SoundFormat.Stereo);
m_Block.SetFloat<GainNodeJob.Params, NoProvs, GainNodeJob>(m_MasterGainNode, GainNodeJob.Params.Vol1, 0, 0);
m_Block.SetFloat<GainNodeJob.Params, NoProvs, GainNodeJob>(m_MasterGainNode, GainNodeJob.Params.Vol2, 0, 0);
m_MasterConnection = m_Block.Connect(m_MasterGainNode, 0, WorldGraph.GetRootDSP(), 0);

if (Application.platform == RuntimePlatform.XboxOne)
{
m_ConverterNode = m_Block.CreateDSPNode<StereoTo7Point1NodeJob.Params, NoProvs, StereoTo7Point1NodeJob>();
m_Block.AddInletPort(m_ConverterNode, 2, SoundFormat.Stereo);
m_Block.AddOutletPort(m_ConverterNode, 8, SoundFormat.SevenDot1);
m_ConverterConnection = m_Block.Connect(m_MasterGainNode, 0, m_ConverterNode, 0);
m_MasterConnection = m_Block.Connect(m_ConverterNode, 0, WorldGraph.GetRootDSP(), 0);
}
else
{
m_MasterConnection = m_Block.Connect(m_MasterGainNode, 0, WorldGraph.GetRootDSP(), 0);
}

m_LimiterNode = m_Block.CreateDSPNode<LimiterNodeJob.Params, LimiterNodeJob.Provs, LimiterNodeJob>();
m_Block.AddInletPort(m_LimiterNode, 2, SoundFormat.Stereo);
Expand Down Expand Up @@ -114,8 +128,13 @@ internal void SwapBuffers()

protected override void OnDestroyManager()
{
if(m_BlocksAlive)
if (m_BlocksAlive)
{
if (Application.platform == RuntimePlatform.XboxOne)
{
m_Block.ReleaseDSPNode(m_ConverterNode);
}

m_Block.ReleaseDSPNode(m_MasterGainNode);
m_Block.ReleaseDSPNode(m_LimiterNode);
m_Block.Complete();
Expand Down Expand Up @@ -159,11 +178,11 @@ internal void UpdateParameters(uint lerpLength = 1024)
}
}

public void SetActive (bool value)
public void SetActive(bool value)
{
var volume = value ? 1 : 0;
m_Block.SetFloat<GainNodeJob.Params, NoProvs, GainNodeJob>(m_MasterGainNode, GainNodeJob.Params.Vol1, volume, 5*44100);
m_Block.SetFloat<GainNodeJob.Params, NoProvs, GainNodeJob>(m_MasterGainNode, GainNodeJob.Params.Vol2, volume, 5*44100);
m_Block.SetFloat<GainNodeJob.Params, NoProvs, GainNodeJob>(m_MasterGainNode, GainNodeJob.Params.Vol1, volume, 5 * 44100);
m_Block.SetFloat<GainNodeJob.Params, NoProvs, GainNodeJob>(m_MasterGainNode, GainNodeJob.Params.Vol2, volume, 5 * 44100);
}
}

Expand Down
14 changes: 7 additions & 7 deletions package/Runtime/Systems/BoxTriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct TriggerJob : IJobChunk
public ChunkEntityEnumerable m_BoundingBoxEnumerable;

[ReadOnly]
public ComponentDataFromEntity<Translation> m_PointPosition;
public ComponentDataFromEntity<LocalToWorld> m_PointPosition;

[ReadOnly]
public ComponentDataFromEntity<BoxIndex> m_PointBoxIndex;
Expand All @@ -45,7 +45,7 @@ public struct TriggerJob : IJobChunk
public ArchetypeChunkEntityType m_PointEntityType;

[ReadOnly]
public ArchetypeChunkComponentType<Translation> m_PositionType;
public ArchetypeChunkComponentType<LocalToWorld> m_PositionType;

[ReadOnly]
public ArchetypeChunkComponentType<BoxIndex> m_BoxIndexType;
Expand All @@ -55,13 +55,13 @@ public struct TriggerJob : IJobChunk
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var pointEntities = chunk.GetNativeArray(m_PointEntityType);
var positionComponents = chunk.GetNativeArray<Translation>(m_PositionType);
var positionComponents = chunk.GetNativeArray<LocalToWorld>(m_PositionType);
var boxIndexComponents = chunk.GetNativeArray<BoxIndex>(m_BoxIndexType);

for (int p = 0; p < pointEntities.Length; p++)
{
var pointEntity = pointEntities[p];
var position = positionComponents[p].Value;
var position = math.transform(positionComponents[p].Value, new float3());

Entity newBoundingBox = Entity.Null;
foreach (var boundingBoxEntity in m_BoundingBoxEnumerable)
Expand Down Expand Up @@ -103,11 +103,11 @@ protected override JobHandle OnUpdate(JobHandle inputDeps)
var job = new TriggerJob
{
m_BoundingBoxEnumerable = m_BoundingBoxEnumerable,
m_PointPosition = GetComponentDataFromEntity<Translation>(),
m_PointPosition = GetComponentDataFromEntity<LocalToWorld>(),
m_PointBoxIndex = GetComponentDataFromEntity<BoxIndex>(),
m_BoundingBoxes = GetComponentDataFromEntity<BoundingBox>(),
m_PointEntityType = GetArchetypeChunkEntityType(),
m_PositionType = GetArchetypeChunkComponentType<Translation>(true),
m_PositionType = GetArchetypeChunkComponentType<LocalToWorld>(true),
m_BoxIndexType = GetArchetypeChunkComponentType<BoxIndex>(),
m_EntityCommandBuffer = m_Barrier.CreateCommandBuffer().ToConcurrent()
};
Expand All @@ -134,7 +134,7 @@ protected override void OnCreateManager()
m_PointGroup = GetComponentGroup(
new EntityArchetypeQuery
{
All = new ComponentType[] { typeof(Translation), typeof(BoxIndex) },
All = new ComponentType[] { typeof(LocalToWorld), typeof(BoxIndex) },
None = Array.Empty<ComponentType>(),
Any = Array.Empty<ComponentType>(),
});
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.unity.audio.megacityprototype",
"version": "0.0.1-preview.2",
"version": "0.0.1-preview.3",
"unity": "2019.1",
"description": "This package contains the prototype audio system for the megacity sample project. The contents of this package should not be considered as part of the standard audio system feature set of unity, as it was a prototype created for the megacity sample, that will serve as inspiration for audio features going forward.",
"displayName": "Megacity Audio System",
Expand Down
1 change: 1 addition & 0 deletions versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0.0.1-preview.1
0.0.1-preview.2
0.0.1-preview.3

0 comments on commit a334dde

Please sign in to comment.