mirror of
https://github.com/ppy/osu.git
synced 2026-05-29 04:49:58 +08:00
update audio quality check to account for ogg files
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using ManagedBass;
|
||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
@@ -9,8 +10,9 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
public class CheckAudioQuality : ICheck
|
||||
{
|
||||
// This is a requirement as stated in the Ranking Criteria.
|
||||
// See https://osu.ppy.sh/wiki/en/Ranking_Criteria#rules.4
|
||||
private const int max_bitrate = 192;
|
||||
// See https://osu.ppy.sh/wiki/en/Ranking_criteria#audio
|
||||
private const int max_bitrate_default = 192;
|
||||
private const int max_bitrate_ogg = 208;
|
||||
|
||||
// "A song's audio file /.../ must be of reasonable quality. Try to find the highest quality source file available"
|
||||
// There not existing a version with a bitrate of 128 kbps or higher is extremely rare.
|
||||
@@ -35,10 +37,17 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
|
||||
if (track?.Bitrate == null || track.Bitrate.Value == 0)
|
||||
yield return new IssueTemplateNoBitrate(this).Create();
|
||||
else if (track.Bitrate.Value > max_bitrate)
|
||||
yield return new IssueTemplateTooHighBitrate(this).Create(track.Bitrate.Value);
|
||||
else if (track.Bitrate.Value < min_bitrate)
|
||||
yield return new IssueTemplateTooLowBitrate(this).Create(track.Bitrate.Value);
|
||||
else
|
||||
{
|
||||
// Determine max bitrate based on audio format
|
||||
var audioFormat = AudioCheckUtils.GetAudioFormatFromFile(context, audioFile);
|
||||
int upperBitrateLimit = audioFormat.HasFlag(ChannelType.OGG) ? max_bitrate_ogg : max_bitrate_default;
|
||||
|
||||
if (track.Bitrate.Value > upperBitrateLimit)
|
||||
yield return new IssueTemplateTooHighBitrate(this).Create(track.Bitrate.Value, upperBitrateLimit);
|
||||
else if (track.Bitrate.Value < min_bitrate)
|
||||
yield return new IssueTemplateTooLowBitrate(this).Create(track.Bitrate.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public class IssueTemplateTooHighBitrate : IssueTemplate
|
||||
@@ -48,7 +57,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
}
|
||||
|
||||
public Issue Create(int bitrate) => new Issue(this, bitrate, max_bitrate);
|
||||
public Issue Create(int bitrate, int maxBitrate) => new Issue(this, bitrate, maxBitrate);
|
||||
}
|
||||
|
||||
public class IssueTemplateTooLowBitrate : IssueTemplate
|
||||
|
||||
Reference in New Issue
Block a user