How do I play a simple audio file from the cmd line?

A simple enough task you would think. How do I play a wav file from the command line?

aplay myfile.wav returns the following

aplay: Playing ‘myfile.wav’:Signed 16 bit Little Endian
buffer_bytes = (1024,1024) omin=0 omax=0 int=1 empty=0
period_bytes = (128,128) omin=0 omax=0 int=1 empty=0
cannot prepare channel: errno =-22
Aplay:Failed in pcm_prepare

Note I only want to do this from CLI. I am NOT a software developer, I’m just trying to check out some magoh red boards before sending them off to my software developer.

Our final objective is to play audio from out custom linux application (won’t be using legato platform)

cm info all
Device: WP7607
IMEI: 359779080143064
IMEISV: 5
FSN: VN851171271310
Firmware Version: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
Bootloader Version: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
MCU Version: 002.009
PRI Part Number (PN): 9908767
PRI Revision: 001.001
Carrier PRI Name: GENERIC
Carrier PRI Revision: 002.041_000
SKU: 1104218
Last Reset Cause: Power Down
Resets Count: Expected: 15 Unexpected: 0

you can use the sample app audioPlaybackRec :

app runProc audioPlaybackRec audioPlaybackRecTest --exe=audioPlaybackRecTest – PB_SAMPLES MIC /usr/share/sounds/0-to-9.wav 1 8000 16

Nope that doesn’t work, and the error doesn’t really help much.

app runProc audioPlaybackRec audioPlaybackRecTest --exe=audioPlaybackRecTest - PB_SAMPLES MIC /home/root/test.wav 1 8000 16

Invalid arguments. Try --help.

I know I’ve used aplay on another board some while ago, so why isn’t this one working?

how about using AT command?

at!avcfg=5,1,2
AT!AVSETPROFILE=5

AT!AVAUDIO=1,1,/home/root/0-to-9_8k.wav

i remember i try on WP76 R9, it is working fine for aplay:

For WP76 R9:
amix ‘PRI_RX Audio Mixer MultiMedia1’ 1
amix ‘Sys Clock Enable Switch’ 1
amix ‘Capture PGA Mute Switch’ 1
amix ‘Digital Playback Mute Switch’ 1
amix ‘Digital Playback Volume’ 192
amix ‘Speaker Playback Volume’ 57
amix ‘Speaker Playback Mute Switch’ 1
amix ‘SPKOUTP VDD Enable Switch’ 1
amix ‘SPKOUTN VDD Enable Switch’ 1
amix ‘SPKOUTP Mute Switch’ 1
amix ‘SPKOUTN Mute Switch’ 1
amix ‘SPKOUTP Enable Switch’ 1
amix ‘SPKOUTN Enable Switch’ 1
amix ‘ADC Mute All Switch’ 1
amix ‘Speaker Function’ 1
amix ‘SPKOUTP Mixer Speak PGA to Speaker P Switch’ 1
amix ‘SPKOUTN Mixer Speak PGA to Speaker N Switch’ 1
amix ‘Speaker Mixer DAC to Speak PGA Switch’ 1
amix ‘MultiMedia1 Mixer PRI_TX’ 1
amix ‘Input PGA Enable Switch’ 1
amix ‘Left ADC Enable Switch’ 1
amix ‘Input PGA AUX to Invert InPGA Switch’ 1
amix ‘Input PGA IN1 to InPGA Switch’ 1
amix ‘PRI_MI2S_RX Audio Mixer MultiMedia1’ 1
aplay 0-to-9_8k.wav

Strangely enough, I tried the AT!AVAUDIO method and it played the file. I then tried again using aplay and it worked. This is consistent: aplay will only work if I microcom to /dev/ttyAT and use the AT!AVAUDIO command.

The amix commands don’t work, they just report “control not found”

This helps me to test the hardware - but it is obviously going to make things messy to play audio files from a custom Linux program. So what exactly is the missing part here, what did the AT command do exactly to make it work?

Or, to put it another way, what is the correct procedure to play audio from a custom Linux application?

Thanks

You can send AT command within the app

Yes I know that, but I would like to know what is the AT command doing that makes it work?

We may not be only playing files (e.g. using a text-to-speech library) so may want to output to the sound device directly. Also, we will need to control the mixer settings to allow separate left/right balance.

Also, I plan to use a different codec IC. How would that affect the operation of the built-in AT command for playing / volume adjustment?

Thanks

Didn’t you say “aplay will only work if I microcom to /dev/ttyAT and use the AT!AVAUDIO command”?
You can play a dummy file after power on.
After that you can use aplay.

I know, but that really is a bodge. I would like to know WHY, so I can make sure that it will always work, in all circumstances and preferably for future revisions of hardware & firmware. It’s asking for trouble relying on some obscure undocumented artifact of a some function.

I also need the mixer to set left & right volume but that doesn’t seem to work either.

This will be used for a commercial product, so I need a consistent & reliable operation.

Can you try R9?
I remember it was working fine for aplay

Also be careful of the single quote character

You can also compre the amix before and after those AT command.

Er, I am using R9!

There is something seriously half-assed about this software platform. amix before & after yeilds exactly the same (which incidentally exposes something else broken - the redirect > doesn’t work so I had to use PuTTY logging to capture the output), I won’t post the output here as it’s 1600 lines ling.

This is what I enter from the cmd line

root@swi-mdm9x28-wp:~# aplay ready.wav
aplay: Playing 'ready.wav':Signed 16 bit Little Endian
buffer_bytes = (1024,1024) omin=0 omax=0 int=1 empty=0
period_bytes = (128,128) omin=0 omax=0 int=1 empty=0
cannot prepare channel: errno =-22
Aplay:Failed in pcm_prepare

microcom /dev/ttyAT
AT!AVAUDIO=1,1,/home/root/ready.wav
OK
<CTRL-AX to quit>

root@swi-mdm9x28-wp:~# aplay ready.wav
aplay: Playing 'ready.wav':Signed 16 bit Little Endian
buffer_bytes = (1024,1024) omin=0 omax=0 int=1 empty=0
period_bytes = (128,128) omin=0 omax=0 int=1 empty=0
Aplay: Done playing

So in the absence of anything helpful, let’s start with the error message. What does errno -22 mean?

Maybe this will help: this is the output from dmesg after each stage:

aplay attempt - fail
[ 105.398240] MDM Media1: ASoC: no backend DAIs enabled for MDM Media1
[ 105.402660] q6asm_callback: cmd = 0x10bcd returned error = 0x1
[ 105.402741] __q6asm_cmd: DSP returned error[ADSP_EFAILED] opcode 68557
[ 105.398240] MDM Media1: ASoC: no backend DAIs enabled for MDM Media1
[ 105.402660] q6asm_callback: cmd = 0x10bcd returned error = 0x1
[ 105.402741] __q6asm_cmd: DSP returned error[ADSP_EFAILED] opcode 68557
[ 121.121063] sierra_startup_monitor
[ 150.685702] MDM Media1: ASoC: no backend DAIs enabled for MDM Media1
[ 150.689626] q6asm_callback: cmd = 0x10bcd returned error = 0x1
[ 150.689710] __q6asm_cmd: DSP returned error[ADSP_EFAILED] opcode 68557

AT command play - works
[ 194.027962] afe_send_custom_topology_block: AFE SVC cal has invalid size: 0!
[ 194.027990] afe_send_custom_topology: No cal sent for cal_index 7! ret -22
[ 194.028006] afe_get_cal_topology_id: [AFE_TOPOLOGY_CAL] not initialized for this port 4096
[ 194.046531] q6asm_callback: cmd = 0x10da1 returned error = 0x3
[ 194.046615] q6asm_send_cal: DSP returned error[3] audio audstrm cal send
[ 194.054185] adm_callback: cmd = 0x10328 returned error = 0x3
[ 194.054257] send_adm_cal_block: DSP returned error[ADSP_EUNSUPPORTED]
[ 194.614128] aplay (1773) used greatest stack depth: 4520 bytes left

aplay command - works
[ 234.309229] afe_get_cal_topology_id: [AFE_TOPOLOGY_CAL] not initialized for this port 4096
[ 234.321106] q6asm_callback: cmd = 0x10da1 returned error = 0x3
[ 234.321169] q6asm_send_cal: DSP returned error[3] audio audstrm cal send
[ 234.325585] adm_callback: cmd = 0x10328 returned error = 0x3
[ 234.325637] send_adm_cal_block: DSP returned error[ADSP_EUNSUPPORTED]