Linux sound: Difference between revisions
No edit summary |
|||
(27 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This page is about Linux sound system, including device, peripherals, hardware support. For information regarding audio applications, file formats, see [[Linux audio]]. |
|||
Sound / Audio in Linux seems to be a wild jungle. This page is an attempt to summarize the situation. |
|||
== References == |
== References == |
||
Line 7: | Line 7: | ||
* http://blogs.adobe.com/penguinswf/2007/05/welcome_to_the_jungle.html<br/>A dependency graph between all sound systems, frameworks, libraries, etc in Linux ([http://blogs.adobe.com/penguinswf/files/penguinswf/linuxaudio.png direct link]) |
* http://blogs.adobe.com/penguinswf/2007/05/welcome_to_the_jungle.html<br/>A dependency graph between all sound systems, frameworks, libraries, etc in Linux ([http://blogs.adobe.com/penguinswf/files/penguinswf/linuxaudio.png direct link]) |
||
* http://www.linux-sound.org/midi.html<br/>List of MIDI related softwares. Link seems dead, so here the [http://webcache.googleusercontent.com/search?q=cache:i2UoFGv0lKMJ:www.linux-sound.org/midi.html+gnome+midi&cd=4&hl=en&ct=clnk&gl=be&source=www.google.be Google cache link] |
* http://www.linux-sound.org/midi.html<br/>List of MIDI related softwares. Link seems dead, so here the [http://webcache.googleusercontent.com/search?q=cache:i2UoFGv0lKMJ:www.linux-sound.org/midi.html+gnome+midi&cd=4&hl=en&ct=clnk&gl=be&source=www.google.be Google cache link] |
||
* http://alsa.opensrc.org/Main_Page<br/>'''Unofficial''' wiki on ALSA. Lots of information. |
|||
** [http://alsa.opensrc.org/Hda-intel HDA-intel] |
|||
* http://www.alsa-project.org/main/index.php/Main_Page<br/>'''Official''' ALSA wiki. |
|||
** [http://www.alsa-project.org/main/index.php/Matrix:Module-hda-intel snd-hda-intel] module (used by Intel/nVidia) |
|||
* [http://seehuhn.de/pages/alsa Using the ALSA Sound System]<br/>Interesting post on using ALSA on Debian system, with lots of overview information. |
|||
* [http://wiki.linuxquestions.org/wiki/Main_Page LinuxQuestions.Org] also has many interesting reference information on Linux sound system |
|||
** [http://wiki.linuxquestions.org/wiki/Jack Jack] |
|||
** [http://wiki.linuxquestions.org/wiki/GStreamer GStreamer] |
|||
** [http://wiki.linuxquestions.org/wiki/Open_Sound_System OSS] (only v3 apparently) |
|||
** [http://wiki.linuxquestions.org/wiki/ALSA ALSA] |
|||
== Guides == |
|||
To summarize: |
|||
* http://slack4dummies.blogspot.be/2012/02/alsa-multiple-output-multiple-sound.html |
|||
== Landscape == |
== Landscape == |
||
Line 41: | Line 55: | ||
** Old sound system For Gnome/GTK environment |
** Old sound system For Gnome/GTK environment |
||
** Main goal was to cope with lack of SW mixing layer in OSS. |
** Main goal was to cope with lack of SW mixing layer in OSS. |
||
== Pulseaudio == |
|||
See [[Pulseaudio]]. |
|||
== ALSA / OSS == |
== ALSA / OSS == |
||
Line 100: | Line 117: | ||
** PulseAudio interfers with TiMIDity |
** PulseAudio interfers with TiMIDity |
||
** Try to play MIDI with ''kmid'' first (not ''kmidi'' !!!). If it plays, then it should play fine in NtEd as well. |
** Try to play MIDI with ''kmid'' first (not ''kmidi'' !!!). If it plays, then it should play fine in NtEd as well. |
||
On ALSA: |
|||
* Check [http://alsa.opensrc.org/PlayingMIDIFiles ALSA page] dedicated to playing MIDI |
|||
* In particular, to play using a software synthesizer, use either ''TiMIDity'' or ''FluidSynth''. |
|||
* One can also use ''gt'' utility to play MIDI files in surround sound. |
|||
On gStreamer: |
|||
* http://linuxtechie.wordpress.com/2008/02/29/gstreamer-plugins-bad-now-offers-midi-plugin/ |
|||
* http://linuxtechie.wordpress.com/2008/01/22/how-to-ubuntu-midi-playback-with-audacious/ (related post) |
|||
Line 106: | Line 134: | ||
: TiMidity++ is a software synthesizer. It can play MIDI files by converting them into PCM waveform data; give it a MIDI data along with digital instrument data files, then it synthesizes them in real-time, and plays. It can not only play sounds, but also can save the generated waveforms into hard disks as various audio file formats. |
: TiMidity++ is a software synthesizer. It can play MIDI files by converting them into PCM waveform data; give it a MIDI data along with digital instrument data files, then it synthesizes them in real-time, and plays. It can not only play sounds, but also can save the generated waveforms into hard disks as various audio file formats. |
||
: Note that according to ''NtEd'' FAQ, ''PulseAudio'' creates bad interference with TiMIDity. |
: Note that according to ''NtEd'' FAQ, ''PulseAudio'' creates bad interference with TiMIDity. |
||
<source lang=bash> |
|||
sudo apt-get install timidity |
|||
timidity /home/data/d/documents/desktop/_tidymeuprestricted/Ghostbusters.mid # Play a MIDI file |
|||
timidity -iA -B2,8 -Os1l -s 44100 # Run as MIDI server |
|||
</source> |
|||
; [http://developer.kde.org/~larrosa/kmid.html KMid] |
; [http://developer.kde.org/~larrosa/kmid.html KMid] |
||
:Mid is a X11 / KDE based midi player for Linux and FreeBSD. KMid displays the text of karaoke files and change its colour as it is being played so that the tune can be easily followed ! It uses /dev/sequencer as output device supporting external synths, AWE , GUS and now also FM cards (such as sb16 or sbpro). |
:Mid is a X11 / KDE based midi player for Linux and FreeBSD. KMid displays the text of karaoke files and change its colour as it is being played so that the tune can be easily followed ! It uses /dev/sequencer as output device supporting external synths, AWE , GUS and now also FM cards (such as sb16 or sbpro). |
||
; [http://wildmidi.sourceforge.net/?id=about WildMidi |
; [http://wildmidi.sourceforge.net/?id=about WildMidi] |
||
: A GStreamer plugin to play MIDI files. Works fine along with ''RhythmBox'' for instance. |
: A GStreamer plugin to play MIDI files. Works fine along with ''RhythmBox'' for instance. |
||
; [http://ict.ewi.tudelft.nl/~erik/open-source/musica/ Musica MIDI player] |
|||
: Play MIDI on system with OSS sound card interface |
|||
; [http://sourceforge.net/apps/trac/fluidsynth/ FluidSynth] |
|||
:FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications. |
|||
=== Typesetting software === |
=== Typesetting software === |
||
; [http://lilypond.org/ LilyPond] |
; [http://lilypond.org/ LilyPond] |
||
:LilyPond is a music engraving program, devoted to producing the highest-quality sheet music possible. It brings the aesthetics of traditionally engraved music to computer printouts. LilyPond is free software and part of the GNU Project. |
:LilyPond is a music engraving program, devoted to producing the highest-quality sheet music possible. It brings the aesthetics of traditionally engraved music to computer printouts. LilyPond is free software and part of the GNU Project. |
||
== Devices == |
|||
;<tt>/dev/snd</tt> |
|||
:<tt>/dev/snd</tt> is the audio device when using ALSA |
|||
;<tt>/dev/dsp</tt> |
|||
:<tt>/dev/dsp</tt> is the audio device when using OSS |
|||
<source lang=bash> |
|||
lsof +D /dev/snd # Show which processes are using the device |
|||
</source> |
|||
== Metronomes == |
|||
=== Gtick === |
|||
Gnome application. Easy to setup, but not very synchronous. |
|||
=== Kmetronome === |
|||
Advanced MIDI based metronome. Requires a MIDI server. |
|||
First launch the server, for instance: |
|||
<source lang=bash> |
|||
timidity -iA -B2,8 -Os1l -s 44100 |
|||
</source> |
|||
Then start <code>kmetronome</code>. |
|||
* Go into settings and select a MIDI server (''Output port connection'' → ''TiMidity:0''). |
|||
* Select a MIDI bank (''Output instrument → General MIDI'' or anything else). |
|||
To play a standard metronome click, select ''Roland GS''. Then in the pattern editor, select ''Metronome Click'' as Drum Key. |
|||
== Tips == |
|||
=== ALSA in multi-user, multi-card === |
|||
See this excellent post: [http://slack4dummies.blogspot.be/2012/02/alsa-multiple-output-multiple-sound.html] |
|||
Also: [http://www.fail2fail.com/index.php?archives/22-English.html&serendipity%5Blang_selected%5D=en] |
|||
=== ALSA through HDMI === |
|||
See [[XBMC]]. |
|||
== Troubleshoot == |
|||
=== References === |
|||
* http://doc.ubuntu-fr.org/audio_intel_hda |
|||
* https://help.ubuntu.com/community/HdaIntelSoundHowto |
|||
=== Sound Issues in Linux === |
|||
reference: [https://help.ubuntu.com/community/SoundTroubleshooting SoundTroubleshooting on ubuntu.com]. |
|||
Troubleshooting Alsa: |
|||
<source lang=bash> |
|||
sudo aplay /usr/share/sounds/alsa/Front_Center.wav # Play a file as root |
|||
aplay /usr/share/sounds/alsa/Front_Center.wav # If it works, try as yourself |
|||
sudo addgroup <username> audio # ... add yourself to 'audio' group if you can't play the file |
|||
# But DON'T ADD TO 'audio' group if you are using PulseAudio! |
|||
sudo aplay -l # List all possible HW devices |
|||
sudo aplay -L # List all possible PCM devices (software devices) |
|||
lspci -v | grep -A7 -i "audio" # List all devices recognized as audio devices |
|||
aplay -D "plughw:0,7" /usr/share/sounds/alsa/Front_Center.wav # Play on a specific device (HW or PCM) |
|||
mplayer -ao alsa:device=hw=0 /usr/share/sounds/alsa/Front_Center.wav # Other way to play on a specific HW device (bypassing Alsa) |
|||
</source> |
|||
;audio group |
|||
:On Debian and Ubuntu systems, ''there should be no users in the audio group'' [https://wiki.ubuntu.com/Audio/TheAudioGroup] |
|||
=== Top Five Wrong Ways to Fix Your Audio === |
|||
See http://voices.canonical.com/david.henningsson/2012/07/13/top-five-wrong-ways-to-fix-your-audio/ |
|||
=== Install jackd === |
|||
See http://doc.ubuntu-fr.org/jackd. Nice advice on setting up audio, detecting audio issues. |
|||
=== Under-run when using play command === |
|||
Trying to play a (small) sound file, we get no sound but a warning <code>play WARN alsa: under-run</code>. Add option <code>--single-threaded</code> does not help. |
|||
<source lang=bash> |
|||
play --single-threaded /usr/share/games/xboard/sounds/woodthunk.wav |
|||
# /usr/share/games/xboard/sounds/woodthunk.wav: |
|||
# |
|||
# File Size: 1.89k Bit Rate: 182k |
|||
# Encoding: Unsigned PCM |
|||
# Channels: 1 @ 8-bit |
|||
# Samplerate: 22255Hz |
|||
# Replaygain: off |
|||
# Duration: 00:00:00.08 |
|||
# |
|||
# In:100% 00:00:00.08 [00:00:00.00] Out:1.84k [!=====|=====!] Clip:0 |
|||
# Done. |
|||
# play WARN alsa: under-run |
|||
</source> |
|||
The solution is to use <code>paplay</code>! |
|||
<source lang="bash"> |
|||
paplay /usr/share/games/xboard/sounds/woodthunk.wav |
|||
</source> |
Latest revision as of 12:12, 1 June 2020
This page is about Linux sound system, including device, peripherals, hardware support. For information regarding audio applications, file formats, see Linux audio.
References
- http://insanecoding.blogspot.com/2007/05/sorry-state-of-sound-in-linux.html
A summary of the situation back in the year 2007. - http://insanecoding.blogspot.com/2009/06/state-of-sound-in-linux-not-so-sorry.html
Same but updated to situation in 2009. A well of information! - http://4front-tech.com/hannublog/?p=5
Blog post explaining why closed source OSS is better than Alsa (back in 2007). - http://blogs.adobe.com/penguinswf/2007/05/welcome_to_the_jungle.html
A dependency graph between all sound systems, frameworks, libraries, etc in Linux (direct link) - http://www.linux-sound.org/midi.html
List of MIDI related softwares. Link seems dead, so here the Google cache link - http://alsa.opensrc.org/Main_Page
Unofficial wiki on ALSA. Lots of information. - http://www.alsa-project.org/main/index.php/Main_Page
Official ALSA wiki.- snd-hda-intel module (used by Intel/nVidia)
- Using the ALSA Sound System
Interesting post on using ALSA on Debian system, with lots of overview information. - LinuxQuestions.Org also has many interesting reference information on Linux sound system
Guides
To summarize:
Landscape
Here a summary of usual names we find in the Linux sound jungle along with their meaning/roles.
The sound systems (the real stuff that interface with the sound card. Today no apps should use these API directly but instead use one of the simple wrapper instead):
- OSS v3 — Open Sound System
- The original sound system on Linux, derived from the Sound Blaster driver API.
- The main limitation of OSS is that there was no software mixer (mixing was done by the soundcard) and so if your sound card did not support mixing in HW, then only one application could generate sounds.
- Closed Source
- OSS v4
- Open source again
- Full support of mixing
- Better latency (done in kernel)
- ALSA — Advanced Linux Sound Architecture
- A new sound system for Linux, including new set of API, kernel modules, etc.
- Support SW mixing
- Created after OSS went closed source
- Provide an OSS emulation layer for applications that still requires OSS
- Many advantages but many drawback as well (like OSS emulation does not support mixing, requires many additional lib like alsa-lib or jack)
The wrapper libraries (to support any sound back-end API, i.e. OSS/ALSA):
- SDL — Simple DirectMedia Layer
- Wrapper around OSS, aRTS and ESD.
- To allow running at the same applications that uses OSS, aRTS or ESD.
- OpenAL
- libao
The sound servers (Add mixing, considered useless today and adds lot of latency on top of the OSS/ALSA back-end):
- aRTS — Analog Real Time Synthesizer
- Old sound system for KDE environment
- Main goal was to cope with lack of SW mixing layer in OSS.
- ESD — Enlightened Sound Daemon
- Old sound system For Gnome/GTK environment
- Main goal was to cope with lack of SW mixing layer in OSS.
Pulseaudio
See Pulseaudio.
ALSA / OSS
ALSA
3 components:
- Drivers in the kernel
- Sound developer API
- Sound mixing component
Pros:
- Optional sound mixing outside the kernel
- Alsa support OSS v3 emulation
Cons:
- OSS v3 emulation has no mixing outside kernel (i.e. no mixing for old or other Unix'es apps when HW does not support mixing)
- Linux only (i.e. SW written to support other Unix'es will likely be written for OSS
- API too hard to work with
OSS
Now at version 4.
Pros:
- Sound mixing always supported
- Mixing in the kernel (so no latency issues)
Cons:
- Very bad ALSA emulation (but ALSA sound developer API can output to OSS directly, hence providing perfect ALSA compatibility).
Summary
- Both sound systems can output to either ALSA / OSS kernel back-ends.
- OSS back-end always has good sound, except when using OpenAL->ALSA to output to it.
- ALSA generally sounds better when using the OSS API, and has lower latency (generally because that avoids any sound mixing as per an earlier diagram).
- OSS related technology is generally the way to go for best sound.
- No application should use these APIs directly, but should use one of the light library wrapper instead.
Music Score Editors
Applications
Some music score editors in Linux:
- Frescobaldi
- Frescobaldi is a LilyPond sheet music text editor for KDE4. It aims to be powerful, yet lightweight and easy to use.
- Canorus
- Canorus is a free extensible music score editor. It supports note writing, import/export of various file formats, MIDI input and output, scripting and more! Using a Qt4 framework Canorus offers a fast and modern GUI and cross-platformability. Canorus runs on Linux, Windows and MacOSX.
- NoteEdit
- NoteEdit is a free music score editor for Linux. It supports an unlimited number and length of staffs, polyphony, a MIDI playback of written notes, chord markings, lyrics, a number of import and export filters to many formats like MIDI, MusicXML, ABC Music, MUP, PMX, MusiXTeX and LilyPond and more!
- MusE
- MusE is a MIDI/Audio sequencer with recording and editing capabilities written originally by Werner Schweer now developed and maintained by the MusE development team. MusE aims to be a complete multitrack virtual studio for Linux, it is published under the GNU General Public License.
- Rosegarden
- Rosegarden is a well-rounded audio and MIDI sequencer, score editor, and general-purpose music composition and editing environment. Rosegarden is an easy-to-learn, attractive application that runs on Linux, ideal for composers, musicians, music students, and small studio or home recording environments.
- MuseScore
- MuseScore is a free cross-platform WYSIWYG music notation program, that offers a cost-effective alternative to professional programs such as Sibelius and Finale. You can print beautifully engraved sheet music or save it as PDF or MIDI file.
- NtEd]
- NtEd is a GTK+ score editor. It intends to be really WYSIWYG: what you see on the screen is exactly what you get on printer output. It supports up to 4 voices per staff, drum notes, 5 lyrics lines, N-Tuplets, context changes, repeats with alternatives, configurable music instruments per staff, MIDI / MusicXML import, PS / PDF / SVG / PNG / Lilypond / MIDI export. Scores can be played through the ALSA sequencer.
Playing Midi
Information:
- Check NtEd FAQ for some links on how to play MIDI in score editors.
- PulseAudio interfers with TiMIDity
- Try to play MIDI with kmid first (not kmidi !!!). If it plays, then it should play fine in NtEd as well.
On ALSA:
- Check ALSA page dedicated to playing MIDI
- In particular, to play using a software synthesizer, use either TiMIDity or FluidSynth.
- One can also use gt utility to play MIDI files in surround sound.
On gStreamer:
- http://linuxtechie.wordpress.com/2008/02/29/gstreamer-plugins-bad-now-offers-midi-plugin/
- http://linuxtechie.wordpress.com/2008/01/22/how-to-ubuntu-midi-playback-with-audacious/ (related post)
Some software:
- TiMIDity++
- TiMidity++ is a software synthesizer. It can play MIDI files by converting them into PCM waveform data; give it a MIDI data along with digital instrument data files, then it synthesizes them in real-time, and plays. It can not only play sounds, but also can save the generated waveforms into hard disks as various audio file formats.
- Note that according to NtEd FAQ, PulseAudio creates bad interference with TiMIDity.
sudo apt-get install timidity
timidity /home/data/d/documents/desktop/_tidymeuprestricted/Ghostbusters.mid # Play a MIDI file
timidity -iA -B2,8 -Os1l -s 44100 # Run as MIDI server
- KMid
- Mid is a X11 / KDE based midi player for Linux and FreeBSD. KMid displays the text of karaoke files and change its colour as it is being played so that the tune can be easily followed ! It uses /dev/sequencer as output device supporting external synths, AWE , GUS and now also FM cards (such as sb16 or sbpro).
- WildMidi
- A GStreamer plugin to play MIDI files. Works fine along with RhythmBox for instance.
- Musica MIDI player
- Play MIDI on system with OSS sound card interface
- FluidSynth
- FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications.
Typesetting software
- LilyPond
- LilyPond is a music engraving program, devoted to producing the highest-quality sheet music possible. It brings the aesthetics of traditionally engraved music to computer printouts. LilyPond is free software and part of the GNU Project.
Devices
- /dev/snd
- /dev/snd is the audio device when using ALSA
- /dev/dsp
- /dev/dsp is the audio device when using OSS
lsof +D /dev/snd # Show which processes are using the device
Metronomes
Gtick
Gnome application. Easy to setup, but not very synchronous.
Kmetronome
Advanced MIDI based metronome. Requires a MIDI server.
First launch the server, for instance:
timidity -iA -B2,8 -Os1l -s 44100
Then start kmetronome
.
- Go into settings and select a MIDI server (Output port connection → TiMidity:0).
- Select a MIDI bank (Output instrument → General MIDI or anything else).
To play a standard metronome click, select Roland GS. Then in the pattern editor, select Metronome Click as Drum Key.
Tips
ALSA in multi-user, multi-card
See this excellent post: [1] Also: [2]
ALSA through HDMI
See XBMC.
Troubleshoot
References
Sound Issues in Linux
reference: SoundTroubleshooting on ubuntu.com.
Troubleshooting Alsa:
sudo aplay /usr/share/sounds/alsa/Front_Center.wav # Play a file as root
aplay /usr/share/sounds/alsa/Front_Center.wav # If it works, try as yourself
sudo addgroup <username> audio # ... add yourself to 'audio' group if you can't play the file
# But DON'T ADD TO 'audio' group if you are using PulseAudio!
sudo aplay -l # List all possible HW devices
sudo aplay -L # List all possible PCM devices (software devices)
lspci -v | grep -A7 -i "audio" # List all devices recognized as audio devices
aplay -D "plughw:0,7" /usr/share/sounds/alsa/Front_Center.wav # Play on a specific device (HW or PCM)
mplayer -ao alsa:device=hw=0 /usr/share/sounds/alsa/Front_Center.wav # Other way to play on a specific HW device (bypassing Alsa)
- audio group
- On Debian and Ubuntu systems, there should be no users in the audio group [3]
Top Five Wrong Ways to Fix Your Audio
See http://voices.canonical.com/david.henningsson/2012/07/13/top-five-wrong-ways-to-fix-your-audio/
Install jackd
See http://doc.ubuntu-fr.org/jackd. Nice advice on setting up audio, detecting audio issues.
Under-run when using play command
Trying to play a (small) sound file, we get no sound but a warning play WARN alsa: under-run
. Add option --single-threaded
does not help.
play --single-threaded /usr/share/games/xboard/sounds/woodthunk.wav
# /usr/share/games/xboard/sounds/woodthunk.wav:
#
# File Size: 1.89k Bit Rate: 182k
# Encoding: Unsigned PCM
# Channels: 1 @ 8-bit
# Samplerate: 22255Hz
# Replaygain: off
# Duration: 00:00:00.08
#
# In:100% 00:00:00.08 [00:00:00.00] Out:1.84k [!=====|=====!] Clip:0
# Done.
# play WARN alsa: under-run
The solution is to use paplay
!
paplay /usr/share/games/xboard/sounds/woodthunk.wav