Linux home sound system

Using the ALSA Sound System

This page summarises things I learned while trying to understand and use the Advanced Linux Sound Architecture (ALSA) on my Debian GNU/Linux system. I would be happy to receive suggestions to improve or extend this web page.

Configuration

This section gives some help with ALSA configuration issues. In order to avoid complications, we avoid use of external programs in figuring things out.

Is ALSA present in your kernel? Check for the presence of a /proc/asound/ directory. If the directory exists, you have ALSA support in your kernel. Why does program xyz not recognise my sound card? On current Linux systems there are several, partially conflicting ways to access the sound card: using ALSA (this is what we aim for here), using OSS (this is an older sound system, but still used by many programs), or by connecting to a sound daemon like esd or artsd (which in turn might use ALSA or OSS to connect to the system). Probably your program is trying to use the wrong method to play sound.

Programs using OSS can be used with ALSA by enabling the OSS compatibility layer of ALSA. You might need to load additional kernel modules to enable this. Check the file /dev/sndstat . If the file exists and can be read, you have the OSS compatibility layer enabled. It should list audio devices which correspond to the ALSA devices on your system.

Programs using esd can be used with ALSA by compiling esd with ALSA support.

What sound cards are known to the system? Check the contents of the /proc/asound/cards file. Each entry there corresponds to a (real or simulated) sound card. On my system I get the following:

0 [VirMIDI ]: VirMIDI - VirMIDI Virtual MIDI Card 1 1 [V8237 ]: VIA8237 - VIA 8237 VIA 8237 with ALC850 at 0x1000, irq 21 2 [Revolution51 ]: ICE1724 - M Audio Revolution-5.1 M Audio Revolution-5.1 at 0xb800, irq 16 3 [system ]: USB-Audio - iMic USB audio system Griffin Technology, Inc iMic USB audio .

Card 0 is a virtual MIDI card. It does not correspond to any hardware and I do not yet know what it is good for. Entry 1 is for the built-in sound hardware on my ASUS A8V main-board (since it has an interrupt, irq 19, assigned this one must be hardware). Card 2 is a M-Audio Revolution 5.1 card. Card 3 is a simple USB sound card (an iMic USB adapter), good for connecting a microphone and an external speaker.

What features do these sound cards have? There are several ways to find out. For example /proc/asound/devices contains an entry for every component of every device ALSA knows about. For the system described above I get

0: [ 0] : control 1: : sequencer 8: [ 0- 0]: raw midi 9: [ 0- 1]: raw midi 10: [ 0- 2]: raw midi 11: [ 0- 3]: raw midi 32: [ 1] : control 33: : timer 48: [ 1- 0]: digital audio playback 49: [ 1- 1]: digital audio playback 56: [ 1- 0]: digital audio capture 57: [ 1- 1]: digital audio capture 64: [ 2] : control 80: [ 2- 0]: digital audio playback 81: [ 2- 1]: digital audio playback 82: [ 2- 2]: digital audio playback 88: [ 2- 0]: digital audio capture 96: [ 3] : control 112: [ 3- 0]: digital audio playback 120: [ 3- 0]: digital audio capture

There are different groups of devices: control (used by the system to set the volume, mute channels, etc.), playback , capture (reading audio data into the computer), raw midi , sequencer and timer (I don’t know yet what the latter two do).

Читайте также:  Как восстановить рут пароль линукс

How do I set the default device? Create a configuration file (either for the whole system at /etc/asound.conf or .asoundrc in your home directory) containing statements like the following ones:

defaults.ctl.card 1 defaults.pcm.card 1 defaults.timer.card 1

This file would make card 1 the default. The card number (1 in this example) is taken from the /proc/asound/cards file. For a description of the ALSA configuration file format see the ALSA library API documentation.

Why does program xyz hang on start-up? Sound devices can be only opened by one program at a time. For example if you have the esd daemon running (it is often started automatically when you log into a GNOME desktop), other programs won’t be able to open the sound device simultaneously and might just silently wait until esd quits.

You can solve this problem by either stopping all other programs which access the sound device or by using one of the sound daemons and having all programs access the sound hardware through the daemon (the sound daemon can handle simultaneous connections from several programs).

Connecting a Microphone

In this section I give some hints on how a microphone can be connected to the computer to record sound using the ALSA interface.

How do I connect an analog microphone? Most sound-cards use 3.5mm mini-jack connectors. Make sure that your card has a separate microphone connector. If you want to connect a microphone via the line in connector, you will need an external amplifier. How do I connect a USB microphone? Just plug it into a USB port and make sure that you have USB sound support enabled in you kernel. Why do I record only silence? Use alsamixer to make sure that you selected your microphon input for capturing data (use the Capture view) and that the volume is up for both the microphone line and the capture device. Why is there a lot of noise and distorted sound in my recording? The built-in sound hardware which comes with most computers is not of high quality. For example the on-board sound hardware on my system (see above) always adds a lot of noise to any recordings from the microphone. Another problem could be the operational noise from your computer (ventilation etc.). Some programs can remove noise from recordings, but this is no real replacement for using good hardware. How do I record sound? Once you have a microphone successfully connected to your machine there are many programs to record sound. I tried ardour and it worked quite well.

Читайте также:  Линукс винда одном диске

Programs

Volume Control / Mixers

program version remarks
alsamixer 1.0.10 Text modus mixer. Works well. You can choose which sound card to use with the -c option.
aumix 2.8 Needs OSS emulation. Defaults to soundcard 0 (by using /dev/mixer by default. You can select a different mixer with the -d option.
GNOME
mixer applet
gnome-applets
2.12.2
Supports ALSA but ignores default soundcard setting (it uses card 1 in the system described above when the default is card 2). There is no way to manually make it use the correct card.
GNOME
settings daemon
gnome-control-center
2.12.2
This daemon is running while I am logged into GNOME and for some reason it keeps the device /dev/snd/controlC0 (the mixer of the virtual midi device) open all the time, presumably to preserve volume settings between logins. Whatever it is trying to do, it will not work by using this device.
GNOME
volume control
2.12.0 This allows selecting a sound device and remembers your settings. Ignores the ALSA default device setting.

Table 1. This table summarises the ALSA support of different mixers on a Debian GNU/Linux system.

Daemons / frameworks

program version remarks
esd Esound
0.2.36
The sound daemon currently used by the GNOME desktop environment. Can be compiled to work with ALSA.
gstreamer 2.12.0 Can be configured to use ALSA using gstreamer-properties . Works well.
jack 0.100.0 Uses ALSA by default. The daemon ignores the default device setting, but you can select a device manually.

Table 2. This table summarises the ALSA support of different sound daemons and frameworks on a Debian GNU/Linux system.

Applications

program version remarks
alsaplayer 0.99.76 Works well with ALSA (no surprise).
audacity 1.2.4 Uses OSS. When using the ALSA’s OSS emulation, the program insists on using card 0.
ardour 0.99 Uses JACK to connect to the sound hardware.
xmms 1.2.10 Can be configured to use ALSA (at the Audio I/O Plugins pane of the preferences window), works well.

Table 3. This table summarises the ALSA support of different applications on a Debian GNU/Linux system.

References

  • official ALSA site, containing the ALSA library API documentation
  • ALSA opensrc.org web site
  • Planet CCRMA at home sound package collection for Red Hat/Fedora systems.
  • Linux Audio Developer’s Simple Plugin API (LADSPA)

Copyright © 2011, Jochen Voss. All content on this website (including text, pictures, and any other original works), unless otherwise noted, is licensed under a Creative Commons Attribution-Share Alike 3.0 License.

Читайте также:  Линукс монтирование при загрузке

Источник

Sound system (Русский)

Состояние перевода: На этой странице представлен перевод статьи Sound system. Дата последней синхронизации: 8 августа 2020. Вы можете помочь синхронизировать перевод, если в английской версии произошли изменения.

Эта статья рассказывает о базовом управлении звуком. Для получения информации о более сложных темах см. статью Профессиональное аудио.

Общие сведения

Звуковая система Arch Linux состоит из нескольких уровней:

  • Драйверы и интерфейс — поддержка и взаимодействие с аппаратным обеспечением
  • Usermode API (библиотеки) — требуются и используются приложениями
  • (опционально) Звуковые серверы в пользовательском режиме — находят лучшее применение в сложных системах, требующих одновременной работы нескольких аудиоприложений и незаменимы для более продвинутых возможностей, например, профессионального аудио.
  • (опционально) Звуковые фреймворки — более высокоуровневые программные окружения, не связанные с серверными процессами

Базовая установка Arch Linux включает в себя звуковую систему ядра (ALSA), также можно установить множество утилит для управления ALSA из официальных репозиториев. Если требуются дополнительные возможности, вы можете сменить его на OSS или выбрать другой звуковой сервер.

Драйверы и интерфейс

  • ALSA — компонент ядра Linux, содержащий драйверы устройств и обеспечивающий наиболее низкоуровневую поддержку звукового аппаратного обеспечения.
  • Open Sound System (OSS) — альтернативная звуковая архитектура для Unix- и POSIX-совместимых систем. OSS 3-ей версии была основной звуковой системой Linux и включалась в ядро, но была заменена на ALSA в 2002 году, когда 4-ая версия OSS стала проприетарным ПО. OSSv4 вновь стала свободным ПО в 2007, когда 4Front Technologies опубликовали её исходные коды и разместили их под лицензией GPL. OSS не поддерживает такое же множество устройств как ALSA, но в некоторых случаях работает лучше.

Звуковые серверы

  • PulseAudio — очень популярный звуковой сервер, использующийся большинством современных приложений для Linux. Очень хорошо работает с несколькими одновременными потоками аудио и может использоваться по сети. Также PulseAudio легко настраивается — зачастую достаточно только установить пакет.

The factual accuracy of this article or section is disputed.

Reason: Описание JACK и JACK2 может быть некорректным согласно FAQ: what are the differences between JACK 1 and JACK2 (англ.), где сказано, что: «Jack 1 и Jack 2 — одинаковые реализации одного протокола». Также в FAQ рассматривается следующий вопрос: «Почему я должен предпочитать одно другому? Для большинства людей нет никакой разницы. Для других же обычно существует одна-две возможности, которые и влияют на выбор». См. FAQ (англ.) для получения более подробной информации. (Discuss in Talk:Sound system (Русский))

  • JACK Audio Connection Kit — более старая редакция звукового сервера, используемая в профессиональной работе со звуком, особенно когда требуется быстрый отклик при работе с записью, эффектами, синтезом в реальном времени и так далее. Хотя эта редакция и является старой, она сохраняет группу активных и преданных разработчиков, а многие проблемы удаётся решить путём проб и ошибок.
  • JACK2 — новая версия JACK, разработанная непосредственно для работы в мультипроцессорных системах и также включающая передачу данных по сети.
  • NAS — звуковой сервер, поддерживаемый некоторыми крупными приложениями.

Смотрите также

Источник

Оцените статью
Adblock
detector