summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2023-12-17 14:43:38 -0500
committerDudemanguy <random342@airmail.cc>2024-01-20 16:08:33 +0000
commitf04727145bf0e7c651e08592360fb22a101d3f43 (patch)
tree423d48817b5657884b4b805f8c6c1395f32f3fcb /player/command.c
parent0f2370476b4279040261878c601fb8015a8502d7 (diff)
downloadmpv-f04727145bf0e7c651e08592360fb22a101d3f43.tar.bz2
mpv-f04727145bf0e7c651e08592360fb22a101d3f43.tar.xz
audio: add --volume-gain options to control volume in decibels
This adds volume-gain, volume-gain-max, volume-gain-min options, which can be used to control audio volume and target dynamic range in decibels. The gain is applied on top of the existing volume setting.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/player/command.c b/player/command.c
index c080e779fa..315ebf77c1 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1625,6 +1625,28 @@ static int mp_property_volume(void *ctx, struct m_property *prop,
return mp_property_generic_option(mpctx, prop, action, arg);
}
+static int mp_property_volume_gain(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ struct MPOpts *opts = mpctx->opts;
+
+ switch (action) {
+ case M_PROPERTY_GET_CONSTRICTED_TYPE:
+ *(struct m_option *)arg = (struct m_option){
+ .type = CONF_TYPE_FLOAT,
+ .min = opts->softvol_gain_min,
+ .max = opts->softvol_gain_max,
+ };
+ return M_PROPERTY_OK;
+ case M_PROPERTY_PRINT:
+ *(char **)arg = talloc_asprintf(NULL, "%.1f", opts->softvol_gain);
+ return M_PROPERTY_OK;
+ }
+
+ return mp_property_generic_option(mpctx, prop, action, arg);
+}
+
static int mp_property_ao_volume(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3872,6 +3894,7 @@ static const struct m_property mp_properties_base[] = {
// Audio
{"mixer-active", mp_property_mixer_active},
{"volume", mp_property_volume},
+ {"volume-gain", mp_property_volume_gain},
{"ao-volume", mp_property_ao_volume},
{"ao-mute", mp_property_ao_mute},
{"audio-delay", mp_property_audio_delay},
@@ -4033,9 +4056,9 @@ static const char *const *const mp_event_property_change[] = {
"video-dec-params", "osd-dimensions",
"hwdec", "hwdec-current", "hwdec-interop"),
E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate",
- "samplerate", "channels", "audio", "volume", "mute",
+ "samplerate", "channels", "audio", "volume", "volume-gain", "mute",
"current-ao", "audio-codec-name", "audio-params",
- "audio-out-params", "volume-max", "mixer-active"),
+ "audio-out-params", "volume-max", "volume-gain-min", "volume-gain-max", "mixer-active"),
E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"),
E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"),
E(MP_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"),