audio

Audio unter Linux

Das Basis-Framework für Sound ist ALSA mit dem für die Soundkarte passenden Treiber. Moderne Linux Distros transportieren alle Audiodaten über den Pulseaudio Daemon als netzwerk-transparenten Datenstream. Daher kann der Pluseaudio Daemon auch auf entfernte Sound-Hardware im Netz zugreifen. Entsprechend kann man Audiodaten über ALSA oder Pulseaudio abgreifen und weiter verarbeiten. Pulseaudio abstrahiert die Audiodaten vollständig von der darunter liegenden Hardware:

Soundquelle → PulseAudio → ALSA-Treiber → Hardware

Dabei ist jedes Soundgerät entweder Quelle (Source) oder Senke (Sink) für Audiodaten.

Audio Debugging für OpenSUSE: https://en.opensuse.org/SDB:Audio_troubleshooting

Auflisten aller Mikrofone

arecord -l

odysseus3:~ # arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC289 Analog [ALC289 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: Dock [WD15 Dock], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 2: StudioTM [Microsoft® LifeCam Studio(TM)], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Aufnahme von einem bestimmten Mikrofone mit Alsa

arecord -f S16_LE -d 10 -r 16000 --device="hw:1,0" /tmp/test-mic.wav

Aufnahme mit Pulseaudio

Auflisten der Devices

pacmd list-sources | egrep '^\s+name:.*\.monitor'

Aufnehmen

parecord --channels=1 -d STREAM_NAME filename.wav

Auflisten der Quellen

pacmd list-sinks | egrep '^\s+name: .*alsa_output'

At a high level, here is what you are going to do:

  1. Create a “null” sink that you will be recording. Let’s call it recording.
  2. Create a combined sink that will send its input to both headphones and the recording sink. Otherwise, you will be able to record a stream but not hear it yourself. So, let’s call this sink combined.
  3. Direct the sound from the specific applications you want to record into the combined sink.
  4. Record the monitor of the recording sink to a file.

Find out the name of your output device by running

''pacmd list-sinks | egrep '^\s+name: .*alsa_output'''

In my case, it says

''name: <alsa_output.pci-0000_00_1f.3.analog-stereo>''

To create the two sinks, run these commands (you need to substitute the name of the output device that you learned on the previous step):

''pacmd load-module module-null-sink sink_name=recording sink_properties=device.description=recording
pacmd load-module module-combine-sink sink_name=combined sink_properties=device.description=combined \
  slaves=recording,alsa_output.pci-0000_00_1f.3.analog-stereo''

If you do this often, make it a permanent setup by creating the file ~/.config/pulse/default.pa with this contents (note that the long load-module command should be on a single line, don’t wrap it):

''.include /etc/pulse/default.pa
load-module module-null-sink sink_name=recording sink_properties=device.description=recording
load-module module-combine-sink sink_name=combined sink_properties=device.description=combined slaves=recording,alsa_output.pci-0000_00_1f.3.analog-stereo''

Now, redirect the sound to the combined sink:

  1. Run the pavucontrol command (a graphical window will appear) and go to the “Playback” tab.
  2. Start the application you’d like to record.
  3. The application should appear in pavucontrol. If it doesn’t, make sure the application produces some sound. Unfortunately, until the application tries to play something, PulseAudio cannot “see” it.

Quelle: https://ro-che.info/articles/2017-07-21-record-audio-linux

  • audio.txt
  • Zuletzt geändert: vor 2 Monaten
  • von thommie4