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

How to mute soundplay_node? #166

Closed
5tan opened this issue Jan 21, 2021 · 7 comments
Closed

How to mute soundplay_node? #166

5tan opened this issue Jan 21, 2021 · 7 comments
Labels

Comments

@5tan
Copy link

5tan commented Jan 21, 2021

This is bug or feature request.

I would like to add "mute" capability to robot using ReSpeaker as audio output.

Unfortunately system mute button doesn't work when I use soundplay and reaspeaker. This is weird because when I use sound_play with sound card on my laptop, mute button works. Also if I use ReSpeaker with other audio apps (e.g. chromium/YouTube) mute button works.

Summary:
default laptop sound card + sound_play -> mute button works
ReSpeaker + sound_play -> mute button doesn't work
ReSpeaker + chromium/YouTube -> mute button works

Any idea what is the issue here? Is this bug in ReSpeaker firmware? In sound_play? Or in some gstreamer plugin? How to verify this?

What option do you recommend to mute soundplay_node? Do you find "mute" a useful feature to add?

@knorth55
Copy link
Member

can you check if you can change the volume level of respeaker byalsamixer?
if not, we cannot change it, probably.
Can you also try volume=0 field in SoundRequest?

@5tan
Copy link
Author

5tan commented Jan 22, 2021

with alsamixer no, "This sound device does not have any controls."
image
but with pavucontrol yes, I can change volume and mute. It works when I use e.g. chromium, but doesn't work when I use sound_play. What's the difference?
image

Can you also try volume=0 field in SoundRequest?

Yes, this can be workaround, but not perfect in distributed system (since sound requests might come from many source nodes).

@knorth55
Copy link
Member

knorth55 commented Jan 22, 2021

soundplay_node.py uses alsasink, which relies on alsa.
so if you cannot control volume your device from alsa, you cannot control it, probably (I'm not a alsa specialist, so I'm not 100% sure).
https://github.com/ros-drivers/audio_common/blob/master/sound_play/scripts/soundplay_node.py#L85

I found out respeaker alsa issue in github, so please ask about alsa support in the issue.
respeaker/usb_4_mic_array#39

Or another solution is to use different sink in soundplay_node.py, such as pulsesink.
https://gstreamer.freedesktop.org/documentation/pulseaudio/pulsesink.html?gi-language=c

@knorth55 knorth55 added the bug label Jan 22, 2021
@5tan
Copy link
Author

5tan commented Jan 22, 2021

Thanks @knorth55 !
Can I change sink by configuration? Or do I have to modify soundplay_node code? https://github.com/ros-drivers/audio_common/blob/master/sound_play/scripts/soundplay_node.py#L85

@knorth55
Copy link
Member

you need to change the source code following part.
I'm not sure it will work if you simply change just one line.
https://github.com/ros-drivers/audio_common/blob/master/sound_play/scripts/soundplay_node.py#L85

@5tan
Copy link
Author

5tan commented Jan 25, 2021

As it turned out, I just had to install gstreamer1.0-pulseaudio (and configure my docker for pulseaudio access). soundplay_node began to use pulseaudio instantly (no changes in code required).

I am not sure how this works (how alsasink got promoted into pulsesink?), but it's fantastic finding for ReSpeaker users.

For me the case is closed, thanks!

@5tan 5tan closed this as completed Jan 25, 2021
@yuetin
Copy link

yuetin commented May 29, 2024

As it turned out, I just had to install gstreamer1.0-pulseaudio (and configure my docker for pulseaudio access). soundplay_node began to use pulseaudio instantly (no changes in code required).

I am not sure how this works (how alsasink got promoted into pulsesink?), but it's fantastic finding for ReSpeaker users.

For me the case is closed, thanks!

Could you explain how to change the docker archive?
i have same problem in this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants