Skip to content

Fix wrong bytes per sample in TrackBass#6039

Merged
smoogipoo merged 1 commit into
ppy:masterfrom
hwsmm:fix-bass-resolution
Oct 31, 2023
Merged

Fix wrong bytes per sample in TrackBass#6039
smoogipoo merged 1 commit into
ppy:masterfrom
hwsmm:fix-bass-resolution

Conversation

@hwsmm

@hwsmm hwsmm commented Oct 30, 2023

Copy link
Copy Markdown
Contributor

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

bdach commented Oct 30, 2023

Copy link
Copy Markdown
Collaborator

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

hwsmm commented Oct 30, 2023

Copy link
Copy Markdown
Contributor Author

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.

@hwsmm hwsmm force-pushed the fix-bass-resolution branch from 7b22710 to 9756229 Compare October 30, 2023 15:03

@smoogipoo smoogipoo left a comment

Copy link
Copy Markdown
Contributor

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 enabled auto-merge October 31, 2023 06:36
@smoogipoo smoogipoo merged commit 0bf4656 into ppy:master Oct 31, 2023
@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