Linux - Without hardware soundcard, capture audio playback, and record it to file
Asked Answered
A

3

14

Is such a thing even possible?

Is there a possibility to create a virtual sound card and then use for example PyAudio to listen to its output and save it to a file? NOTE that there is no hardware soundcard present on the machine.

I have tried a lot of things, especially snd-dummy ALSA module, but I am starting to doubt if I am looking for the right tools. I would be grateful if someone could point me towards at least high-level solution. Preferably something that would work on Ubuntu server.

Alis answered 15/10, 2016 at 16:7 Comment(0)
A
14

Thanks to both @mjy and @Matthias I have finally managed to figure out the minimal steps to take in order to make the recording work:

sudo apt-get install pulseaudio jackd2 alsa-utils dbus-x11

No need to play with snd-dummy, no need to create any additional config files... All these things only caused me to lose few hours :( After installing these packages on a clean Ubuntu server installation, I was able to run Python script and capture output audio to a file using PyAudio...

Alis answered 17/10, 2016 at 21:16 Comment(3)
You are the man & Saved me hours <3 -- a note: you can check that this answer is working by typing python3 -m sounddevice in a terminalByandby
Thanks! Was setting up baresip in debian netinst and ubuntu server and this worked like a charm. My error message was "alsa could not open auplay device 'default' (no such file or directory)" for contextSigma
This is a great solution!Contain
W
4

If the application producing the sound supports JACK, this should be easy. Then you only need to select the dummy driver for JACK and you can route the audio signal to any sound recording program you want (as long as it also supports JACK).

You'll need the package jackd, which has a command line interface for starting the JACK daemon. The package qjackctl provides a nice GUI for experimenting with different settings and for making audio connections between programs. For recording, you can try the program jack_rec which is part of jackd, but there are many other recording application for JACK available as well.

If you want to use Python for recording, you can try the sounddevice and soundfile modules. If you need some JACK-specific functionality, you should try jackclient-python.

Wittgenstein answered 16/10, 2016 at 8:7 Comment(1)
How would I know, whether the application supports JACK?Crossfertilize
T
1

Install the PulseAudio.

sudo apt install pulseaudio

PulseAudio has emulation for ALSA.

Tigress answered 15/10, 2016 at 17:5 Comment(3)
Could you provide some further information on said emulation?Reprehend
Emulation device will be created automatically. You probably will be able to record and play back in the ALSA emulation devices without setting.Tigress
already have pulse audio but how is this supposed to work?Benis

© 2022 - 2024 — McMap. All rights reserved.