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

ao_pipewire: reactivate cubic volume control #15835

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions audio/out/ao_pipewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ static uint64_t pw_stream_get_nsec(struct pw_stream *stream)
}
#endif

// cubic volume scale for a more natural feel of volume change
#define VOL_MP2PW_LIN(v) pow(v/100., 3)
// transform PW linear values to cubic scale, pow(x, 1/n) is the nth root of x
#define VOL_PW2MP_CUB(v) lrint(100 * pow(v, 1/3.))

enum init_state {
INIT_STATE_NONE,
INIT_STATE_SUCCESS,
Expand Down Expand Up @@ -273,12 +278,12 @@ static void on_state_changed(void *userdata, enum pw_stream_state old, enum pw_s

static float spa_volume_to_mp_volume(float vol)
{
return vol * 100;
return VOL_PW2MP_CUB(vol);
}

static float mp_volume_to_spa_volume(float vol)
{
return vol / 100;
return VOL_MP2PW_LIN(vol);
}

static float volume_avg(float* vols, uint32_t n)
Expand Down