Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to play PCM sound file in Ubuntu?

Tags:

linux

pcm

I have a PCM sound file with sample rate 16000, sample bit 16 and channel 1. I want to play it , but there's no software can do. I also tried ffplay like :

ffplay -ar 16000 -ac 1 snake.raw

But still failed. How to play the PCM sound file in Ubuntu?

like image 364
socket Avatar asked Dec 01 '13 17:12

socket


People also ask

Is wav the same as PCM?

PCM and WAV both format contains raw PCM data, the only difference is their header(wav contains a header where pcm doesn't). So if you just add wav header then it will do the tricks. Just get the PCM data and add the wav header on top of the PCM data.


2 Answers

To use ffplay with signed 16-bit little endian raw PCM, specify -f s16le:

ffplay -f s16le -ar 16k -ac 1 snake.raw

For a stereo, 32-bit floating-point, little endian, 48 kHz file specify:

ffplay -f f32le -ar 48k -ac 2 snake.raw

For a list of supported formats for the -f option, use ffplay -formats. -ar is the sample rate and -ac is the number of channels.

like image 50
mark4o Avatar answered Oct 23 '22 12:10

mark4o


You can use play/sox, which should be standard in ubuntu

play -t raw -r 16k -e signed -b 16 -c 1 snake.raw 

-r = sampling rate
-b = sampling precision (bits)
-c = number of channels
like image 30
sanette Avatar answered Oct 23 '22 14:10

sanette