I have a 16-bit WAV file, the header of the file as below:

WAV header Information:
RIFF            : RIFF
Chunk Size      : 5719002
Format          : WAVE

Sub-Chunk 1 Information:
Sub-Chunk 1 ID  : fmt 
Sub-Chunk Size  : 16
Audio Format    : 1 (PCM = 1)
Channels        : 1 (MONO = 1, STERIO = 2)
Sampling Rate   : 250000 Hz
Byte Rate       : 500000 (500000)
block Alignment : 2 (2)
Bits Per Sample : 16 bits

Sub-Chunk 2 Information:
Sub-Chunk 2 ID  : data
Sub-Chunk Size  : 5718016

I am gonna develop a program that play it in my pi 3 b+ with PWM with wiringPi api. I read the data from the WAV file, and output it by the api void pwmWrite (int pin, int value), the value was set to the value from the WAV file data. But i got a noise not a music.

My question is :

In the api pwmSetRange (unsigned int range) the type of range is unsigned int, and in void pwmWrite (int pin, int value), the type of range is int, and the range of value is 0-1024 from the reference.

But my WAV file is 16-bit, the range is —32768-32767, so i am confused to set the range and value in those api.

Looking forward to receive answers.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.