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

RPC command SET_USER_VOICE_SETTINGS "volume" not sending good values #7325

Closed
mthsgl opened this issue Jan 3, 2025 · 3 comments
Closed

RPC command SET_USER_VOICE_SETTINGS "volume" not sending good values #7325

mthsgl opened this issue Jan 3, 2025 · 3 comments
Labels

Comments

@mthsgl
Copy link

mthsgl commented Jan 3, 2025

Description

When I send a SET_USER_VOICE_SETTINGS command to my RPC application (using pypresence library), the volume value I'm sending is not the one displayed on my discord client.
Valeurs discord.xlsx

Steps to Reproduce

  1. Create a application and connect to it in RPC
  2. Send a SET_USER_VOICE_SETTINGS command with arg : "volume" = [int between 0 and 200]

Expected Behavior

Sending the value "volume" to my client

Current Behavior

Values not corresponding even though API is answering with the value I sent

Screenshots/Videos

You can find attached an excel file with the value I sent and the one displayed on Discord Client

Client and System Information

Using pypresence and python on a W11 machine

@mthsgl mthsgl added the bug label Jan 3, 2025
@lsdimagine
Copy link

@mthsgl do you mind posting all params in your command?

@mthsgl
Copy link
Author

mthsgl commented Jan 9, 2025

Here is the Payload schema sent by pypresence library :
`def set_user_voice_settings(cls, user_id: str, pan_left: float = None,
pan_right: float = None, volume: int = None,
mute: bool = None):
payload = {
"cmd": "SET_USER_VOICE_SETTINGS",
"args": {
"user_id": str(user_id),
"pan": {
"left": pan_left,
"right": pan_right
},
"volume": volume,
"mute": mute
},
"nonce": '{:.20f}'.format(cls.time())
}

    print (payload)

    return cls(payload, True)`

And here is the payload for a user in my vocal:
{ "cmd": "SET_USER_VOICE_SETTINGS", "args": { "user_id": "933262680758825011", "pan": { "left": null, "right": null }, "volume": 29, "mute": null }, "nonce": "1736411427.93830204010009765625" }

Note: it changed the volume of the user to 78 on my discord client

@rcombs
Copy link

rcombs commented Jan 14, 2025

This is by-design. The Discord UI exposes a "perceptual" volume level, which has a non-linear relationship with the actual underlying amplitude. The exact function used for the conversion isn't specified, and may change in the future; RPC clients shouldn't rely on it. The APC API exposes the underlying linear amplitude value, so its behavior is guaranteed to remain stable. If exposing this value to a user in a slider or similar UI element, I'd suggest applying your own perceptual curve (a power function with an exponent between 2 and 5 tends to work well; the exact optimal curve depends on your design).

@rcombs rcombs closed this as completed Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants