Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't change the playback pitch along the playback speed #29629

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

normalid-awa
Copy link
Contributor

@normalid-awa normalid-awa commented Aug 28, 2024

Solved: #29596

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

@normalid-awa normalid-awa changed the title Implement the feature Add an option to toggle whether the playback pitch change along the playback speed Aug 28, 2024
@normalid-awa normalid-awa marked this pull request as ready for review August 28, 2024 14:25
@smoogipoo
Copy link
Contributor

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.

@normalid-awa normalid-awa marked this pull request as draft August 29, 2024 04:55
@normalid-awa normalid-awa force-pushed the feature/replay/toggle-playback-speed-pitch branch from 31002d8 to d49cd71 Compare August 29, 2024 04:55
@normalid-awa normalid-awa changed the title Add an option to toggle whether the playback pitch change along the playback speed Don't change the playback pitch along the playback speed Aug 29, 2024
@normalid-awa normalid-awa reopened this Aug 29, 2024
@normalid-awa normalid-awa marked this pull request as ready for review August 29, 2024 05:01
@smoogipoo
Copy link
Contributor

smoogipoo commented Aug 29, 2024

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.

@normalid-awa
Copy link
Contributor Author

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,
        };


@bdach
Copy link
Collaborator

bdach commented Aug 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants