nixers
Audio and music on Unix - Printable Version
+- nixers (https://nixers.net)
+-- Forum: Desktop Customization, Efficiency, and Aesthetics (https://nixers.net/Forum-Desktop-Customization-Efficiency-and-Aesthetics)
+--- Forum: Desktop Customization & Workflow (https://nixers.net/Forum-Desktop-Customization-Workflow)
+--- Thread: Audio and music on Unix (/Thread-Audio-and-music-on-Unix)
Pages: 1 2


Audio and music on Unix - venam - 23-10-2015

Hello fellow nixers,
In this thread we'll discuss the general topic of audio, music, and audio
manipulation on Unix.

We'll try to assess its state and share experiences and problems.


NB: This was supposed to be a podcast topic but the podcast has been dead for the
past 4-5 weeks.


#Configuring the audio

Configuring the audio on Unix can be difficult depending on what OS and driver
you are using.

On Linux Alsa and the legacy OSS (open sound system) are available).
Both are kernel driven sound card drivers and thus are loaded by your init
system or deamon manager.

Consequently, everything that can affect the init system might create a problem
with the driver.

Alsa can be configured via the asound.conf or asoundrc files where you can specify specific
sound card configurations.

Testing and manipulating the audio for alsa is done with:

```
Code:
alsamixer #volume
alsaequal-mgr #Save and restore named alsaequal states
speaker-test -c 2 #test the speakers
aplay -l #list devices
and all the alsa* utilities
```


The advantages of using OSS:

You'll have a per-application volume control, some legacy cards have better
support, it is cross platform (runs on BSDs and Solaris),
has a smaller and easier to use API.

The advantages of using ALSA:

You'll have better support for USB, bluetooth, HD audio devices, and all other
funky hardware you can find.


Personal note:

Sound output from HDMI caused me troubles in the past the solution was a messy
script.
For more information consult this link.


Configuring the sound on BSD variants differs from distro to distro.

I won't enter the subject but for example NetBSD has the `audioctl` commands
to set audio configurations and FreeBSD the `sysctl` to set the kernel state.


#Pulseaudio

Pulseaudio is a sound proxy application that gives and interface to the lower
layer to other applications.
[Image: 1000px-Pulseaudio-diagram.svg.png]

It can detect the devices and automatically configure them (or we hope so).

You can control all the lower layers from pulseaudio.
It offers a sound equalizer loaded with:

Code:
$ pactl load-module module-equalizer-sink
$ pactl load-module module-dbus-protocol
$ pactl - cli

It has many frontends.


#Codecs

Quote:A codec is a device or computer program capable of encoding and/or decoding a digital data stream or signal.

Media players need to know how to decode the audio to play it. Audio files have
multiple formats and codec libraries are there to give those programs a way to
understand them.

Some said that one of the reasons they won't use a Linux Libre kernel was that
it wouldn't support all codecs. It is partially true, libre kernels offers free
versions of most codecs.

I'm using a Libre kernel and didn't run into any issues related to
codecs so far.


#PC BEEP


If you're a Unix users you're obviously knowledgeable about beeps.

A PC beep is a sound, usually used as warning when the ram isn't in place for
example, that comes straight from the motherboard and not the speaker (although
it depends on the computer manufacturer and the components).

The beep can be muted from multiple places, the audio driver (alsa, oss, and others),
from the console (TTY), in the X11 environment, in the kernel, and at boot time.

On Linux it's loaded via the pcspkr module
Code:
rmmod pcspkr


A cross platform way, but only in X is `xset -b`.

There are programs used to play with the frequency of the beep such as
the program `beep`.

You can find scripts to play music using the motherboard speaker.

If you are even more of a beep amateur you've certainly heard of chiptunes.

`sidplay2` is a program that emulates the commodore 64 to play music.

Quote:Sidplay is SID-chip emulator for playing Commodore 64 music.


#Music Player - Music tagging


There are ton of music players.
You have the choice between curses interface and gui.
Choice between those that have a daemon interfaces and others that play the music directly.

mplayer, mpd, xmms2, cmus, cplay, deadbeef, amarok, clementine, are common names.

-

Music files have metadata about authors, album, etc..

Unix has different tools to edit those information, they go by the name of tageditors:
  • tagtool
  • easytag
  • mp3info
  • exfalso - audio tag editor for GTK+
  • kid3 - KDE MP3 ID3 tag editor
  • puddletag - simple, powerful audio tag editor


And if you want to add a party ambiance you can use music visualizers, which are
programs that us a fast fourier transform to create
amazing shapes and forms that move around with the music.

If it's not built in your music player you can use ProjectM or VSXu.


#Music/Sound Editing - Converting


After my research I was surprised that there was so many programs available for
sound editing on Unix.

I haven't tried them all but I've read good reviews about some.

A list of interesting ones:
  • ardour - digital audio workstation (graphical gtk2 interface)
  • ardour3 - digital audio workstation (graphical gtk2 interface)
  • audacity - fast, cross-platform audio editor
  • sweep - Audio editor and live playback tool
  • mhwaveedit - Simple and fast GTK2 sound editor
  • nama - Ecasound-based multitrack recorder/mixer
  • pitivi - non-linear audio/video editor using GStreamer
  • rosegarden - music editor and MIDI/audio sequencer
  • rosegarden-dbg - Debugging symbols for Rosegarden
  • swami - MIDI instrument editor application
  • swami-dbg - MIDI instrument editor - debugging symbols
  • wav2cdr - Converts wav files into CD-ROM audio file format
  • cecilia - Sound synthesis and audio signal processing environment
  • kwave - sound editor for KDE
  • milkytracker - music creation tool inspired by Fast Tracker 2
  • muse - Qt4-based audio/MIDI sequencer
  • pitivi - non-linear audio/video editor using GStreamer
  • rosegarden - music editor and MIDI/audio sequencer
  • snd-gtk-pulse - Sound file editor (GTK+ user interface - PulseAudio)
  • traverso - Multitrack audio recorder and editor
  • xsynth-dssi - classic-analog (VCOs-VCF-VCA) style software synthesizer

Or you could go real hardcore like this dude and
create music by writing C programs to generate the sound.

For spectrum analysis I'd use sonic visualisers.


#TTS - Voice recognition(STT)

Text to speech and voice recognition is an area that is poor in the Unix community.

However, it's not only the Unix community that is lacking support for those.
All the softwares that have a "natural feel" are proprietary and costly. They are sold to mobile operators.

I've tried my share of them and will only retain one thing: festival is the best
text to speech available on Unix even though it's hard to setup and you have to
search for voice files on the web.

As far as voice recognition goes I've also tried a few but none of them worked
correctly and they were all insanely complex to setup. Sphinx is hell to understand.


I hope this covers a general topic on audio and music on Unix.


Now it's time for you to share your stories and experiences.


RE: Audio and music on Unix - chc4 - 23-10-2015

I've been using cmus for music, and it works pretty damn well. It's nice and clean looking, along with not being complex to use. Just using ALSA though, because pulseaudio is still a buggy mess like 10 years after it was supposed to replace ALSA...

I just load up podcasts and stuff in mpv instead though, so I don't keep the files around after I listen to them.


RE: Audio and music on Unix - Wildefyr - 23-10-2015

Also been using just alsa recently.. I think I will have to install pulse on my crux install however because on of my applications (teamspeak3) grabs the audio output entirely and won't allow any other programs to use the audio device (/dev/dsp). Doesn't seem to be any solution when using pure alsa.


RE: Audio and music on Unix - Houseoftea - 23-10-2015

http://tedfelix.com/linux/linux-midi.html

Great write up venam, thought I should add the link above to this thread, its got a lot of good info on it if a little outdated.

Soon I'm gonna be setting up a midi keyboard so I hope that goes well, if I learn anything I'll post it here


RE: Audio and music on Unix - ninjacharlie - 23-10-2015

Nice breakdown of the options, venam. Gonna have to look into some of the audio editors.

I've been rolling with ALSA (plz kill pulseaudio... as well as systemd and anything else that Poettering touches), mopidy for music daemon, since it supports Spotify, and ncmpcpp + mpc for music control. Recently added sxhkd bindings so that the play button on my keyboard makes mopidy start/stop my starred playlist :)


RE: Audio and music on Unix - darthlukan - 24-10-2015

I keep it simple: ALSA + mpd + mpc. I've no need for other stuff so I haven't dug into other sound options for over a decade.


RE: Audio and music on Unix - pranomostro - 24-10-2015

@venam:
You could also mention ogg123/ogg122/mpg123/mpg321. They are very nice minimal music players, but working
perfectly if you are organizing your music in other ways. I also like to use ffmpeg to convert different
audio and video formats.


RE: Audio and music on Unix - z3bra - 24-10-2015

I've been trying hard, but audio still is deep magic to me, eg: .asoundrc. I genuinely think there is no doc abojt it, and that no one except *some* ALSA devs can actually understand how it works (they're the ones posting snippets on forums).

I've never managed to get a fully working microphone by myself, even if I know it can actually be decent (ubuntu proved it!)

For the music playing part though, Ive tried many things. mpg123 /ogg123 are nice, but too limited in terms of format. my best choice is sox to play music:

Code:
$ play rick_ashley-never_gonna_give_you_up.ogg
$ play rhcp/californication/*.ogg
$ more playlist.txt | xargs play
$ shuf playlist.txt | xargs play
$ curl -s http://radio.2f30.org/live.ogg:8000 | play -

That's really all I need :)


RE: Audio and music on Unix - apk - 25-10-2015

I used sndio a couple times, its not too bad.




Thats all I got to say in regards to audio.


RE: Audio and music on Unix - kirby - 27-10-2015

I just use as little ALSA as I can get away with and cmus. I always find configuring it a pain but once it's done it's done.

This reminds me of a problem I unsuccessfully tried to solve once, so I might as well ask here for some discussion. Is there a program that allows me to host my own music server and connect to it from various clients? I know of mpd but it wasn't really what I was looking for (though admittedly I didn't spend ages with it, so maybe there's some config to it), it was a massive pain to get sound coming out of the client machine and not the server, and when listening to songs I just tend to pick what I want as I want it, so being coerced into making a playlist each time was a bit annoying. Basically I just want all my music on one remote machine and a cmus-like interface whenever I need it.


RE: Audio and music on Unix - Wildefyr - 28-10-2015

Gonna have to move to pulseaudio sadly... Would prefer a more minimum sound setup but when using teamspeak3 it grabs the entire audio output, or if audio is currently being used, has no sound output at all. Searched heavily but there doesn't seem to be a solution other than using pulseaudio >:|


RE: Audio and music on Unix - z3bra - 29-10-2015

Just use mumble instead :)


RE: Audio and music on Unix - darthlukan - 29-10-2015

@Wildfyr - ALSA requires dmix / software mixing to handle multiple audio streams at once. I'll load up my .asoundrc after work so you can see how I had to set it up (based on info from the Arch Wiki). Hopefully it will help you out.


RE: Audio and music on Unix - Wildefyr - 29-10-2015

(29-10-2015, 07:29 AM)z3bra Wrote: Just use mumble instead :)

If I had a penny every time someone mentioned this I would be rich.

@darth thanks, alsa confuses the hell outta me.


RE: Audio and music on Unix - z3bra - 29-10-2015

Maybe you should git it a go then? There might be a reason people mention it so often


RE: Audio and music on Unix - Wildefyr - 29-10-2015

The problem is that all my windows friends use teamspeak only and I've found getting people (especially non tech people) to use teamspeak is loads easier than getting them to use mumble.


RE: Audio and music on Unix - venam - 06-11-2015

Here's an answer to a question I've always wondered about:
Quote:Some audio output from files or streams is too low. It is obvious that hardware is able to play the same sounds but louder but because of the data it just plays it at some low level even at 100% volume. Vlc can generally increase the volume of a file up to 200%. Is there a way to do the same thing VLC does system-wide and if possible for an arbitrary v percentage value.
http://superuser.com/questions/146784/sound-volume-increase-beyond-100-whenever-possible-on-linux


RE: Audio and music on Unix - z3bra - 06-11-2015

I wonder if such a thing is possible without pulseaudio


RE: Audio and music on Unix - venam - 11-11-2015

If you have any stories with issues concerning the audio on Unix please bump this thread with it.
Gathering a source of horror posts can be fun.


RE: Audio and music on Unix - ChefIronBelly - 13-11-2015

In NetBSD I was using default sound 'OSS' with mpg123/sox for cli and and cmus for a curses interface. I should add that worked out of the box with my hardware on 3 different machines.

Today decided to tackle mpd + mpc (after catching a glimpse of a character who lurks in the shadows carrying sharp pointed metal objects)

Well mpd didn't work out of the box so I RTFM. Read the conf for maybe a clue to what was missing or which option was specific to my machine. A clue was given so off to see what the format of the device line. The NetBSD wiki had one reference to pulse-audio and mpd ugh. Oh the games we play the tests we take, long story short pieced together the answer from a few sources.

Code:
audio_output {
    type        "oss"
    name        "LibAO-OSS"
#       device        "@DEVOSSAUDIO@"
    device        "/dev/audio" # changed default or /dev/sound
}

And we are off and running.


RE: Audio and music on Unix - venam - 03-04-2016

Here's my new audio horror story on Unix.

I bought a usb headset (headphone+microphone) yesterday.
I plug it in and it doesn't magically work so I dive into documentation and online posts.
Pavucontrol popped up, it is an application that let you interface with pulseaudio. It didn't work on my Arch machine and I decided to give it a try on my Debian box. It worked flawlessly.
After doing a diff of the pulse configuration files I found my issue, that's what worked for me:
Code:
http://pub.iotek.org/p/vEOlSe3
[+] Uploaded file client.conf
http://pub.iotek.org/p/YxGaVtP
[+] Uploaded file daemon.conf
http://pub.iotek.org/p/YvLFHBI
[+] Uploaded file default.pa
http://pub.iotek.org/p/fBmZTsU
[+] Uploaded file default.pa.pacnew
http://pub.iotek.org/p/7m4JbNr
[+] Uploaded file system.pa
It also automatically switches to the usb headset when connected.

But there was still an issue I couldn't hear any sound as a normal user. I was firing mplayer to test the audio and after hours of debugging the .mplayer/config had this faulty line:
Code:
ao=alsa
I swapped alsa by pulse and this solved it.

Next on the list: MPD wasn't using my pulse configuration. As "I discovered in the manual", mpd lauches it's own instance of pulse when started as a global daemon and thus I had to switch from a global to a local setting.

Done... Still no sound.

I rechecked my .mpdconfig over and over again trying weird things that made no sense to finally find my issue:
Code:
audio_output {
    type                    "fifo"
    name                    "my_fifo"
    path                    "/tmp/mpd.fifo"
    format                  "44100:16:2"
}


audio_output {
       type     "pulse"
       name     "MPD - music server"
       server   "127.0.0.1"
}

I had those lines for the audio output. The first one being for the "artsy" in ncmpcpp and second for my pulse output.

However I didn't know that pulse had to listen on a TCP port to be usable from MPD localhost; the "server 127.0.0.1" in the above config.

Adding this line to /etc/pulse/default.pa made everything finally work.
Code:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1



RE: Audio and music on Unix - ninjacharlie - 03-04-2016

I feel your pain venam :(

PavuControl is such crap - it adds confusion for no good reason. Every time I change my audio setup in the slightest, it's bound to screw it up and I'll waste an afternoon fixing it. For instance, I recently bought a Schiit Fulla DAC, but when I plugged it in, no sound was sent through it. After opening pavucontrol, and fiddling around, I got it set up. However, when I went to play CS:GO, pavu decided that my mic should be the output of the DAC, so it just loopbacked (all because I forgot to set my mic as the default fallback).

I don't know how it can be fixed, but linux's audio system is crap right now. ALSA is usable for the most part, but most things require pulseaudio at this point, which inevitably means one will block the other somehow.


RE: Audio and music on Unix - arcetera - 03-04-2016

In the meantime, I have an audio anti-horror story.

When I installed Void and CRUX (on Arch I used Pulse, which kinda "just werked"), I had to spend a while configuring them in both environments for some reason. It took me a while to get the perfect `~/.asoundrc`.

I installed OpenBSD on March 31, and to get audio working, I literally just had to `mixerctl -t outputs.master.mute` and it just worked. IIRC sndio can also be used on Linux if need be.


RE: Audio and music on Unix - tudurom - 04-04-2016

The perfect .asoundrc

Code:
defaults.pcm.rate_converter "speexrate_best"

defaults.pcm.card 0
defaults.ctl.card 0

Good quality sound AND it works with firefox without pulse.


RE: Audio and music on Unix - ninjacharlie - 04-04-2016

(03-04-2016, 07:20 PM)arcetera Wrote: I installed OpenBSD on March 31, and to get audio working, I literally just had to `mixerctl -t outputs.master.mute` and it just worked. IIRC sndio can also be used on Linux if need be.

Wow! If it's really that good I'll have to check OpenBSD out. I've been kinda reticent to install it since I've heard the hardware support is a few years behind linux (and I'm worried about wireless and graphics). Do you happen to know what the nvidia drivers are like?


RE: Audio and music on Unix - arcetera - 04-04-2016

(04-04-2016, 11:03 AM)ninjacharlie Wrote:
(03-04-2016, 07:20 PM)arcetera Wrote: I installed OpenBSD on March 31, and to get audio working, I literally just had to `mixerctl -t outputs.master.mute` and it just worked. IIRC sndio can also be used on Linux if need be.

Wow! If it's really that good I'll have to check OpenBSD out. I've been kinda reticent to install it since I've heard the hardware support is a few years behind linux (and I'm worried about wireless and graphics). Do you happen to know what the nvidia drivers are like?

There are no nvidia drivers, period. Nvidia doesn't give enough info to do much. Nouveau exists, but it's heavily Linux-only, and doesn't work (obviously).


RE: Audio and music on Unix - tudurom - 04-04-2016

(04-04-2016, 11:50 AM)arcetera Wrote:
(04-04-2016, 11:03 AM)ninjacharlie Wrote:
(03-04-2016, 07:20 PM)arcetera Wrote: I installed OpenBSD on March 31, and to get audio working, I literally just had to `mixerctl -t outputs.master.mute` and it just worked. IIRC sndio can also be used on Linux if need be.

Wow! If it's really that good I'll have to check OpenBSD out. I've been kinda reticent to install it since I've heard the hardware support is a few years behind linux (and I'm worried about wireless and graphics). Do you happen to know what the nvidia drivers are like?

There are no nvidia drivers, period. Nvidia doesn't give enough info to do much. Nouveau exists, but it's heavily Linux-only, and doesn't work (obviously).

can't they just study nouveau's code?


RE: Audio and music on Unix - neeasade - 04-04-2016

I would imagine that would prove pretty difficult, as nouveau is a reverse engineering of proprietary Linux drivers[1]. I don't think it would be a very trivial effort and there would need to be a large enough nvidia-using openBSD userbase who were both competent and cared for such a thing.

https://en.wikipedia.org/wiki/Nouveau_(software)#Software_architecture

Googling a bit led me to a thread and an article (under openBSD heading)

https://lwn.net/Articles/616097/
http://openbsd-archive.7691.n7.nabble.com/nouveau-driver-help-td235541.html


RE: Audio and music on Unix - pfr - 23-02-2022

How about we revive this one.


Lately I've been looking for a way to play local music files. Previously I've used many of the solutions mentioned earlier in this thread (mpd+mpc etc) however I am interested in what you are all using these days?

Ever since spotify arrived I've been subscribed to that and thanks to the curses based spotify client ncspot I've had no need to store music on my hdd.

I've just begun growing a local music library again and am somewhat disatisfied with the long list of options available. I dont want mpd on my system anymore. I dont think I need it. I don't even really need a full fledged client.

What I really wan't is to be able to play music files with mpv/mpg123/sox/whatever, using a shell script. Something I can pipe through fzf would be sweet, with the ability to select multiple files perhaps in order to create playlists.

For example, I use a pure sh terminal file manager called shfm (similar to nnn or fff). This was written by Dylan who also wrote fff, although the fork I'm using has also implemented core utils for cp/mv'ing files etc. Ideally I'd just hack shfm to be able to play multiple selected files using whatever player I want, but I think a simple script should do the trick.

Me being fairly sh illiterate (when it comes to writing scripts at least) means I find it hard to put this together. I wonder if something this minimal already exists. If so, I haven't found it yet.

But I digress.

What do you guys use these days?


RE: Audio and music on Unix - venam - 23-02-2022

What I personally use is still a combination of mpd and client interfaces such as ncmpcpp. I like the whole architecture of having a server manage the music library and be able to interact with it from different places.

I think it would also fit your scenario if you used the command line tool `mpc`.

EDIT: you can also refer to this thread for setup (not player): https://nixers.net/Thread-Your-Audio-Setup