Hi Georg,

Thank you so much for that fast reply!
It helped me find the solution I was looking for :)

For completeness, here's what I found and how this can work.

First module-role-cork. It turns out I had that one active already. All it
needed was roles to be passed to applications which can be done like [1].
Once I passed those roles the corking effect was immediately clear when
starting the media with the "phone" role.
Downside in my case of cork is that it completely mutes the other (music in
this case) which is a bit sudden.

Module-role-ducking on the other hand is exactly what i'm looking for!
I removed module-role-cork and loaded module-role-ducking with these
settings:
load-module module-role-ducking trigger_roles=phone
ducking_roles=music,video volume=60%
Next (pulseaudio restart in between) I just played [1] again.
Now the music stream is lowered in volume while the phone stream has audio
to output.

While this works, it's still a bit rough.
In my case the "phone" stream is the mpv media player. As long as it just
plays something it works as-described. If you however start seeking
forward/backward in that "phone" stream then - the fraction of time you
seek and have no sound - ducking resumes the volume level of "music" to
what it was. So if you do a lot of seeking you have a lot of volume jumps
which sounds very weird. It would be great if ducking would wait for a
second or so before resuming volume. A bonus feature would be if ducking
would fade in and out over - say - 300ms.

Anyhow, this is already very usable to me! Thank you so much for pointing
me in the right direction Georg, that's much appreciated!

[1] just start 2 media players with different roles:
PULSE_PROP='media.role=music' mpv <media to play>
PULSE_PROP='media.role=phone' mpv <media to play>


On Sat, May 4, 2024 at 12:08 PM Georg Chini <ge...@chini.tk> wrote:

> Hi Mark,
>
> there are module-role-cork and module-role-ducking which provide the
> kind of functionality
> you are looking for. If you have a stream with "role1" assigned, which
> should duck all other
> streams, the command would be something like
>
> pactl load-module module-role-ducking trigger_roles="role1"
> ducking_roles="any_role" global=1
>
> The grouping of roles works for both, module-role-cork and
> module-role-ducking even though
> it is only mentioned in the description of module-role-ducking.
> (pacmd describe-module module-role-ducking) You can use the special
> roles "any_role" to specify
> all streams and "no_role" for those streams that do not have a role
> assigned.
>
> The main problem is to make sure that your (trigger) streams always have
> the correct role,
> so you have to set the media.role property somehow.
>
> Regards
>                 Georg
>
> On 04.05.24 10:27, Mark Gaiser wrote:
> > Hi,
> >
> > Let me first try to describe what I'm trying to do. Perhaps there is
> > an existing solution for this already that I haven't found yet.
> >
> > This is mostly for home automation purposes. Imagine you have a DIY
> > speaker with a raspberry pi. You use it to play music on. Perhaps even
> > with a higher quality DAC. The gist is that you have a linux-based
> > speaker that uses pulseaudio for playback.
> >
> > Now you want to send an audio notification. What you would want to do is:
> > - Whatever is currently playing, lower it's volume
> > - Play the notification at a louder volume
> > - Resume to whatever was playing at whatever volume it was
> >
> > Are there any ways that one can achieve the above with the current
> > pulseaudio version?
> >
> > The following is a brainstorm! What I'm thinking is if it would be
> > possible to make a pulseaudio module that registers its own dedicated
> > sink. When audio is being sent to that sink then it would lower the
> > volume on the other sinks. When no more audio is sent the other sinks
> > get restored to whatever their level was. Audio played on this
> > "notification sink" is boosted a little. All these options should be
> > configurable. Would such a plugin even be possible in pulseaudio? I
> > guess I'm asking if a plugin has the capabilities to modify the output
> > of other sinks?
> >
> > I'm looking forward to what you folks think.
> > Hopefully it's all already possible :) That sure is a million times
> > easier!
> >
> > Best regards,
> > Mark
> >
>

Reply via email to