User avatar
Ram.Sh
Posts: 60
Joined: Wed Oct 26, 2016 9:14 pm

need help: aplay to usb headphones

Thu Jan 16, 2020 2:46 pm

Hello all,

Hardware
using RPI Zero /w running
Raspbian GNU/Linux 10 (buster)
Linux raspberrypi 4.19.75+ #1270 Tue Sep 24 18:38:54 BST 2019 armv6l GNU/Linux
Pi is connected to a a usb headphones (including mic)

Objective
playing short OGG (2 seconds, sample rate 44100) using aplay or omxplayer

VLC testing
when playing the OGG file using VLC the file plays nicely to the headphones.

Problem
when trying omxplayer:

Code: Select all

omxplayer -o alsa /home/pi/Desktop/test.ogg
Playing raw data '/home/pi/Desktop/test.ogg' : Unsigned 8 bit, Rate 8000 Hz, Mono
Audio codec vorbis channels 2 samplerate 44100 bitspersample 16
Subtitle count: 0, state: off, index: 1, delay: 0
have a nice day ;)
the file plays in "high speed"

when trying aplay:

Code: Select all

aplay /home/pi/Desktop/test.ogg
Playing raw data '/home/pi/Desktop/test.ogg' : Unsigned 8 bit, Rate 8000 Hz, Mono
the audio output is "white noise "

when aplay with specific card

Code: Select all

aplay --device=hw:1,0 /home/pi/Desktop/test.ogg
Playing raw data '/home/pi/Desktop/test.ogg' : Unsigned 8 bit, Rate 8000 Hz, Mono
aplay: set_params:1339: Sample format non available
Available formats:
- S16_LE
no audio output

Current Setup

/etc/asound.conf

Code: Select all

  pcm.!default  {
     type hw card 1
    }
    ctl.!default {
     type hw card 1
    }
changed to 1 in /usr/share/alsa/alsa.conf

Code: Select all

defaults.ctl.card 1
defaults.pcm.card 1
added to /boot/config.txt

Code: Select all

audio_pwm_mode=2
added blacklist to /etc/modprobe.d/raspi-blacklist.conf

Code: Select all

blacklist snd_bcm2835
output of aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: LX3000 [Microsoft LifeChat LX-3000], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
the next part is a snapshot of alsamixer, the default is always pulseaudio
Image

i guess it has somethiong to do with the sample rate but as you can see my audio knowledge is less than adequate to solve this...
any help is highly appreciated!!!

many thanks in advance,
best,
Ram

tvjon
Posts: 724
Joined: Mon Jan 07, 2013 9:11 am

Re: need help: aplay to usb headphones

Thu Jan 16, 2020 3:12 pm

As they're so short, can you zip up & attach a couple of the samples?

Also what's in:

~/.asoundrc

User avatar
Ram.Sh
Posts: 60
Joined: Wed Oct 26, 2016 9:14 pm

Re: need help: aplay to usb headphones

Thu Jan 16, 2020 4:22 pm

tvjon wrote:
Thu Jan 16, 2020 3:12 pm
As they're so short, can you zip up & attach a couple of the samples?

Also what's in:

~/.asoundrc

thank you for your reply!
pls find attached zip and the content of ~/.asoundrc
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "output"
}
capture.pcm {
type plug
slave.pcm "input"
}
}

pcm.output {
type hw
card 1
}

ctl.!default {
type hw
card 1
}

pcm.input {
type hw
card 1
}
Attachments
ogg samples.zip
(212.71 KiB) Downloaded 9 times

tvjon
Posts: 724
Joined: Mon Jan 07, 2013 9:11 am

Re: need help: aplay to usb headphones

Fri Jan 17, 2020 1:40 am

Your samples play fine in alsaplayer & omxplayer.

Presumably you have

pavucontrol

installed, as you're using pulseaudio?
If not, install it.

I don't have usb headphones, but several usb audio "cards", a couple of which I used for testing this.

Even if you have only USB phones in a Pi0, (raspbian) Buster doesn't automatically create a connection for them to pulseaudio.

In fact, even on a Pi4 for example, selecting the target audio output from the LXDE speaker icon doesn't propagate that to pulseaudio either. No idea if that's pulse or the volume control, or both at fault, or it's just designed that way.

So to play your samples, see the attached picture, where my audio card, CM108 is substituted for your headphones.

Use a longer file than your samples though because that entry in pavucontrol is only visible for the playback duration.

Once you've selected your headphones, use, for example:

$ omxplayer -o alsa 4.ogg

HTH
Attachments
usb-output-select.png
usb-output-select.png (44.08 KiB) Viewed 197 times

User avatar
Ram.Sh
Posts: 60
Joined: Wed Oct 26, 2016 9:14 pm

Re: need help: aplay to usb headphones

Fri Jan 17, 2020 2:02 am

Dear tvjon,

many thanks for taking the time to help me with this!!

I did have PulseAudio but after re-install/update it following your post - omxplayer is playing the ogg files!! success!!

however, I would prefer to use aplay instead since it loading time is faster than omxplaer, sadly, reinstalling PulseAudio didn't change that, i can't play the file using aplay:

Code: Select all

pi@raspberrypi:~ $ aplay --device=hw:1,0 --rate=44100 --format=S16_LE --channels=2 /home/pi/Desktop/test.ogg
Playing raw data '/home/pi/Desktop/test.ogg' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
audio output is white noise.

any thoughts on that?

once again, your help is highly appreciated, thx much!

tvjon
Posts: 724
Joined: Mon Jan 07, 2013 9:11 am

Re: need help: aplay to usb headphones

Fri Jan 17, 2020 9:44 am

"...I would prefer to use aplay instead since it loading time is faster than omxplaer..."

Note my comment, "Your samples play fine in *alsaplayer* (www.alsaplayer.org) & omxplayer", NOT aplay. Aplay will start up faster than applications, but it doesn't know how to play anything other than its listed formats, hence your white noise when it tries!

You could try an early version of say, mplayer to compare loading speeds, but omxplayer is probably not going to be much slower. It's a very versatile player.

User avatar
Ram.Sh
Posts: 60
Joined: Wed Oct 26, 2016 9:14 pm

Re: need help: aplay to usb headphones

Fri Jan 17, 2020 1:19 pm

tvjon wrote:
Fri Jan 17, 2020 9:44 am
Aplay will start up faster than applications, but it doesn't know how to play anything other than its listed formats, hence your white noise when it tries!
got it, I think I'll use WAV instead of OGG then.

I appreciate your help!
have a great weekend.

tvjon
Posts: 724
Joined: Mon Jan 07, 2013 9:11 am

Re: need help: aplay to usb headphones

Fri Jan 17, 2020 5:16 pm

"got it, I think I'll use WAV instead of OGG then.

I appreciate your help!
have a great weekend."

Yes, that's a good idea, especially considering your samples are relatively small.

:)

You too, & all the best for your RPi projects.

Return to “Graphics, sound and multimedia”