2

I want to route (clone) my audio output (all sounds that are leaving the system through hdmi) to an virtual input device so I can capture the output (virtual audio cable). As said the output is hdmi and I'm using kodi for playback.

I've searched a lot but couldn't find the perfect solution. I want a config which affects my actual system as little as possible. Also I have to say that I use passthrough in kodi.

I know it could be possible with Jack but couldn't find a solution. Also I know it could be possible with "plain" alsa and a loopback interface and finally it could be possible with pulseaudio but everything is so much confusing especially with hdmi.

Right now I'm using alsa.

user685336
  • 21
  • 1
  • 2

1 Answers1

1

It's actually really easy to do that with Pulseaudio, so if you want a config that affects your actual system as little as possible, it's the ideal solution.

Under Pulseaudio, every sink (e.g. your HDMI output) has a corresponding monitor source (same name, but with .monitor at the end). You just have to record audio from this source, using any application you like, and you can capture the output that leaves your system through this sink. You can point applicatons to specific sources either with the pavucontrol utility, or using command line switches etc. of the application, e.g. arecord -d your-hdmi-device.monitor.

For ALSA, you have to use the snd-aloop kernel module, set up a virtual soundcard, duplicate your HDMI sound output with the dshare plugin, route it to the virtual soundcard, and then record from this soundcard. Which is a good deal more complicated than the Pulseaudio solution, and I'd have to expirement with .asoundrc myself to get that right.

dirkt
  • 16,421
  • 3
  • 31
  • 37
  • Do you have an example how I can extend my setup to pulse? Furthermore I forgot to tell that I'm using PyAudio to capture. – user685336 Jan 13 '17 at 11:13
  • Usually all distros offer Pulseaudio support out of the box; just install the right packages. There's an ALSA compatibility layer, so any application using ALSA will also work. – dirkt Jan 13 '17 at 11:35
  • PyAudio seem to be a Python binding for PortAudio. PortAudio doesn't seem to support Pulseaudio by default, but there is [software](https://github.com/bkgood/portaudio-pulseaudio) for that. I've never used PyAudio, nor PortAudio, so I can't tell you how well that works. What do you use the PyAudio for (i.e., what do you want to achieve in the end)? Would Python bindings for Pulseaudio or ALSA also work? – dirkt Jan 13 '17 at 11:37
  • It's for https://github.com/scottlawsonbc/audio-reactive-led-strip which uses PyAudio to read the audio stream. I will check the link you provided. Thank you. – user685336 Jan 13 '17 at 12:16
  • @user685336 Have you found a solution working with the reactive strip? I'm dealing with the same problem at the moment. – Ben Longo Nov 07 '17 at 04:25