Skip to content

Commit

Permalink
Per-subframe E-AC-3 rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Nov 25, 2024
1 parent 3560d71 commit 89680f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
7 changes: 4 additions & 3 deletions Cavern.Format/Decoders/EnhancedAC3/ObjectAudioMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

using Cavern.Channels;
using Cavern.Format.Common;
Expand All @@ -22,13 +23,13 @@ partial class ObjectAudioMetadata {
/// <summary>
/// Decoded object audio element metadata.
/// </summary>
OAElementMD[] elements = new OAElementMD[0];
OAElementMD[] elements = Array.Empty<OAElementMD>();

/// <summary>
/// Bed channels used. The first dimension is the element ID, the second is one bit for each channel,
/// in the order of <see cref="bedChannels"/>.
/// </summary>
bool[][] bedAssignment;
bool[][] bedAssignment = Array.Empty<bool[]>();

/// <summary>
/// Use intermediate spatial format (ISF), which has a few fixed layouts.
Expand Down
11 changes: 4 additions & 7 deletions Cavern.Format/Renderers/EnhancedAC3Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public EnhancedAC3Renderer(EnhancedAC3Decoder stream) : base(stream) {
else {
for (int channel = 0; channel < outputMatrix.Length; channel++) {
Source source = new StreamMasterSource(reader, channel) {
LFE = inputMatrix[channel] == ReferenceChannel.ScreenLFE,
Position = ChannelPrototype.AlternativePositions[(int)outputMatrix[channel]] * Listener.EnvironmentSize
};
objects.Add(source);
Expand Down Expand Up @@ -209,15 +210,11 @@ void RenderNextTimeslot() {
}
// Channel-based rendering or fallback to it when OAMD or JOC can't be decoded correctly
else {
for (int i = 0; i < outputMatrix.Length; i++) {
for (int i = 0; i < inputMatrix.Length; i++) {
objects[i].Position = ChannelPrototype.AlternativePositions[(int)inputMatrix[i]] * Listener.EnvironmentSize;
timeslotResult[i] = inputData[i];
objects[i].Position = ChannelPrototype.AlternativePositions[(int)outputMatrix[i]] * Listener.EnvironmentSize;
if (ChannelPrototype.Mapping[(int)outputMatrix[i]].LFE) { // LFE is handled elsewhere
objects[i].Position = default;
timeslotResult[i].Clear();
}
}
for (int i = outputMatrix.Length; i < timeslotResult.Length; i++) {
for (int i = inputMatrix.Length; i < timeslotResult.Length; i++) {
objects[i].Position = default;
timeslotResult[i].Clear();
}
Expand Down

0 comments on commit 89680f7

Please sign in to comment.