Control volume of mpg123
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Good time of day! Currently developing something like "smart home" and I need to start different audio streams with different volume level. For example, I want to hear background music with 20% of original volume but in case if someone press door bell then I want to hear that bell ring with 100% volume. For my purposes currently, I'm using mpg123
with Python scripts. Python script with pexpect
runs mpg123 with needed settings like
mpg123 -vC <filename>
Current approach sends 's'
like pause immediately after the player starts. Then I'm sending needed count of '-'
like decrease volume by 2 to the player and resume it. Huh... it works but an implementation is ugly, and there is some gap between the player start and volume decreasing. At least I hear few first "packets" before python script actually pauses player and decrease volume.
Is there any way to reduce the volume by some command?
Is there any way to start mpg123 paused? At least to eliminate that gap
Thanks!
python audio
add a comment |Â
up vote
0
down vote
favorite
Good time of day! Currently developing something like "smart home" and I need to start different audio streams with different volume level. For example, I want to hear background music with 20% of original volume but in case if someone press door bell then I want to hear that bell ring with 100% volume. For my purposes currently, I'm using mpg123
with Python scripts. Python script with pexpect
runs mpg123 with needed settings like
mpg123 -vC <filename>
Current approach sends 's'
like pause immediately after the player starts. Then I'm sending needed count of '-'
like decrease volume by 2 to the player and resume it. Huh... it works but an implementation is ugly, and there is some gap between the player start and volume decreasing. At least I hear few first "packets" before python script actually pauses player and decrease volume.
Is there any way to reduce the volume by some command?
Is there any way to start mpg123 paused? At least to eliminate that gap
Thanks!
python audio
Pulseaudio or ALSA? Under Pulseaudio, you can control the volume per application, and it remembers the last volume by name of application. Some tools likepaplay
have options to set application or stream name. Withpacmd
, and you can script volume changes etc. Under ALSA< it's going to be a lot more difficult.
â dirkt
Jul 6 '17 at 7:20
I can use pulse or ALSA but I will be glad to use some higher level tool like player and control volume in it, not in system mixer
â user922871
Jul 6 '17 at 7:37
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Good time of day! Currently developing something like "smart home" and I need to start different audio streams with different volume level. For example, I want to hear background music with 20% of original volume but in case if someone press door bell then I want to hear that bell ring with 100% volume. For my purposes currently, I'm using mpg123
with Python scripts. Python script with pexpect
runs mpg123 with needed settings like
mpg123 -vC <filename>
Current approach sends 's'
like pause immediately after the player starts. Then I'm sending needed count of '-'
like decrease volume by 2 to the player and resume it. Huh... it works but an implementation is ugly, and there is some gap between the player start and volume decreasing. At least I hear few first "packets" before python script actually pauses player and decrease volume.
Is there any way to reduce the volume by some command?
Is there any way to start mpg123 paused? At least to eliminate that gap
Thanks!
python audio
Good time of day! Currently developing something like "smart home" and I need to start different audio streams with different volume level. For example, I want to hear background music with 20% of original volume but in case if someone press door bell then I want to hear that bell ring with 100% volume. For my purposes currently, I'm using mpg123
with Python scripts. Python script with pexpect
runs mpg123 with needed settings like
mpg123 -vC <filename>
Current approach sends 's'
like pause immediately after the player starts. Then I'm sending needed count of '-'
like decrease volume by 2 to the player and resume it. Huh... it works but an implementation is ugly, and there is some gap between the player start and volume decreasing. At least I hear few first "packets" before python script actually pauses player and decrease volume.
Is there any way to reduce the volume by some command?
Is there any way to start mpg123 paused? At least to eliminate that gap
Thanks!
python audio
python audio
asked Jul 5 '17 at 22:02
user922871
62
62
Pulseaudio or ALSA? Under Pulseaudio, you can control the volume per application, and it remembers the last volume by name of application. Some tools likepaplay
have options to set application or stream name. Withpacmd
, and you can script volume changes etc. Under ALSA< it's going to be a lot more difficult.
â dirkt
Jul 6 '17 at 7:20
I can use pulse or ALSA but I will be glad to use some higher level tool like player and control volume in it, not in system mixer
â user922871
Jul 6 '17 at 7:37
add a comment |Â
Pulseaudio or ALSA? Under Pulseaudio, you can control the volume per application, and it remembers the last volume by name of application. Some tools likepaplay
have options to set application or stream name. Withpacmd
, and you can script volume changes etc. Under ALSA< it's going to be a lot more difficult.
â dirkt
Jul 6 '17 at 7:20
I can use pulse or ALSA but I will be glad to use some higher level tool like player and control volume in it, not in system mixer
â user922871
Jul 6 '17 at 7:37
Pulseaudio or ALSA? Under Pulseaudio, you can control the volume per application, and it remembers the last volume by name of application. Some tools like
paplay
have options to set application or stream name. With pacmd
, and you can script volume changes etc. Under ALSA< it's going to be a lot more difficult.â dirkt
Jul 6 '17 at 7:20
Pulseaudio or ALSA? Under Pulseaudio, you can control the volume per application, and it remembers the last volume by name of application. Some tools like
paplay
have options to set application or stream name. With pacmd
, and you can script volume changes etc. Under ALSA< it's going to be a lot more difficult.â dirkt
Jul 6 '17 at 7:20
I can use pulse or ALSA but I will be glad to use some higher level tool like player and control volume in it, not in system mixer
â user922871
Jul 6 '17 at 7:37
I can use pulse or ALSA but I will be glad to use some higher level tool like player and control volume in it, not in system mixer
â user922871
Jul 6 '17 at 7:37
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Options for Pulseaudio:
1) Stream the output of mpg123
into paplay
, for example with something like
mpg123 --stdout ... | paplay --rate=44100 --format=s16le --channels=2 --stream-name=Music --client-name=Musicplayer --volume=65536
You can either set the volume on the commandline as above, or set the volume once in pavucontrol
by client-name, and the next time the same application starts it will remember the volume. So if you use different client names, say Musicplayer
and Bellringer
, you can pre-set the volume once and for all, without having it to change from Python.
2) Use some other program to play MP3 files that uses Pulseaudio and either can set the client name, or has a recognizable client name, or has a option to set the volume. E.g.
mplayer -volume=... ...
Then you have the same options as above.
3) Use pamcd
or pactl
to set the volume of the stream that's playing, e.g.
pacmd set-sink-input-volume 42 50%
You can use something similar to
pacmd list-sink-inputs | egrep '(index)|(name)'
to find the index numer for a given stream or client name. Or parse the complete output in Python.
4) Use the DBUS interface of Pulseaudio from Python. This will require some programming.
I wouldn't advise to use Python with pexpect
to somehow change the volume through the UI, that looks like a horrible kludge, and isn't really "higher level".
Thanks a lot! Your answer is really helpful! Do you know any other ways to interact with the player? It will be good for me to softly increase/decrease volume value. Thanks!
â user922871
Jul 6 '17 at 19:00
Withmpg123
? No, I don't know ways to interact with it, and I wouldn't try. You can change the volume smoothly viapacmd
or DBus.
â dirkt
Jul 6 '17 at 21:13
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Options for Pulseaudio:
1) Stream the output of mpg123
into paplay
, for example with something like
mpg123 --stdout ... | paplay --rate=44100 --format=s16le --channels=2 --stream-name=Music --client-name=Musicplayer --volume=65536
You can either set the volume on the commandline as above, or set the volume once in pavucontrol
by client-name, and the next time the same application starts it will remember the volume. So if you use different client names, say Musicplayer
and Bellringer
, you can pre-set the volume once and for all, without having it to change from Python.
2) Use some other program to play MP3 files that uses Pulseaudio and either can set the client name, or has a recognizable client name, or has a option to set the volume. E.g.
mplayer -volume=... ...
Then you have the same options as above.
3) Use pamcd
or pactl
to set the volume of the stream that's playing, e.g.
pacmd set-sink-input-volume 42 50%
You can use something similar to
pacmd list-sink-inputs | egrep '(index)|(name)'
to find the index numer for a given stream or client name. Or parse the complete output in Python.
4) Use the DBUS interface of Pulseaudio from Python. This will require some programming.
I wouldn't advise to use Python with pexpect
to somehow change the volume through the UI, that looks like a horrible kludge, and isn't really "higher level".
Thanks a lot! Your answer is really helpful! Do you know any other ways to interact with the player? It will be good for me to softly increase/decrease volume value. Thanks!
â user922871
Jul 6 '17 at 19:00
Withmpg123
? No, I don't know ways to interact with it, and I wouldn't try. You can change the volume smoothly viapacmd
or DBus.
â dirkt
Jul 6 '17 at 21:13
add a comment |Â
up vote
0
down vote
Options for Pulseaudio:
1) Stream the output of mpg123
into paplay
, for example with something like
mpg123 --stdout ... | paplay --rate=44100 --format=s16le --channels=2 --stream-name=Music --client-name=Musicplayer --volume=65536
You can either set the volume on the commandline as above, or set the volume once in pavucontrol
by client-name, and the next time the same application starts it will remember the volume. So if you use different client names, say Musicplayer
and Bellringer
, you can pre-set the volume once and for all, without having it to change from Python.
2) Use some other program to play MP3 files that uses Pulseaudio and either can set the client name, or has a recognizable client name, or has a option to set the volume. E.g.
mplayer -volume=... ...
Then you have the same options as above.
3) Use pamcd
or pactl
to set the volume of the stream that's playing, e.g.
pacmd set-sink-input-volume 42 50%
You can use something similar to
pacmd list-sink-inputs | egrep '(index)|(name)'
to find the index numer for a given stream or client name. Or parse the complete output in Python.
4) Use the DBUS interface of Pulseaudio from Python. This will require some programming.
I wouldn't advise to use Python with pexpect
to somehow change the volume through the UI, that looks like a horrible kludge, and isn't really "higher level".
Thanks a lot! Your answer is really helpful! Do you know any other ways to interact with the player? It will be good for me to softly increase/decrease volume value. Thanks!
â user922871
Jul 6 '17 at 19:00
Withmpg123
? No, I don't know ways to interact with it, and I wouldn't try. You can change the volume smoothly viapacmd
or DBus.
â dirkt
Jul 6 '17 at 21:13
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Options for Pulseaudio:
1) Stream the output of mpg123
into paplay
, for example with something like
mpg123 --stdout ... | paplay --rate=44100 --format=s16le --channels=2 --stream-name=Music --client-name=Musicplayer --volume=65536
You can either set the volume on the commandline as above, or set the volume once in pavucontrol
by client-name, and the next time the same application starts it will remember the volume. So if you use different client names, say Musicplayer
and Bellringer
, you can pre-set the volume once and for all, without having it to change from Python.
2) Use some other program to play MP3 files that uses Pulseaudio and either can set the client name, or has a recognizable client name, or has a option to set the volume. E.g.
mplayer -volume=... ...
Then you have the same options as above.
3) Use pamcd
or pactl
to set the volume of the stream that's playing, e.g.
pacmd set-sink-input-volume 42 50%
You can use something similar to
pacmd list-sink-inputs | egrep '(index)|(name)'
to find the index numer for a given stream or client name. Or parse the complete output in Python.
4) Use the DBUS interface of Pulseaudio from Python. This will require some programming.
I wouldn't advise to use Python with pexpect
to somehow change the volume through the UI, that looks like a horrible kludge, and isn't really "higher level".
Options for Pulseaudio:
1) Stream the output of mpg123
into paplay
, for example with something like
mpg123 --stdout ... | paplay --rate=44100 --format=s16le --channels=2 --stream-name=Music --client-name=Musicplayer --volume=65536
You can either set the volume on the commandline as above, or set the volume once in pavucontrol
by client-name, and the next time the same application starts it will remember the volume. So if you use different client names, say Musicplayer
and Bellringer
, you can pre-set the volume once and for all, without having it to change from Python.
2) Use some other program to play MP3 files that uses Pulseaudio and either can set the client name, or has a recognizable client name, or has a option to set the volume. E.g.
mplayer -volume=... ...
Then you have the same options as above.
3) Use pamcd
or pactl
to set the volume of the stream that's playing, e.g.
pacmd set-sink-input-volume 42 50%
You can use something similar to
pacmd list-sink-inputs | egrep '(index)|(name)'
to find the index numer for a given stream or client name. Or parse the complete output in Python.
4) Use the DBUS interface of Pulseaudio from Python. This will require some programming.
I wouldn't advise to use Python with pexpect
to somehow change the volume through the UI, that looks like a horrible kludge, and isn't really "higher level".
answered Jul 6 '17 at 11:38
dirkt
14.8k2932
14.8k2932
Thanks a lot! Your answer is really helpful! Do you know any other ways to interact with the player? It will be good for me to softly increase/decrease volume value. Thanks!
â user922871
Jul 6 '17 at 19:00
Withmpg123
? No, I don't know ways to interact with it, and I wouldn't try. You can change the volume smoothly viapacmd
or DBus.
â dirkt
Jul 6 '17 at 21:13
add a comment |Â
Thanks a lot! Your answer is really helpful! Do you know any other ways to interact with the player? It will be good for me to softly increase/decrease volume value. Thanks!
â user922871
Jul 6 '17 at 19:00
Withmpg123
? No, I don't know ways to interact with it, and I wouldn't try. You can change the volume smoothly viapacmd
or DBus.
â dirkt
Jul 6 '17 at 21:13
Thanks a lot! Your answer is really helpful! Do you know any other ways to interact with the player? It will be good for me to softly increase/decrease volume value. Thanks!
â user922871
Jul 6 '17 at 19:00
Thanks a lot! Your answer is really helpful! Do you know any other ways to interact with the player? It will be good for me to softly increase/decrease volume value. Thanks!
â user922871
Jul 6 '17 at 19:00
With
mpg123
? No, I don't know ways to interact with it, and I wouldn't try. You can change the volume smoothly via pacmd
or DBus.â dirkt
Jul 6 '17 at 21:13
With
mpg123
? No, I don't know ways to interact with it, and I wouldn't try. You can change the volume smoothly via pacmd
or DBus.â dirkt
Jul 6 '17 at 21:13
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f375595%2fcontrol-volume-of-mpg123%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Pulseaudio or ALSA? Under Pulseaudio, you can control the volume per application, and it remembers the last volume by name of application. Some tools like
paplay
have options to set application or stream name. Withpacmd
, and you can script volume changes etc. Under ALSA< it's going to be a lot more difficult.â dirkt
Jul 6 '17 at 7:20
I can use pulse or ALSA but I will be glad to use some higher level tool like player and control volume in it, not in system mixer
â user922871
Jul 6 '17 at 7:37