aplay does not speak out wav file

Post Reply
sang0627
Posts: 41
Joined: Fri Mar 15, 2019 4:02 pm
languages_spoken: english
ODROIDs: odroid-c2
Has thanked: 5 times
Been thanked: 6 times
Contact:

aplay does not speak out wav file

Unread post by sang0627 » Tue Jan 21, 2020 3:39 pm

'speaker-test -c 2 -t wav -l 2' works fine over HDMI cable to my monitor.
(i.e. my monitor has an headphone jack, so I can here the sound output.)

But, 'aplay sample.wav' does not output any sound.
What should I try to do to resolve this problem?

Here is some information about my odroid-c2 environment.

Code: Select all

mslee@odroid64:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
mslee@odroid64:~$
mslee@odroid64:~$ ls -al /proc/asound
total 0
dr-xr-xr-x   3 root root 0 Jan 21 06:26 .
dr-xr-xr-x 151 root root 0 Jan  1  1970 ..
dr-xr-xr-x   4 root root 0 Jan 21 06:26 card0
-r--r--r--   1 root root 0 Jan 21 06:26 cards
-r--r--r--   1 root root 0 Jan 21 06:26 devices
-r--r--r--   1 root root 0 Jan 21 06:26 hwdep
lrwxrwxrwx   1 root root 5 Jan 21 06:26 ODROIDHDMI -> card0
-r--r--r--   1 root root 0 Jan 21 06:26 pcm
-r--r--r--   1 root root 0 Jan 21 06:26 timers
-r--r--r--   1 root root 0 Jan 21 06:26 version
mslee@odroid64:~$
mslee@odroid64:~$ cat /etc/asound.conf
pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}
mslee@odroid64:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ODROIDHDMI [ODROID-HDMI], device 0: I2S dit-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
mslee@odroid64:~$
I attach these dmesg outputs to compare two different messages when I execute two commands, speaker-test and aplay.

[ dmesg from speaker-out test ]

Code: Select all

[  444.068069] divider=16,frac=33920000,SDMval=4523
[  444.068124] [aml-i2s-dai]i2s dma ffffff80004c2000,phy addr 1573257216,mode 0,ch 2
[  444.068131] ----aml_hw_iec958_init,runtime->rate=48000,sample_rate=4--
[  444.068135] aml_set_spdif_clk rate
[  444.068142] divider=20,frac=33920000,SDMval=5654
[  444.068149] set normal 512 fs /4 fs
[  444.068155] iec958 mode PCM16
[  444.068164] IEC958 16bit
[  444.068170] hdmitx: audio: aout notify rate 48000
[  444.068174] hdmitx: audio: aout notify size 16
[  444.068178] hdmtix: set audio
[  444.068192] hdmitx tx_aud_src = 0
[  444.068217] hdmitx aud_n_para = 6144
[  444.068235] hdmitx set channel status
[  444.068294] 958 with i2s
[  444.070920] aiu i2s playback enable
[  444.070942] audio_hw_958_enable 1
[  450.133438] aiu i2s playback disable
[  450.133452] audio_hw_958_enable 0
[ dmesg from aplay test ]

Code: Select all

[  554.690215] divider=48,frac=33920000,SDMval=13568
[  554.690265] [aml-i2s-dai]i2s dma ffffff80004c2000,phy addr 1573257216,mode 0,ch 2
[  554.690271] ----aml_hw_iec958_init,runtime->rate=16000,sample_rate=10--
[  554.690275] aml_set_spdif_clk rate
[  554.690282] divider=61,frac=1152000,SDMval=576
[  554.690288] set normal 512 fs /4 fs
[  554.690294] iec958 mode PCM16
[  554.690302] IEC958 16bit
[  554.690308] hdmitx: audio: get FS_MAX
[  554.690312] hdmitx: audio: aout notify size 16
[  554.690317] hdmtix: set audio
[  554.690331] hdmitx tx_aud_src = 0
[  554.690357] hdmitx aud_n_para = 6144
[  554.690375] hdmitx set channel status
[  554.690434] 958 with i2s
[  554.690902] aiu i2s playback enable
[  554.690920] audio_hw_958_enable 1
[  588.222947] aiu i2s playback disable
[  588.222961] audio_hw_958_enable 0
[ downloaded sample.wav from internet (i.e. it plays well with pulseaudio which I removed/purged after test ]

Code: Select all

mslee@odroid64:~$ aplay sample.wav
Playing WAVE 'sample.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
mslee@odroid64:~$ mediainfo sample.wav
General
Complete name                            : sample.wav
Format                                   : Wave
File size                                : 2.05 MiB
Duration                                 : 33s 529ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 512 Kbps
Album                                    : YouTube Audio Library
Track name                               : Impact Moderato
Performer                                : Kevin MacLeod
Director                                 : Kevin MacLeod
Genre                                    : Cinematic
Original source form/Name                : YouTube Audio Library

Audio
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 1
Duration                                 : 33s 529ms
Bit rate mode                            : Constant
Bit rate                                 : 512 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 16.0 KHz
Bit depth                                : 16 bits
Stream size                              : 2.05 MiB (100%)

sang0627
Posts: 41
Joined: Fri Mar 15, 2019 4:02 pm
languages_spoken: english
ODROIDs: odroid-c2
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: aplay does not speak out wav file

Unread post by sang0627 » Tue Jan 21, 2020 4:05 pm

After reading viewtopic.php?f=136&t=34190&p=249365&hi ... ay#p249365, I tried to resample my original sample.wav from 16khz to 48khz.
aplay successfully outputs sounds. :)
pulseaudio seems to have internal resampler, so it could play the sample.wav file without problem.

anyway, odroid-c2 has any limitation for sampling rate of audio file?
or should I configure any settings with regard to alsa?

Code: Select all

mslee@odroid64:~$ resample -to 48000 sample.wav sample48.wav
Target sampling-rate set to 48000.000000.
Writing output to "sample48.wav".
Sampling rate conversion factor set to 3.000000

Starting Conversion
......................................................................................................................................
Conversion Finished:  1609422 output samples.

mslee@odroid64:~$ aplay sample48.wav
Playing WAVE 'sample48.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
mslee@odroid64:~$

User avatar
odroid
Site Admin
Posts: 33649
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 500 times
Been thanked: 504 times
Contact:

Re: aplay does not speak out wav file

Unread post by odroid » Tue Jan 21, 2020 5:24 pm

The I2S DAC output (7pin header) supports various sample rates natively via raw ALSA driver from 8Khz to 192Khz.
But the HDMI audio driver supports only 48Khz and we need the PulseAudio as a resampler probably.
These users thanked the author odroid for the post:
sang0627 (Thu Jan 23, 2020 10:58 am)

User avatar
meveric
Posts: 10856
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105)
Has thanked: 32 times
Been thanked: 283 times
Contact:

Re: aplay does not speak out wav file

Unread post by meveric » Tue Jan 21, 2020 6:57 pm

I think the asound.conf is incorrect:

Code: Select all

pcm.!default {
        type plug
        slave {
        pcm "hw:0,0"
                format S32_LE
        }
}
It sets the default format and with that should do the resampling.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

sang0627
Posts: 41
Joined: Fri Mar 15, 2019 4:02 pm
languages_spoken: english
ODROIDs: odroid-c2
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: aplay does not speak out wav file

Unread post by sang0627 » Thu Jan 23, 2020 10:58 am

meveric wrote:
Tue Jan 21, 2020 6:57 pm
I think the asound.conf is incorrect:

Code: Select all

pcm.!default {
        type plug
        slave {
        pcm "hw:0,0"
                format S32_LE
        }
}
It sets the default format and with that should do the resampling.
well, I'm a newbie for audio stuff, so I do not know what is wrong.
I got this error with your suggestion.

Code: Select all

mslee@odroid64:~$ aplay shared/sample.wav
Playing WAVE 'shared/sample.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
aplay: set_params:1297: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 16000
PERIOD_TIME: 128000
PERIOD_SIZE: 2048
PERIOD_BYTES: 8192
PERIODS: 4
BUFFER_TIME: 512000
BUFFER_SIZE: 8192
BUFFER_BYTES: 32768
TICK_TIME: 0
mslee@odroid64:~$ 

User avatar
meveric
Posts: 10856
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105)
Has thanked: 32 times
Been thanked: 283 times
Contact:

Re: aplay does not speak out wav file

Unread post by meveric » Thu Jan 23, 2020 5:12 pm

I compared with my image and yes it seems only to work with pulseaudio active.
That way both paplay and aplay work with different type of input files.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 3 guests