Skip to content

Commit

Permalink
Code quality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Oct 16, 2023
1 parent ec42dc4 commit b51f28e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void Read(BitExtractor extractor, bool alternateObjectPresent, int object
if (elementIndex == objectElementIndex) {
ObjectElement(extractor, objectCount, bedOrISFObjects);
} else { // Other elements are unused by encoders
blockOffsetFactor = new short[] { (short)(-1 - elementIndex) };
blockOffsetFactor = new[] { (short)(-1 - elementIndex) };
}
extractor.Position = endPos; // Padding
}
Expand Down
6 changes: 3 additions & 3 deletions Cavern.Format/Renderers/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public float[][] GetNextObjectSamples(int samples) {
/// Set up the renderer for a number of objects.
/// </summary>
protected void SetupObjects(int count) {
for (int obj = 0; obj < count; ++obj) {
for (int obj = 0; obj < count; obj++) {
objects.Add(new StreamMasterSource(reader, obj));
}
FinishSetup(count);
Expand All @@ -89,7 +89,7 @@ protected void SetupObjects(int count) {
/// </summary>
protected void SetupChannels() {
ReferenceChannel[] channels = GetChannels();
for (int channel = 0; channel < channels.Length; ++channel) {
for (int channel = 0; channel < channels.Length; channel++) {
int referenceIndex = (int)channels[channel];
Source source = new StreamMasterSource(reader, channel) {
Position = ChannelPrototype.AlternativePositions[referenceIndex] * Listener.EnvironmentSize,
Expand All @@ -104,7 +104,7 @@ protected void SetupChannels() {
/// Finishing steps of creating a layout.
/// </summary>
protected void FinishSetup(int count) {
for (int obj = 0; obj < count; ++obj) {
for (int obj = 0; obj < count; obj++) {
objects[obj].VolumeRolloff = Rolloffs.Disabled;
}
reader.SetupSources(objects, stream.SampleRate);
Expand Down
2 changes: 1 addition & 1 deletion Cavern.Format/Renderers/RendererConsts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract partial class Renderer {
/// </summary>
/// <remarks>Internal Cavern channel positions are not the same.</remarks>
public static ReferenceChannel ChannelFromPosition(Vector3 position) {
for (int i = 0; i < ChannelPrototype.AlternativePositions.Length; ++i) {
for (int i = 0; i < ChannelPrototype.AlternativePositions.Length; i++) {
if (position == ChannelPrototype.AlternativePositions[i]) {
return (ReferenceChannel)i;
}
Expand Down
8 changes: 4 additions & 4 deletions Cavern.QuickEQ/Graphing/GraphRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ public float GetFrequencyAt(float width) {
/// Set the <see cref="peak"/> to the max displayed gain.
/// </summary>
public void Normalize() {
double peak = float.NegativeInfinity;
double curvePeak = float.NegativeInfinity;
for (int i = 0, c = curves.Count; i < c; i++) {
IReadOnlyList<Band> curve = curves[i].Curve.Bands;
for (int f = 0, c2 = curve.Count; f < c2; f++) {
if (peak < curve[f].Gain) {
peak = curve[f].Gain;
if (curvePeak < curve[f].Gain) {
curvePeak = curve[f].Gain;
}
}
}
Peak = (float)peak;
Peak = (float)curvePeak;
ReRenderFull();
}

Expand Down
6 changes: 3 additions & 3 deletions Cavern.QuickEQ/VerboseImpulseResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ public Peak(int position, float size) {
/// Get the delay of an impulse response in samples. In this case, delay means the index of the highest absolute value sample.
/// </summary>
public static int GetDelay(float[] response) {
int delay = 0;
int result = 0;
float absPeak = float.NegativeInfinity, absHere;
for (int pos = 0; pos < response.Length; ++pos) {
absHere = Math.Abs(response[pos]);
if (absPeak < absHere) {
absPeak = absHere;
delay = pos;
result = pos;
}
}
return delay;
return result;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Test.Cavern.QuickEQ/Consts/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <summary>
/// Common utilities used in testing like assertions.
/// </summary>
internal class TestUtils {
internal static class TestUtils {
/// <summary>
/// Test if an <paramref name="array"/> between the given limits is strictly monotonously decreasing,
/// but allowing an error margin of <paramref name="epsilon"/>.
Expand Down

0 comments on commit b51f28e

Please sign in to comment.