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

Add global Audio Volume setting to REPL #1166

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

Conversation

netux
Copy link
Contributor

@netux netux commented Aug 18, 2024

Allows for adjusting the global volume/gain of the REPL. Set default global value to 50%.

  • Acts similarily to gain(), but without modifying the code.
  • The volume slider uses a logarithmic scale, so it adjusts better to human sound perception.
  • Volume defaults to 50%, which was ideal for me. It can be raised if needed.

I also wanted to add a volume slider to the MiniRepl. But because multiple MiniRepl's can be on a page at the same time, while this setting is global, really makes it hard to implement.

netux added 3 commits August 18, 2024 02:14
Allows for adjusting the global volume/gain of the REPL. Set default global value to 50%.

Acts similarily to `gain()`, but without modifying the code, so passerbys who don't know how to use the tool can adjust the volume too).

The volume slider uses a logarithmic scale, so it adjusts better to human sound perception.
@yaxu
Copy link
Member

yaxu commented Sep 3, 2024

Awesome, I've been finding 50% works well for me as well..

@yaxu
Copy link
Member

yaxu commented Sep 3, 2024

The recently merged PR #1160 added an 'audio engine target' option. The audio volume slider doesn't have any effect when the 'osc' option is selected. Would it be possible to hide or grey out the audio volume slider when webaudio isn't selected? I don't think it would make too much sense to have the slider change the gain control or something like that, as it would need a different default to match superdirt (probably 1).

@netux
Copy link
Contributor Author

netux commented Sep 3, 2024

Sure. How about that?
audio engine target set to osc, audio volume slider disabled

…correctly when step < 1

If we keep flooring the value, but have a step of, e.g., 0.1, then we are never going to reach the next whole number value.

This applies specifically to the Audio Volume slider.
This is a bit overkill, but this way we can somewhat adjust the width of the input so no symbols are cut off (either by the input being too small, or the up/down arrows from the browser).

I am not happy about having to use `calc()` with some magic numbers either, but this is what looked nicest to me and had the least effort.
This ensures the audio volume is synced across tabs, since changing the volume in one tab would retrigger the effect in the other tabs.

It also means we can remove the explicit call to `setGlobalAudioVolume()` from <SettingsTab>
@netux
Copy link
Contributor Author

netux commented Sep 3, 2024

Got a few suggestions from Discord (namely, the new algorithm to calculate resulting gain), as well as a couple things I found while retesting.

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.

2 participants