Skip to content

Added libretro native volume mixer controls#718

Open
rtomasa wants to merge 3 commits intoschellingb:mainfrom
rtomasa:main
Open

Added libretro native volume mixer controls#718
rtomasa wants to merge 3 commits intoschellingb:mainfrom
rtomasa:main

Conversation

@rtomasa
Copy link

@rtomasa rtomasa commented Feb 20, 2026

This PR adds libretro options for DOSBox mixer channels.

What’s included

  • Added new core options for mixer volume control:
    MASTER, DISNEY, SPKR, SB, FM, TSF
  • Option range is 0% to 100% in 10% steps (default 100%).
  • Implemented perceptual volume mapping (logarithmic-in-dB), not linear gain:
    • 100% = 0 dB
    • 0% = mute

Implementation details

  • Added a dedicated per-channel user multiplier in mixer internals (user_scale) so core-option volume acts as an override layer without breaking existing device-specific mixer logic.
  • Added runtime setter functions for master/channel volume and applied them with audio locking for thread safety.
  • Stored channel overrides so they also apply to channels created after boot (not only already-active channels).

NOTE: I removed the Advanced > and Detailed > tags from the core options because they take up unnecessary space and provide little value. They appear to be inherited from the original DOSBox core. If you prefer to keep them, let me know and I will restore them.

if (!dbp_optionsupdatecallback && control && environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &variable_update) && variable_update)
// Always poll variable updates in retro_run: some frontends report callback support
// but do not invoke update-display callbacks consistently.
if (control && environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &variable_update) && variable_update)
Copy link
Author

Choose a reason for hiding this comment

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

This change makes options to be applied in real time without core restart.

@schellingb
Copy link
Owner

Hey there. I'm generally not open to PRs but this looks pretty good, close to what I had in mind but never got around implementing. So thanks for this. Having a separate user_scale in MixerChannel is probably the safest.

First - and I'm sorry I have to ask this but it's the times - did you write this code or was this assisted in any way by via a large language model of some sort? I looked at your GitHub profile and it doesn't look like that's your thing, but just to confirm. I probably should get some thing going that makes opening a PR on this project ask that question.

Secondly, I'm not sure it's great that there is a setting specific for "TSF". The user has no idea what "TinySoundFont" is so there's no meaning of mentioning it in the help description. Also it doesn't cover the MT-32 emulation. So there should just be one "MIDI" volume setting that controls all forms (maybe it can say "except the Frontend MIDI driver" or "except the System MIDI driver" because that doesn't go through the DOSBox mixer).

Then there's a few more mixer channels that aren't covered here. There's the mentioned "MT32", there's a pair of channels "TANDY" and "TANDYDAC" (Tandy Sound System), there's "CMS" (Gameblaster) and there's "GUS" (Gravis Ultra Sound).

I almost feel like the "uncommon" ones ("DISNEY", "TANDY", "TANDYDAC", "GUS") could all go under one setting. But I'm very rarely using them so maybe I'm the wrong person to ask. Either way I think there needs to be at least a few settings that cover 2 or more mixer channels:

  • Sound Blaster: "SB", "CMS"
  • MIDI Synthesizer: "TSF", "MT32"
  • Adlib: "FM" (the core options refer to it as Adlib not FM/OPL)
  • PC-Speaker: "SPKR"

Then either we have one

  • Others (Disney Sound Source, Tandy Sound System, Gravis Ultra Sound): "DISNEY", "TANDY", "TANDYDAC", "GUS"

Or separate them

  • Tandy: "TANDY", "TANDYDAC" (or maybe put it under the PC-Speaker, it covers somewhat of a similar space...)
  • Disney Sound Source: "DISNEY"
  • Gravis Ultra Sound: "GUS"

@rtomasa
Copy link
Author

rtomasa commented Feb 20, 2026

Hi, I'm the developer behind RePlayOS, a new libretro frontend. The repository is private, which is why you could not see it, but I have many other open-source repositories, including controller drivers, GunCon2 support, and other cores such as a media player, and small contributions to many other cores.

In response to your question, yes, about a year ago I started using code assistants because they make my life much easier by helping me write code faster and with fewer errors. However, I never let them write freely. I always analyze the existing code myself first so I can specify the exact technical changes I want. After the generated code aligns with my requests and coding style, I usually apply additional manual adjustments based on my own preferences. That was the reason the mixers you mentioned, such as TANDY and CMS, were missing. I had only checked the mixers displayed when typing the mixer command in the MS-DOS prompt, and I have now realized those depend on the loaded game.
Things like perceptual volume were taken from my own frontend, since I use the same functions for volume control.

That said, I have now included the missing mixers and merged the changes based on your suggestions. I hope you like it.

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