Search code examples
soxpulseaudio

How do I specify the PuseAudio "application name" when playing a sound with SoX?


I want to run a command from a script, like play mysound.mp3, and have the volume for such invocations be remembered by PulseAudio.

I do not want that volume to apply to every invocation of play that I make on my system, just these special ones.

In PulseAudio, you can set sound per-application (aka "sink input"). But How do I run play with a custom application/sink-input name, so it can be differentiated from other invocations?

I'm imagining something like play --appname foo mysound.mp3, but I haven't found an option in SoX to do that.

Right now, they all show up like this in pactl list sink-inpuits:

Sink Input #4023
        Driver: protocol-native.c
        Owner Module: 8
        Client: 2943
        Sink: 2
        Sample Specification: s32le 2ch 44100Hz
        Channel Map: front-left,front-right
        Format: pcm, format.sample_format = "\"s32le\""  format.rate = "44100"  format.channels = "2"  format.channel_map = "\"fr
ont-left,front-right\""
        Corked: no
        Mute: no
        Volume: front-left: 42325 /  65% / -11.39 dB,   front-right: 42325 /  65% / -11.39 dB
                balance 0.00
        Buffer Latency: 130521 usec
        Sink Latency: 100817 usec
        Resample method: copy
        Properties:
                media.name = "playback"
                application.name = "SoX"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "32"
                application.process.id = "4707"
                application.process.user = "myname"
                application.process.host = "myhost"
                application.process.binary = "sox"
                application.language = "C"
                window.x11.display = ":0.0"
                application.process.machine_id = "fa117ee892c54109a928f2c38093b473"
                application.process.session_id = "1"
                module-stream-restore.id = "sink-input-by-application-name:SoX"

So I'm imagining being able to set the application.name field, or similar.

Anyone know how to do this?


Solution

  • It seems the answer is "no, you can't do that, currently".

    From email on the sox-users list:

    There is currently no way to set the name. It is hard-coded here: https://sourceforge.net/p/sox/code/ci/master/tree/src/pulseaudio.c#l65