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

sounds on errors #25

Open
rpodcast opened this issue Dec 18, 2021 · 0 comments
Open

sounds on errors #25

rpodcast opened this issue Dec 18, 2021 · 0 comments

Comments

@rpodcast
Copy link
Owner

rpodcast commented Dec 18, 2021

Key is to get pulse audio working in container and mounted to host processes. Post at https://joonas.fi/2020/12/audio-in-docker-containers-linux-audio-subsystems-spotifyd/ gives a nice overview. Here's what i got working:

More links:

TODO

  • Try setting options for error in R to play sound

Implementation

  1. Add these ubuntu packages to the Dockerfile: libpulse0 libasound2 libasound2-plugins pulseaudio-utils
  2. Add more mounts and custom environment vars to devcontainer.json
// Add more local mounts to container
	"mounts": [
		"source=/opt/local/renv/cache,target=/renv/cache,type=bind,consistency=cached",
		"source=/etc/alsa,target=/etc/alsa,type=bind,consistency=cached",
		"source=/usr/share/alsa,target=/usr/share/alsa,type=bind,consistency=cached",
		"source=/run/user/1000/pulse/native,target=/run/user/1000/pulse/native,type=bind,consistency=cached"
	],

"containerEnv": {
		"PULSE_SERVER": "unix:/run/user/1000/pulse/native"
	}
  1. Audio can be played in a container system process via paplay (which the {beepr} package wraps:
paplay some_file.wav

To route the sound to a custom pulse audio sink:

paplay some_file.wav -d SoundBoard

where SoundBoard is an example of the name

  1. To play in R:
system2("paplay", args = c("some_file.wav", "-d", "SoundBoard"), wait = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant