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

Fix wrong bytes per sample in TrackBass #6039

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

hwsmm
Copy link
Contributor

@hwsmm hwsmm commented Oct 30, 2023

BASS uses 16-bit samples by default if neither BassFlags.Byte nor BassFlags.Float is specified. (https://www.un4seen.com/doc/#bass/BASS_StreamCreate.html)

You can find this out by applying the following diff:

--- a/osu.Framework/Audio/Track/TrackBass.cs
+++ b/osu.Framework/Audio/Track/TrackBass.cs
@@ -15,6 +15,7 @@
 using osu.Framework.Extensions;
 using osu.Framework.Extensions.ObjectExtensions;
 using osu.Framework.Utils;
+using osu.Framework.Logging;

 namespace osu.Framework.Audio.Track
 {
@@ -106,6 +107,9 @@ internal TrackBass(Stream data, string name, bool quick = false)

                 bool success = seconds >= 0;

+                if (Bass.ChannelGetInfo(activeStream, out var info))
+                    Logger.Log($"Track Resolution: {info.Resolution}");
+
                 if (success)
                 {
                     Length = seconds * 1000;

Waveform will no longer bring the constant from TrackBass since Waveform still uses float samples.

@bdach
Copy link
Collaborator

bdach commented Oct 30, 2023

How did you notice this? Does this have any meaningful impact on anything?

Not to say that it won't be merged even if it's correct, it probably will be merged after verification, just wondering how this would ever get spotted.

Waveform will also no longer bring the constant from TrackBass since Waveform still uses float samples.
@hwsmm
Copy link
Contributor Author

hwsmm commented Oct 30, 2023

I could find because I have been working on #6002 which also uses BASS to decode, was just reading TrackBass and spotted this.

This PR probably has impact on nothing since the old value (4) was already correct enough since a sample frame has 2 channels.

Copy link
Contributor

@smoogipoo smoogipoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. It used to have Float specified, but that caused issues with macOS.

@smoogipoo smoogipoo merged commit 0bf4656 into ppy:master Oct 31, 2023
11 of 13 checks passed
@hwsmm hwsmm deleted the fix-bass-resolution branch October 31, 2023 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants