Skip to content

Commit

Permalink
Code quality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Aug 6, 2024
1 parent 4bd1d2b commit 230fb9d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions CavernUnity DLL/QuickEQ/SpeakerSweeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,26 @@ public void RegenerateSweep() {
Measurements.OffbandGain(sweepFFTlow, StartFreq, EndFreqLFE, sampleRate, 100);
}

/// <summary>
/// Get if any channel was clipping while measuring.
/// </summary>
/// <remarks>This function is using <see cref="Parallelizer.For(int, int, Action{int})"/> and might overload the
/// thread pool. Use <see cref="GetClippingChannels(bool)"/> with its parameter set to false to perform the operation
/// on a single thread.</remarks>
public bool[] GetClippingChannels() => GetClippingChannels(true);

/// <summary>
/// Get if any channel was clipping while measuring.
/// </summary>
/// <returns>For each channel if it was clipping.</returns>
public bool[] GetClippingChannels(bool parallel = true) {
public bool[] GetClippingChannels(bool parallel) {
bool[] result = new bool[ExcitementResponses.Length];
if (parallel) {
Parallelizer.For(0, result.Length, i => result[i] = WaveformUtils.GetPeakSigned(ExcitementResponses[i]) >= 1);
} else for (int i = 0; i < result.Length; i++) {
result[i] = WaveformUtils.GetPeakSigned(ExcitementResponses[i]) >= 1;
} else {
for (int i = 0; i < result.Length; i++) {
result[i] = WaveformUtils.GetPeakSigned(ExcitementResponses[i]) >= 1;
}
}
return result;
}
Expand Down

0 comments on commit 230fb9d

Please sign in to comment.