Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sounds on errors #25

Description

@rpodcast

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions