Add an option to toggle whether the playback pitch change along the playback speed
Solved: #29596
How
Add an option to allows player to toggle whether the playback pitch adjusted along the playback speed
Drawback
The minimum playback speed is limited to 0.1x(rather than 0.05). This is because of the BASS library doesn't support the tempo that's equal to or less than 0.5
Demo
https://github.com/user-attachments/assets/59d973db-d0a2-44cf-812f-2666f0ca1e1b
Please no more options... It's okay for the game to be opinionated, we don't need to cater to every user's personal preference.
Looks like HT(0.5) + 0.1 playback speed crashes the game with:
[runtime] 2024-08-29 06:53:15 [error]: System.ArgumentException: TrackBass does not support Tempo specifications below 0.05. Use Frequency instead.
[runtime] 2024-08-29 06:53:15 [error]: at osu.Framework.Audio.Track.TrackBass.<>c.<.ctor>b__18_0(ValueChangedEvent`1 t)
Given these two particular values, it's likely a rounding issue. However it's an issue that this can happen in any case.
If we do want this PR, then it will also need a framework change to clamp the aggregate tempo. Perhaps a simple fix is:
diff --git a/osu.Framework/Audio/AudioAdjustments.cs b/osu.Framework/Audio/AudioAdjustments.cs
index c7bca336b2..b5c59a2e84 100644
--- a/osu.Framework/Audio/AudioAdjustments.cs
+++ b/osu.Framework/Audio/AudioAdjustments.cs
@@ -140,11 +140,14 @@ private BindableNumber<double> getProperty(AdjustableProperty type)
{
switch (type)
{
- default:
- return (a, b) => a * b;
+ case AdjustableProperty.Tempo:
+ return (a, b) => Math.Clamp(a * b, 0.051, 49.9);
case AdjustableProperty.Balance:
return (a, b) => a + b;
+
+ default:
+ return (a, b) => a * b;
}
}
}
There is a comment at the crashsite suggesting that we should somehow support tempo < 0.05, but I don't know if this is sane to do.
Looks like HT(0.5) + 0.1 playback speed crashes the game with:
[runtime] 2024-08-29 06:53:15 [error]: System.ArgumentException: TrackBass does not support Tempo specifications below 0.05. Use Frequency instead. [runtime] 2024-08-29 06:53:15 [error]: at osu.Framework.Audio.Track.TrackBass.<>c.<.ctor>b__18_0(ValueChangedEvent`1 t)Given these two particular values, it's likely a rounding issue. However it's an issue that this can happen in any case.
If we do want this PR, then it will also need a framework change to clamp the aggregate tempo. Perhaps a simple fix is:
diff --git a/osu.Framework/Audio/AudioAdjustments.cs b/osu.Framework/Audio/AudioAdjustments.cs index c7bca336b2..b5c59a2e84 100644 --- a/osu.Framework/Audio/AudioAdjustments.cs +++ b/osu.Framework/Audio/AudioAdjustments.cs @@ -140,11 +140,14 @@ private BindableNumber<double> getProperty(AdjustableProperty type) { switch (type) { - default: - return (a, b) => a * b; + case AdjustableProperty.Tempo: + return (a, b) => Math.Clamp(a * b, 0.051, 49.9); case AdjustableProperty.Balance: return (a, b) => a + b; + + default: + return (a, b) => a * b; } } }There is a comment at the crashsite suggesting that we should somehow support tempo < 0.05, but I don't know if this is sane to do.
Would it be better to just clamp the tempo bindable minValue (framework side)? like so:
/// <summary>
/// Rate at which the component is played back (does not affect pitch). 1 is 100% playback speed.
/// </summary>
public BindableNumber<double> Tempo { get; } = new BindableDouble(1)
{
MinValue = 0.51,
Default = 1,
};
No it would not be better. Whatever you're trying to do there does not look sane.
The tempo on a singular component should not be clamped. The aggregate tempo should be.