Showing posts with label Sound. Show all posts
Showing posts with label Sound. Show all posts

Thursday, November 4, 2010

Run Pulseaudio and MPD as own user

Oh huh.. I've ran into some meany troubles when installing MPD. It just didn't want to talk to Pulseaudio if it runs as systemwide daemon.

Solutions: Start MPD as your user or the Pulseaudio daemon systemwide.
Problem: Every Howto for Pulseaudio told me how bad and very bad and very very bad it is to run it systemwide ~.~

Okey.. not a big deal. Let's just set up MPD with your own user..

First of all install MPD:

emerge mpd -avq

I'm using the following useflags for it:

aac alsa avahi bzip2 curl ffmpeg fifo flac id3 ipv6 jack lame lastfmradio libsamplerate mad mikmod network ogg pulseaudio tcpd unicode vorbis wavpack -ao -audiofile -cdio -cue -debug -doc -fluidsynth -libmms -modplug -mpg123 -musepack -oss -pipe -profile -sid -sndfile -sqlite -twolame -zip

Some of them might not be available on every system because I'm using the live version from mpd overlay. It's available in layman.

Now the /etc/mpd.conf needs to go to the right place:

mkdir -p ~/.config/mpd/
cp /etc/mpd.conf ~/.config/mpd/


And finally some edits in the config.. mine looks like this:

music_directory "/mnt/media/music/collection"
playlist_directory "/mnt/media/music/playlists"
db_file "~/.config/mpd/database"
log_file "~/.config/mpd/mpd.log"
pid_file "/var/run/mpd/mpd.pid"
state_file "~/.config/mpd/state"
bind_to_address "localhost"
audio_output {
type "pulse"
name "MPD"
}
replaygain "album"
replaygain_preamp "0"
volume_normalization "yes"

Everything else is commented out.

So far so good.. mpd should be able to run now.

mpd ~/.config/mpd/mpd.conf


I've put this line into my autostart.sh of Openbox. It's using really less CPU while idling so I really don't mind. Some frontends are able to start and stop it too but I'm switching the frontends sometimes for tests and silly things.

Monday, November 1, 2010

How to run two soundcards?

Here's a pretty simple setup how to bring two soundcards to work..

Build both drivers as module into your kernel and add the following to your /etc/modprobe.d/alsa.conf:

alias snd-card-0 <driver1>
alias sound-slot-0 <driver1>
alias snd-card-1 <driver2>
alias sound-slot-1 <driver2>


Replace <driver1> and <driver2> with your own soundcard modules.

I'm using pulseaudio to manage the different sinks.

Jack and Pulseaudio

I've recently found a question on the Gentoo forums about Jack and Pulse in one environment which is very well possible.
Both, Jack and Pulse, need to be build with the dbus useflag which let them communicate which each other.
As soon as you start Jack it will take over the device from Pulse and give it back to it if you close Jack again.

Jack and the LADI overlay

The LADI overlay provides a great set of tools for jack and lash. It is managing your settings in studios and let you save and load different jack settings. The important tools from the overlay are ladish and laditools.

The laditools are containing several utilities. Here's the list quoted from the blog of the ladi creator MarcO'Chapeau:

The laditools python module (no interest for the end users)
laditray : a system tray icon that allows you to start, stop and monitor JACK, as well as start some JACK related apps (log viewer, connections...)
wmladi : a controller as a Window Maker dockapp. Uses the same menu as laditray
ladilog : a JACK, LASH and a2jmidid log viewer
ladiconf : a GUI to setup JACK's configuration
g15ladi : a JACK monitor for g15 keyboards


You can add the ladi-overlay to layman:

layman -o http://www.marcochapeau.org/files/downloads/overlays.xml -f -a ladi


Build the laditools:

emerge laditools -avq


There's also a rewrite of lash in the overlay called ladish. It is replacing the lashlibs but it turns out that you run into some file collision if you install ladish and a tool is pulling into lash.

Here's a small workaround to install both package to allow tools like ardour to use lash:

a) Add the useflag lash to your /etc/make.conf
b) Build lash with the oneshot emerge option:

emerge lash -1avq

c) Delete the lash libs from /usr/lib64:

rm /usr/lib64/liblash.so.1.1.1
rm /usr/lib64/pkgconfig/lash-1.0.pc
rm /usr/lib64/liblash.so
rm /usr/lib64/liblash.so.1

d) Build ladish:

emerge ladish -avq


If you want to add laditray to your autostart add this line to ~/.config/openbox/autostart.sh:

laditray &

But be warned it will start Jack automatically and will take control over your devices until you stop the studio. It's better to start laditray from menu if you use Pulseaudio for listening to music and systemsounds and Jack only as realtime soundserver for music composition.


Some interessting Links:
Home of LADI
Overlay

Saturday, July 10, 2010

Pulseaudio

I've run into some troubles a while ago when I looked for a nice way to use two soundcards at the same time.
I've tried a plain alsa install but I wasn't happy with the results. It was just too limited and some tools couldn't be configured like i wanted to do it.
Especially flash and media in the web gave me some headache because I couldn't choose the output device on fly and had troubles with devices kept busy until i closed the browser and such.

The only solution which is really working for me like i want it is Pulseaudio.
It let me switch the devices on fly, to mute them separately, dublex is working and it saves the settings for each tool.
I'm still not happy with it though. The sound is cranky sometimes and it's a bit slow, funny shock moments included. The volume is usually turned up to max if a tool is starting to play sound and it takes a second or two before Pulse toggles the volume if the system is under heavy load.

The good thing.. it's running almost out of the box.

Here's what i did to get sound in every tool, also in browser and flash:

Editing /etc/make.conf and adding pulseaudio useflag:

USE=" [.. snip ..]
mplayer webkit gimp imagemagick ffmpeg jack lash lame \
libsamplerate jpeg2k real wavpack theora pulseaudio gstreamer"


Emerging world with the new useflag:

emerge world -NDavq


Adding my user to the pulseaudio and plugdev group:

usermod -a -G pulseaudio plugdev <user>


Forcing alsa to use Pulseaudio as output build the alsa plugins:

emerge alsa-plugins -avq


And add the following into ~/.asoundrc:

pcm.pulse {
type pulse
}

ctl.pulse {
type pulse
}

pcm.!default {
type pulse
}

ctl.!default {
type pulse
}


And I finally emerged a useful tool to control the Pulseaudio:

emerge pavucontrol -avq


There's no need to add Pulseaudio to a runlevel. It's starting as soon as an application wants to send something to your soundcard.

Don't forget to relog into your account to activate your new group settings. Though the savest way to get all tools running with Pulseaudio would be a restart of your box. Yes.. a restart is sometimes easier.. even with Linux <.<°

Some Links for further infos:
http://www.pulseaudio.org/
http://en.gentoo-wiki.com/wiki/PulseAudio