kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Mon Jul 23, 2012 10:08 am

I'm glad i could help. My config should not be related to the usb card however. Unless you disabled internal soundcard.

raspy_rodent
Posts: 4
Joined: Mon Jul 23, 2012 9:30 am

Re: ALSA on Raspbian

Mon Jul 23, 2012 11:03 am

Hi kadamski,

you're right. I modified /etc/modprobe.d/alsa-base.conf

Code: Select all

options snd-usb-audio index=0
options snd_bcm2835 index=-5
so my hw:0,0 ist the USB soundcard

Thx, Frank

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Mon Jul 23, 2012 11:11 am

And your USB card needed MMAP emulation? That's strange..

raspy_rodent
Posts: 4
Joined: Mon Jul 23, 2012 9:30 am

Re: ALSA on Raspbian

Mon Jul 23, 2012 11:22 am

Why is it strange?
lsusb tells me my soundcard is a 0d8c:0008 C-Media Electronics, Inc. Soundcard. A cheap one ;-)

Greets,
Frank

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Mon Jul 23, 2012 11:40 am

Well.. I though that snd-usb-audio provides mmap support without problems. But maybe my config just solves some strange side effect or something.

raspy_rodent
Posts: 4
Joined: Mon Jul 23, 2012 9:30 am

Re: ALSA on Raspbian

Tue Jul 24, 2012 9:16 am

Hi kadamski,

I was a bit to fast to announce success using asterix/chan_alsa/USB soundcard. Yesterday i only had ssh access to my pi, so i didn't hear the USB soundcard output. Today i know that only the errors 'ERROR[1907] chan_alsa.c: Read error: Resource temporarily unavailable' are gone but the USB soundcard still remains in silence when using mmap_emul with USB soundcard.
Perhaps the soundcard isn't mmap capable?? I will test it on i386 hardware.

Thanks,
Frank

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Tue Jul 24, 2012 9:23 am

That's why i was sceptic about that solving the problem. Please verify if your problem is not USB problem. Check dmesg to see if the card wasn't reset or even turned off. This may be due to power problems for example or some USB bug (USB driver is quite buggy in RPi right now).

User avatar
tzj
Posts: 302
Joined: Thu Jan 05, 2012 3:09 pm
Location: Barnsley, SY, UK

Re: ALSA on Raspbian

Tue Jul 24, 2012 3:34 pm

mmm... the start_alsa.elf keeps preventing my start.elf from loading.
http://www.themagpi.com <---- Checkout the MagPi
(The MagPi - Co-Founder)

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Tue Jul 24, 2012 3:40 pm

What you mean? Does it stop on black screen or on colorful one? Do you overclock your pi?

User avatar
tzj
Posts: 302
Joined: Thu Jan 05, 2012 3:09 pm
Location: Barnsley, SY, UK

Re: ALSA on Raspbian

Tue Jul 24, 2012 5:50 pm

kadamski wrote:What you mean? Does it stop on black screen or on colorful one? Do you overclock your pi?
black screen with the OK light blinking 6 times, not overclocked.
http://www.themagpi.com <---- Checkout the MagPi
(The MagPi - Co-Founder)

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Tue Jul 24, 2012 5:59 pm

And you are sure the file is not currupted or anything? Those fat on boot partition likes to be corrupted. And are all other firmware files up to date?

User avatar
tzj
Posts: 302
Joined: Thu Jan 05, 2012 3:09 pm
Location: Barnsley, SY, UK

Re: ALSA on Raspbian

Tue Jul 24, 2012 6:13 pm

I'll re download it and try again. how do I update, if it won't allow me to do rpi-update?
http://www.themagpi.com <---- Checkout the MagPi
(The MagPi - Co-Founder)

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Tue Jul 24, 2012 6:22 pm

I'm not sure what is the preffered way. I'm just downloading files manually from github. Since I don't think it has anything to do with kernel (it wasn't loaded yet), you only have to check bootcode.bin and loader.bin. They are not updated to often and Icm not really sure how much are.they dependent on each other.

Bob_Tee
Posts: 7
Joined: Sun Mar 04, 2012 12:23 pm

Re: ALSA on Raspbian

Wed Jul 25, 2012 7:41 pm

Today I have had success with the official Raspbian and USB audio in/out with WSPR. But too many variables to know what worked!
1) New SD card 4Gig Class 10. (£4.82 shipped from China in 6 days) I had been using an 8G Class 4.
2) Installed the 17th July image, resized to disk and configured all via SSH. Fixed IP address.
3) apt-get update. apt-get upgrade, kept config unchanged
4) to install WSPR I have been blindly doing the following, some of which may have a bearing :

Code: Select all

sudo apt-get install subversion python2.6-dev python-numpy python-imaging-tk python-pmw
sudo apt-get install libportaudio2 portaudio19-dev libsamplerate0-dev gfortran cl-fftw3 python-dev
sudo svn co http://svn.berlios.de/svnroot/repos/wsjt/branches/wspr
cd wspr
sudo ./configure \--with-portaudio-include-dir=/usr/include \--with-portaudio-lib-dir=/usr/lib/arm-linux-gnueabihf
sudo make
5) pasted in a config file to  /etc/asound.conf file (as given earlier in this thread)

Code: Select all

pcm.mmap0 {
    type mmap_emul;
    slave {
      pcm "hw:0,0";
    }
}

pcm.!default {
  type plug;
  slave {
    pcm mmap0;
  } 
and also
sudo nano /etc/modprobe.d/alsa-base.conf
and changed the line which sets usb-audio to -2 back to 0 to be the default sound card
6) make failed, swapon -a and tried again, no error but segmentation error when run. Deleted wspr directory ran subversion again with swapon but still had "segmentation error".
7) Gave up on the build and copied the wspr I had built and tested under DarkBasic minimal build. Success, at least after I installed libhamlib-utils. The cosmetic appearance of WSPR was not the same under LXDE as it had been under XFCE4 which I put down to a lack of mono-spaced font so I decided to install XFCE4. But just the installation alone fixed the problem while running under LXDE so I guess the fonts are cross compatible.

Running solidly for 5 hours now on transmit and receive and even with band-hopping enabled. But what actually enabled the USB audio? Could it be something in the portaudio packages or the libsampleratr0-dev? Performance seems as good as my PC but I will try side by side tests again when the shack gets cooler!

Bob
G3WKW

User avatar
Mutech
Posts: 2
Joined: Sat Jul 28, 2012 3:44 pm

Re: ALSA on Raspbian

Sat Jul 28, 2012 3:55 pm

kadamski wrote:Ok, found system wide solution. I'm don't know yet why it's working, though. Just configure alsa-lib with standard:

Code: Select all

pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}
and it will work for both mplayer and vlc (and others). Just save that file in /etc/asound.conf (system wide) or in ~/.asoundrc (only for one user).
Thanks! This helped a lot ;)

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: ALSA on Raspbian

Sun Jul 29, 2012 7:41 am

While this is working for mplayer, it may not work for other applications. This is why later I posted even better solution in this post: http://www.raspberrypi.org/phpBB3/viewt ... 25#p125513

ComputerJock
Posts: 14
Joined: Tue Aug 07, 2012 11:21 pm

Re: ALSA on Raspbian

Tue Aug 07, 2012 11:36 pm

OK, my first post on this forum and it's probably in the wrong place. Please let me know what forum should be used to address possible kernel/hardward errors.

My issue: I attempted to play a WAV file using aplay. It is identified by 'file' as:

Chime.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 8012 Hz

I issued the commands:

$ uname -a
Linux PIblack 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l GNU/Linux
$ sudo aplay Chime.wav
Playing WAVE 'Chime.wav' : Signed 16 bit Little Endian, Rate 8012 Hz, Mono

No sound and a ^C does not kill the command. I have to do a ^Z, jobs -l, kill -9 to get rid of it. Sound is now broken and I cannot play one of the previously working WAV files in /usr/share/sounds/alsa

/var/log/kern.log is:

Aug 7 18:29:30 PIblack kernel: [ 1454.538066] snd_bcm2835_playback_open:97 Alsa open (0)
Aug 7 18:29:37 PIblack kernel: [ 1461.732487] vcos: [3802]: bcm2835_audio_write:778 bcm2835_audio_write: failed on vchi_bulk_queue_transmit (status=-1)
Aug 7 18:29:37 PIblack kernel: [ 1461.733493] snd_bcm2835_playback_close:167 Alsa close
Aug 7 18:29:40 PIblack kernel: [ 1464.828242] vcos: [3802]: bcm2835_audio_close:702 bcm2835_audio_close: failed on waiting for event (status=10)

Thank you.

ComputerJock
Posts: 14
Joined: Tue Aug 07, 2012 11:21 pm

Re: ALSA on Raspbian

Wed Aug 08, 2012 12:27 am

Hmmm, can't edit a post so I'll have to reply to it.

I found another post that described the same problem:

http://www.raspberrypi.org/phpBB3/viewt ... 91#p127791

Those folks seem to know what they're talking about, and it appears that the problem is being investigated.

Dozzman
Posts: 1
Joined: Wed Jul 11, 2012 2:37 pm

Re: ALSA on Raspbian

Wed Aug 08, 2012 9:03 am

@ComputerJock
dom wrote: Agreed. There are a few unrelated bugs going on here. A separate github issue for each is probably useful.
(and maybe a spindle one for asb about including a suitable /etc/asound.conf to get the plug format conversion working).

I've stopped it blocking when VC audio buffer is full before we start playing, and I've increased audio output buffer size to 256K.
I've also stopped hdmi from discarding samples written before the start (causing first second of audio to be lost on HDMI - analogue already had this fix).
https://dl.dropbox.com/u/3669512/temp/start_alsa.elf

It does fix the 11025 samplerate hang for me.
Dom posted this new start.elf file which should fix the issue. Replace this start_alsa.elf with your start.elf on the FAT partition on your SD card (ensuring to rename it to start.elf) and try again.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5163
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: ALSA on Raspbian

Wed Aug 08, 2012 9:13 am

Dozzman wrote: Dom posted this new start.elf file which should fix the issue. Replace this start_alsa.elf with your start.elf on the FAT partition on your SD card (ensuring to rename it to start.elf) and try again.
This fix (and others) is now in the standard firmware updates, so just update normally, e.g with rpi-update:
http://elinux.org/R-Pi_Troubleshooting# ... g_firmware

Note: there was a fix last night that fixes the ten second timeout you could get when quitting ALSA apps.
Also some improvements to volume/mute behaviour.

ComputerJock
Posts: 14
Joined: Tue Aug 07, 2012 11:21 pm

Re: ALSA on Raspbian

Fri Aug 10, 2012 2:24 am

dom wrote:
Dozzman wrote: Dom posted this new start.elf file which should fix the issue. Replace this start_alsa.elf with your start.elf on the FAT partition on your SD card (ensuring to rename it to start.elf) and try again.
This fix (and others) is now in the standard firmware updates, so just update normally, e.g with rpi-update:
http://elinux.org/R-Pi_Troubleshooting# ... g_firmware

Note: there was a fix last night that fixes the ten second timeout you could get when quitting ALSA apps.
Also some improvements to volume/mute behaviour.
I just did the rpi-update, rebooted per instructions, and re-ran the aplay command on the WAV file. It's definitely an improvement that the aplay command no longer locks up, however there is not sound and the sound device is wedged. aplay with one of the valid WAV files produces no sound. A reboot is still required to clear the condition.

[Update]

Actually it's worse. I can't play any sound -- or at least I can't hear it. I tried to look at the volume level and that fails too:

$ sudo alsamixer
cannot open mixer: Invalid argument
$ sudo amixer
amixer: Mixer attach default error: Invalid argument

Report this here? Or is there another place to post this? Thanks.

ComputerJock
Posts: 14
Joined: Tue Aug 07, 2012 11:21 pm

Re: ALSA on Raspbian

Fri Aug 10, 2012 3:27 am

ComputerJock wrote: Actually it's worse. I can't play any sound -- or at least I can't hear it. I tried to look at the volume level and that fails too:

$ sudo alsamixer
cannot open mixer: Invalid argument
$ sudo amixer
amixer: Mixer attach default error: Invalid argument

Report this here? Or is there another place to post this? Thanks.
Update: Very sorry... False alarm... I finally figured out that I had to do alsamixer -c 0 and I discovered that it was set to mute after my rpi-update. Apologies to all.

omenie
Posts: 88
Joined: Fri Dec 09, 2011 5:09 pm
Contact: Website

Re: ALSA on Raspbian

Sat Aug 25, 2012 2:38 pm

Hi guys

I'm not right now using ALSA, but would if it would help. I am seeing OMX with code lifted marginally modified from the hello_audio example, and am seeing huge audio latency, maybe 1/3 second. For a man-in-the-loop music synthesizer application it's a killer.

See blog post here - http://raspberrypisynthesizer.blogspot. ... is-go.html - the latency is induced within the OMX thread, which is really simple and modelled after hello_audio. Is there a known issue with huge audio latency?

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5163
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: ALSA on Raspbian

Sat Aug 25, 2012 2:59 pm

OpenMAX is designed for media playback, where latency isn't a big concern (as long as video and audio latency are the same).

You can probably improve it with smaller buffer sizes.

ALSA may well have less latency, but I wouldn't expect to get much better than 100ms. How low do you need?

omenie
Posts: 88
Joined: Fri Dec 09, 2011 5:09 pm
Contact: Website

Re: ALSA on Raspbian

Sat Aug 25, 2012 5:36 pm

Dom

Just PMd you again - I had screwed up, I confess, 50 pushups etc.

It is now quite *AMAZING* and has inaudible latency vs. my finger speed, certainly well under 100th of a second and it can be tuned up more I think.

This hardware, and the stuff that comes with it, is just brilliant.

Will now work on how to get copies into real musicians hands - requiring a hand-soldered custome MIDI interface is a bit of a problem, but if I have to do soldering so be it.

Really, one more time - this platform is quite brilliant. Thansk to all who have contributed.

Return to “Raspbian”