Jun 172009
 

Introduction

I recently switched from using Linux’s KVM to using Sun’s VirtualBox for virtualizing a Windows XP guest on a Gentoo Linux host, and I have been quite pleased. The only feature that I don’t have working is clipboard-sharing, but that’s a problem for another day. Previously, I had major problems with sound using my EchoAudio Mia card. Ultimately, I used ALSA’s dmix plug-in to mix audio streams in software, before feeding it to the card. That worked great! However, VirtualBox was complaining about the new setup, and start-up was defaulting the audio component to “null”. In other words, my VM guest had no audio support!

Two problems, Two Solutions

The primary problem was that I had enabled the “esd” USE flag for my Gentoo system, which enables Enlightenment’s Enlightened Sound Daemon (ESD, or ESounD). Apparently, the latest version of SDL (libsdl) does not function properly in the ALSA environment, if the esd USE flag is set. Well, VirtualBox depends on SDL for audio support; consequently, my VM guest could not produce audio. The solution was to add the “-esd” USE flag to /etc/make.conf and rebuild the dependent packages (emerge -uDN world).

The second problem stems from my use of ALSA’s dmix plug-in. Although this works fine for playback, the dmix plug-in cannot be used for capture. Therefore, an environment variable must be set to specify an alternative capture source, like so:

# Unset any output customizations, use default
$ unset VBOX_ALSA_DAC_DEV
# Specify capture (analog-to-digital converter) device - can also be added to ~/.bashrc
$ export VBOX_ALSA_ADC_DEV="hw:0,0"
# Launch my Windows guest VM
$ VBoxManage startvm "Windows XP SP2"
# wait for it...
$ sleep 3
# check log for results:
$ grep -Pi '(alsa|audio)' VBox.log
VirtualBox Command Line Management Interface Version 2.2.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
 
Waiting for the remote session to open...
Remote session has been successfully opened.
00:00:00.808 [/Devices/AudioSniffer/] (level 2)
00:00:00.808 [/Devices/AudioSniffer/0/] (level 3)
00:00:00.808 [/Devices/AudioSniffer/0/Config/] (level 4)
00:00:00.808 [/Devices/AudioSniffer/0/LUN#0/] (level 4)
00:00:00.808   Driver <string>  = "MainAudioSniffer" (cch=17)
00:00:00.808 [/Devices/AudioSniffer/0/LUN#0/Config/] (level 5)
00:00:00.808   Driver </string><string>  = "AUDIO" (cch=6)
00:00:00.808   AudioDriver </string><string>  = "alsa" (cch=5)
00:00:01.090 Audio: Trying driver 'alsa'.
00:00:01.093 Audio: set_record_source ars=0 als=0 (not implemented)
00:00:01.095 ALSA: ADC frequency 44100Hz, period size 1024, buffer size 4096
00:00:01.099 ALSA: DAC frequency 44100Hz, period size 940, buffer size 3763</string>

Now I could hear audio output from my VM guest, simultaneously while listening to audio from host applications, and I could also capture audio!

Incidentally, I extended my default ~/.asoundrc file a little, although it did not seem to make a difference:

pcm.!default {
    type plug
    slave.pcm "dmix"
}
pcm.dsp0 {
    type plug
    slave.pcm "dmix"
}
ctl.mixer0 {
    type hw
    card 0
}

References

  1. http://forums.virtualbox.org/viewtopic.php?f=7&t=18835
  2. http://forums.gentoo.org/viewtopic-p-5714588.html#5714588
  3. http://www.virtualbox.org/ticket/1908
Share
Jun 162009
 

Introduction

Previously I blogged about using Alsa with EchoAudio’s Mia 96-kHz / 24-bit prosumer audio card. However, I have since experienced one nagging problem: Only one application can use the sound card at a given time! It is impossible for two or more applications to share the sound card. For a second application to use the Mia, the first app must be closed before the second is opened; otherwise, the first one will maintain a lock, blocking the second.

Many newer sound cards included integrated mixers, which allow multiple applications to simultaneously produce sound. Older sound cards depended upon software to perform the mixing. ALSA includes the “dmix” plug-in, which performs this very task.

ALSA DMIX Configuration

Typically, dmix is used automatically by ALSA, whenever it detects a sound-card without built-in mixing. Unfortunately, the ALSA driver for the Mia reports the card as having mixing capability, which it does not. Therefore, we must manually direct ALSA to use the dmix plug-in by default. ALSA is generally controlled through the “asoundrc” file, which can exist at the system or user level:

/etc/asound.conf
/home/my_user/.asoundrc

Several tutorials and HOWTO’s exist to set up ASLA’s dmix plug-in; however, these proved overly complicated, as I simply use:

$ cat /home/my_user/.asoundrc
pcm.!default {
    type plug
    slave.pcm "dmix"
}

This directs all applications to use the dmix plug-in by default. Now I can simultaneously play sound from multiple applications and without having to open and close each application in sequence!

System ALSA Configuration

Just for reference, my system’s ALSA configuration seems to use DMIX by default; however, it has never worked for me. I am including it here, just for reference:

$ cat /etc/asound.conf
pcm.swmix {
    type dmix
    # any unique number here
    ipc_key 313
    slave {
        pcm "hw:0,0"
        # these settings may require tweaking for different sound
        # cards; this is for the Powerbook's built-in snd-powermac
        # probably not required at all for well-behaved cards...
        period_time 0
        period_size 1024
        buffer_size 8192
        # mentioning rate fixes wrong speed/pitch in native ALSA stuff
        rate 44100
    }
}

# this makes OSS emulation via aoss default to using dmix, allegedly
pcm.dsp0 {
    type plug
    slave.pcm "swmix"
}

ctl.mixer0 {
    type hw
    card 0
}

# this makes native ALSA apps default to using dmix
pcm.!default {
    type plug
    slave.pcm "swmix"
}

Conversation with Giuliano Pochini

Giuliano Pochini is the author of the ALSA driver for the EchoAudio Mia. Recently, I posed my problem to him, as follows:

I am using your ALSA driver for the EchoAudio Mia PCI card. You have done a fantastic job! I really appreciate it.

One question: I am only able to use one application at a time to produce sound. If I want to produce sound in another application, I must close the first application, and then open the second.

Is it possible to have more than one application simultaneously produce sound through the Mia?

Should I use ALSA’s dmix plug-in, or is there a better solution?

To which, he kindly replied:

That card has 8 voices and 4 outputs. The vmixer controls how the voices are sent to the outputs. If your application uses default: or hw:x.0.0 or plughw:x.0.0 then it can use a single 1 to 8 – channels output. You have to use dmix to make alsa-lib mix the sound coming from differents apps. Otherwise you can manually configure your apps to use plughw:0.0.0, plughw:0.0.2, plughw:0.0.4 and plughw:0.0.6 and use the vmixer to route them to the ouptus as you prefer.

There is another way which requires some non trivial changes to the driver: make it automatically select the first free stereo pair when an application opens a substream. Drawbacks are that apps wouldn’t be able to open non stereo substreams anymore and that changing the volume would become problematic because you couldn’t know what channels have been assigned to each app. And, of course, there are only 4 stereo pairs available, all with the same sample rate, so dmix and resample are likely to be necessary anyway.

References

  1. http://alsa.opensrc.org/index.php/.asoundrc
  2. http://alsa.opensrc.org/index.php/AlsaTips#Share_a_single_card_with_multiple_applications
  3. http://alsa.opensrc.org/index.php/DmixPlugin
  4. http://alsa.opensrc.org/index.php/Hardware_mixing%2C_software_mixing
  5. http://www.alsa-project.org/main/index.php/Matrix:Vendor-Echo_Corporation
  6. http://www.alsa-project.org/main/index.php/Matrix:Module-mia
  7. http://www.webalice.it/g_pochini/ead
  8. http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
Share
Apr 142009
 

Introduction

For some time, I have casually noticed that Gnome’s Evolution was not spell-checking my email messages.  Most other email clients, text editors, and even modern web-browsers, at least check your spelling as you type, underlining misspelled words with red wavy lines.  Evolution has this capability, but it was not enabled on my system.  Here is how I enabled spell-check on my Gentoo system for Evolution.

Solution

Gnome’s Evolution is dependent upon external spell checkers to perform this function.  Popular open-source checkers include ispell, aspell, and hunspell.  Aspell is newer than ispell, and was designed to replace it, at least according to aspell’s web-siteHunspell is an up and coming spell-checker, based on MySpell and backwards compatible with its dictionaries.  Apparently, Hunspell is used in many popular projects, such as:  OpenOffice, Mozilla Firefox, Mozilla Thunderbird, Opera, and Google Chrome.

All of these above spell-checkers are developed to be language independent; therefore, you also must also install a language specific “library” or “dictionary” to complete the installation.

Evolution appears to use aspell.  However, I installed all 3 spell-checkers and English dictionaries for each checker, plus a few other utilities, like so:

# emerge -pvt app-text/aspell app-text/gnome-spell app-text/ispell \
app-text/spellutils app-vim/vim-spell-en dev-perl/Text-Aspell dev-perl/gtk2-spell \
dev-python/gtkspell-python app-dicts/aspell-en app-dicts/myspell-en

Check to make sure you satisfied with the proposed installations, and then commit:

# emerge app-text/aspell app-text/gnome-spell app-text/ispell \
app-text/spellutils app-vim/vim-spell-en dev-perl/Text-Aspell dev-perl/gtk2-spell \
dev-python/gtkspell-python app-dicts/aspell-en app-dicts/myspell-en

After emerging the above packages and restarting Evolution, I was able to select dictionaries and enable the “Check as you type” feature by navigating here:

Evolution -> Edit -> Preferences -> Composer Preferences -> Spell Checking

Now I had nice red wavy lines everywhere! 🙂

BTW, I did encounter a problem where some of my dictionaries or checkers became corrupted, so I had to re-install (re-emerge) all of the above packages to fix the problem, even though I had previously installed these packages.

Share
Dec 052008
 

Introduction

Every computer you buy or assemble comes with some decent integrated sound card.  A while back (~2000), I bought a “prosumer” (entry-level professional) sound card, the Mia by EchoAudio.  It was a pain at first, because the Windows drivers for XP were just not mature.  However, after about 6 months of updating drivers every other week, I finally got a rock-solid sound card that blew the doors off any integrated sound card I have used, even up to this day (12-2008).  All the integrated cards sound so “tinny” and “weak”, compared to the rich, full sound of this card.

For some time, I have avoided moving my main workstation to Linux, in some measure, due to the lack of drivers for this sound card.  However, a few weeks ago, I noticed an entry for the EchoAudio Mia in the kernel config!  Here is how I managed to get it working on Gentoo Linux.

Default ALSA Installation

The most modern sound system on Linux at this time is ALSA.  The Gentoo wiki page for installing it is here:

http://www.gentoo.org/doc/en/alsa-guide.xml

One important note:  ALSA can be compiled into the kernel or compiled separately as loadable modules.  Currently, Gentoo has mostly abandoned the in-kernel approach (which uses the alsa-drivers package), and it now uses the loadable module approach.  There’s no reason to buck the system here, so we are going to use the loadable module approach.

When you activate the appropriate ALSA kernel options, make sure you include the driver for the EchoAudio Mia, or whatever Echo Audio product you may be using.  Otherwise, you can follow the above guide up to the point where you are ready to run alsaconf.

Make sure you:  Recompile the kernel.  Copy it into place.  Update grub.conf.  Reboot.  You know the drill.  🙂

Modified ALSA Installation for Mia

The Mia driver depends on alsa-utils, but it also needs other ALSA packages, which are not necessary for other integrated sound cards, like hda-intel.  Furthermore, the default make.conf flags do not include the Mia components.  To include these, and to use the latest version of ALSA ;), let us first add a few keywords and compile flags to the ALSA build configuration:

Now, we are ready to install ALSA, again, in addition to the other necessary packages:

# Use latest version of everything ALSA
$ echo -e "media-sound/alsa-tools ~amd64\nmedia-sound/alsa-utils ~amd64\nmedia-sound/alsa-firmware ~amd64\nmedia-sound/alsa-headers ~amd64\nmedia-libs/alsa-lib ~amd64" >> /etc/portage/package.keywords

# Include Mia during ebuilds
$ echo 'ALSA_CARDS="mia"' >> /etc/make.conf

# Check for weirdness:
$ emerge -pvt alsa-utils alsa-tools alsa-firmware alsa-lib alsa-headers

# Build!
$ emerge alsa-utils alsa-tools alsa-firmware alsa-lib alsa-headers

Now update the ALSA configuration using alsa-conf, and you should be good to go!

$ alsaconf

Other Tips

The best mixer to use is the echomixer, which is made for the EchoAudio products, like the Mia.

In the default configuration, most everything is muted, so you will have to slide up the appropriate sliders.  Just be careful not to overdrive the card.  Stop at “0 dB” or less.  Do not slide it up to “+6 dB”; otherwise, you get a fair amount of distortion.

Other pages that mention the “alsa-drivers” package are based upon the “IN-KERNEL” approach.  Those instructions are not compatible with these.  Be careful if you decide to “mix and match”.

References

  1. ALSA’s EchoAudio development status – http://www.webalice.it/g_pochini/ead
Share