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

**URL:** https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130
**Category:** mangOH Red
**Created:** [March 24, 2020, 3:48pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130 "2020-03-24T15:48:35Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![sciscitatio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sciscitatio](https://mangoh.discourse.group/u/sciscitatio)
#### Post date: [March 24, 2020, 3:48pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/1 "2020-03-24T15:48:36Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [March 25, 2020, 1:54am UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/2 "2020-03-25T01:54:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sciscitatio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sciscitatio](https://mangoh.discourse.group/u/sciscitatio)
#### Post date: [March 25, 2020, 11:30am UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/3 "2020-03-25T11:30:03Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [March 25, 2020, 12:03pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/4 "2020-03-25T12:03:26Z")

</div>

how about using AT command?

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

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

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [March 25, 2020, 12:06pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/5 "2020-03-25T12:06:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sciscitatio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sciscitatio](https://mangoh.discourse.group/u/sciscitatio)
#### Post date: [March 26, 2020, 12:31pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/6 "2020-03-26T12:31:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [March 26, 2020, 4:11pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/7 "2020-03-26T16:11:48Z")

</div>

You can send AT command within the app

---

<div class="post-metadata">

### Author: ![sciscitatio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sciscitatio](https://mangoh.discourse.group/u/sciscitatio)
#### Post date: [March 30, 2020, 8:04am UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/8 "2020-03-30T08:04:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [March 30, 2020, 10:45am UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/9 "2020-03-30T10:45:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sciscitatio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sciscitatio](https://mangoh.discourse.group/u/sciscitatio)
#### Post date: [March 30, 2020, 1:37pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/10 "2020-03-30T13:37:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [March 30, 2020, 2:43pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/11 "2020-03-30T14:43:56Z")

</div>

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.

> **[\[solved\] Cannot find pa\_audio\_default with meaningful content](https://forum.legato.io/t/solved-cannot-find-pa-audio-default-with-meaningful-content/3420/5)**
>
> I have tried sending a message to the guy stating that he have gotten it to work as I am very reluctant in waking up dead threads to ask for an out of topic question. But I would like to get his attention non-the-less

---

<div class="post-metadata">

### Author: ![sciscitatio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sciscitatio](https://mangoh.discourse.group/u/sciscitatio)
#### Post date: [March 31, 2020, 12:39pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/12 "2020-03-31T12:39:52Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![sciscitatio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sciscitatio](https://mangoh.discourse.group/u/sciscitatio)
#### Post date: [March 31, 2020, 3:29pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/13 "2020-03-31T15:29:56Z")

</div>

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]

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [May 5, 2020, 5:11am UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/14 "2020-05-05T05:11:40Z")

</div>

I don’t see problem on my WP7607 module even no AT command:

root@swi-mdm9x28-wp:~# amix ‘PRI\_RX Audio Mixer MultiMedia1’ 1  
root@swi-mdm9x28-wp:~# amix ‘Sys Clock Enable Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Capture PGA Mute Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Digital Playback Mute Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Digital Playback Volume’ 192  
capability: volume  
dBscale- min=-72.00dB step=0.37dB max=2.55dB mute=1  
min = ffffe3e0 max = ffval = c0Value = 1.92dB  
root@swi-mdm9x28-wp:~# amix ‘Speaker Playback Volume’ 57  
capability: volume  
dBscale- min=-57.00dB step=1.00dB max=0.63dB mute=0  
min = ffffe9bc max = 3fval = 39Value = 0.57dB  
root@swi-mdm9x28-wp:~# amix ‘Speaker Playback Mute Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTP VDD Enable Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTN VDD Enable Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTP Mute Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTN Mute Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTP Enable Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTN Enable Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘ADC Mute All Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Speaker Function’ 1  
Value: 1 idx:0  
[66.043157] wm8944-codec wm8944-codec: ASoC: DAPM unknown pin Ext Spk Bottom Pos  
[66.050604] wm8944-codec wm8944-codec: ASoC: DAPM unknown pin Ext Spk Bottom Neg  
[66.057830] wm8944-codec wm8944-codec: ASoC: DAPM unknown pin Ext Spk Top Pos  
[66.065434] wm8944-codec wm8944-codec: ASoC: DAPM unknown pin Ext Spk Top Neg  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTP Mixer Speak PGA to Speaker P Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘SPKOUTN Mixer Speak PGA to Speaker N Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Speaker Mixer DAC to Speak PGA Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘MultiMedia1 Mixer PRI\_TX’ 1  
root@swi-mdm9x28-wp:~# amix ‘Input PGA Enable Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Left ADC Enable Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Input PGA AUX to Invert InPGA Switch’ 1  
root@swi-mdm9x28-wp:~# amix ‘Input PGA IN1 to InPGA Switch’ 1  
Value: 1 idx:0  
root@swi-mdm9x28-wp:~# amix ‘PRI\_MI2S\_RX Audio Mixer MultiMedia1’ 1  
root@swi-mdm9x28-wp:~# aplay ./0-to-9.wav  
aplay: Playing ‘./0-to-9.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  
[94.597620] afe\_send\_custom\_topology\_block: AFE SVC cal has invalid size: 0!  
[94.603809] afe\_send\_custom\_topology: No cal sent for cal\_index 7! ret -22  
[94.611093] afe\_get\_cal\_topology\_id: [AFE\_TOPOLOGY\_CAL] not initialized for this port 4096  
[94.640234] q6asm\_callback: cmd = 0x10da1 returned error = 0x3  
[94.645162] q6asm\_send\_cal: DSP returned error[3] audio audstrm cal send  
[94.662618] adm\_callback: cmd = 0x10328 returned error = 0x3  
[94.667332] send\_adm\_cal\_block: DSP returned error[ADSP\_EUNSUPPORTED]  
Aplay: Done playing  
[100.715822] BUG: sleeping function called from invalid context at /usr/src/kernel/kernel/locking/mutex.c:97  
[100.724533] in\_atomic(): 0, irqs\_disabled(): 128, pid: 1759, name: aplay  
root@swi-mdm9x28-wp:~# pwd  
/home/root  
root@swi-mdm9x28-wp:~# cm info  
Device: WP7607  
IMEI: 359779081234565  
IMEISV: 6  
FSN: VN730485080103  
Firmware Version: SWI9X07Y\_02.28.03.05 000000 jenkins 2019/07/08 11:04:16  
Bootloader Version: SWI9X07Y\_[134.606893] i2c-msm-v2 78b8000.i2c: NACK: slave not responding, ensure its powered: msgs(n:1 cur:0 tx) bc(rx:0 tx:2) mode:FIFO slv\_addr:0x3a MSTR\_STS:0x0c1300c8 OPER:0x00000090  
02.28.03.05 000000 jenkins 2019/07/08 11:04:16  
[134.628097] i2c-msm-v2 78b8000.i2c: NACK: slave not responding, ensure its powered: msgs(n:1 cur:0 tx) bc(rx:0 tx:2) mode:FIFO slv\_addr:0x3a MSTR\_STS:0x0c1300c8 OPER:0x00000090  
MCU Version: 002.011  
PRI Part Number (PN): 9908958  
PRI Revision: 001.000  
Carrier PRI Name: GENERIC  
Carrier PRI Revision: 002.073\_000  
SKU: 1104301  
Last Reset Cause: Reset, User Requested  
Resets Count: Expected: 101 Unexpected: 3  
root@swi-mdm9x28-wp:~#

---

<div class="post-metadata">

### Author: ![raghavasanikam](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@raghavasanikam](https://mangoh.discourse.group/u/raghavasanikam)
#### Post date: [June 16, 2021, 12:32pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/15 "2021-06-16T12:32:56Z")

</div>

Do you guys have any solution for this ? I have exactly the same problem on mangOH red with wp7608.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 16, 2021, 12:35pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/16 "2021-06-16T12:35:31Z")

</div>

how about using AT command?

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

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

---

<div class="post-metadata">

### Author: ![raghavasanikam](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@raghavasanikam](https://mangoh.discourse.group/u/raghavasanikam)
#### Post date: [June 16, 2021, 1:31pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/17 "2021-06-16T13:31:44Z")

</div>

AT Command playback works. I do not want to use AT commands for my application use case. I need to read and write samples from/to mic locally for a VoIP application.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 16, 2021, 2:44pm UTC](https://mangoh.discourse.group/t/how-do-i-play-a-simple-audio-file-from-the-cmd-line/4130/18 "2021-06-16T14:44:36Z")

</div>

How about the sample app audioPlaybackRec :

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