1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

style: convert to using declaration for less nesting

This commit is contained in:
tsrk 2023-09-01 20:54:02 +02:00
parent 5ecd5142d8
commit 5f00d3e2a4
No known key found for this signature in database
GPG Key ID: EBD46BB3049B56D6

View File

@ -52,55 +52,54 @@ namespace osu.Game.Rulesets.Edit.Checks
if (!isHitSound(file.Filename))
continue;
using (Waveform waveform = new Waveform(stream))
using Waveform waveform = new Waveform(stream);
var points = waveform.GetPoints();
// Skip muted samples
if (points.Length == 0 || points.Sum(getAverageAmplitude) <= silence_threshold)
continue;
float maxAmplitude = points.Select(getAverageAmplitude).Max();
int consequentDelay = 0;
int delay = 0;
float amplitude = 0;
while (delay + consequentDelay < points.Length)
{
var points = waveform.GetPoints();
amplitude += getAverageAmplitude(points[delay]);
// Skip muted samples
if (points.Length == 0 || points.Sum(getAverageAmplitude) <= silence_threshold)
continue;
// Reached peak amplitude/transient
if (amplitude >= maxAmplitude)
break;
float maxAmplitude = points.Select(getAverageAmplitude).Max();
amplitude *= falloff_factor;
int consequentDelay = 0;
int delay = 0;
float amplitude = 0;
while (delay + consequentDelay < points.Length)
if (amplitude < silence_threshold)
{
amplitude += getAverageAmplitude(points[delay]);
// Reached peak amplitude/transient
if (amplitude >= maxAmplitude)
break;
amplitude *= falloff_factor;
if (amplitude < silence_threshold)
{
amplitude = 0;
consequentDelay++;
}
delay++;
amplitude = 0;
consequentDelay++;
}
if (consequentDelay >= delay_threshold)
yield return new IssueTemplateConsequentDelay(this).Create(file.Filename, consequentDelay);
else if (consequentDelay + delay >= delay_threshold)
{
if (consequentDelay > 0)
yield return new IssueTemplateDelay(this).Create(file.Filename, consequentDelay, delay);
else
yield return new IssueTemplateDelayNoSilence(this).Create(file.Filename, delay);
}
else if (consequentDelay + delay >= delay_threshold_negligible)
{
if (consequentDelay > 0)
yield return new IssueTemplateMinorDelay(this).Create(file.Filename, consequentDelay, delay);
else
yield return new IssueTemplateMinorDelayNoSilence(this).Create(file.Filename, delay);
}
delay++;
}
if (consequentDelay >= delay_threshold)
yield return new IssueTemplateConsequentDelay(this).Create(file.Filename, consequentDelay);
else if (consequentDelay + delay >= delay_threshold)
{
if (consequentDelay > 0)
yield return new IssueTemplateDelay(this).Create(file.Filename, consequentDelay, delay);
else
yield return new IssueTemplateDelayNoSilence(this).Create(file.Filename, delay);
}
else if (consequentDelay + delay >= delay_threshold_negligible)
{
if (consequentDelay > 0)
yield return new IssueTemplateMinorDelay(this).Create(file.Filename, consequentDelay, delay);
else
yield return new IssueTemplateMinorDelayNoSilence(this).Create(file.Filename, delay);
}
}
}