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

Convert volume API from integers [0-128] to floats [0-1] #653

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Starbuck5
Copy link

@Starbuck5 Starbuck5 commented Dec 22, 2024

In a lot of places this actually makes the code simpler. Volumes can be multiplied without then dividing by the integer range, the new SDL3 mixing API can be used without another divide into float-land, it makes one or two music codecs more straightforward.

Closes #652

A couple things I wanted to highlight in review:

  • The handling of gain in music_gme.c might not be 100% the same, I'm finding it difficult to think through the x * y vs floor(x * y + 0.5)/128.
  • The Timidity_SetVolume function previously took in values between 0 and 128, but compares to a MAX AMPLIFICATION of 800, and checks if the value is at least 0. That is strange.
  • Is my handling of master_volume in mixer.c okay? It previously was an SDL_AtomicInt, but there is no SDL_AtomicFloat so I gave it a spinlock instead.

@Starbuck5 Starbuck5 marked this pull request as draft December 22, 2024 12:03
@Starbuck5 Starbuck5 marked this pull request as ready for review December 28, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDL3: update volume to a float
2 participants