Playing sound over PWM (WinCE)

We’re currently playing beeps for user feedback, but as it sounds “cheap”, we’re trying to play pre-recorded sounds instead.

I’m wondering what’s needed for us to be able to play sounds (.mp3, .aac, or .ogg or any other audio format) over the PWM.

We’re working with SilverLight and C/C++.

Kind regards,

Hi @MGlolenstine ,

Not sure if you really want to play something over PWM?
The iMX6 has an audio Codec with Analog Stereo Audio output, this can easily be used through the System Sound API (WAVEAPI).

If you really want to use the PWM output for sound you will have to write something by yourself, but the quality will be much worse than over the analog audio output.

We have a PCB made for T20, VF50 and VF61, and because they don’t have audio Codecs, we didn’t route out the audio pins.
We are still deciding if it’s worth routing out the pins, but your answer accounts for both outcomes.

Thanks for the help!

Kind regards,

Ok, so we have now connected the speaker to the audio output on the iMX6.
We play the audio using

WCHAR *soundPath = L"FlashDisk\\MT\\Sounds\\sound.wav";

and if we wait a few seconds between the sound plays, we get a weird “fade in” effect, even though sound.wav is just a triangle wave without fade ins or outs.
We tried playing an event sound to see if the problem was having the file on the FlashDisk, but the same problem occurred.

Any help would be greatly appreciated.

Kind regards,

Hi @MGlolenstine ,

What you experience is a feature of the Audio Codec (SGTL5000). It ramps up the audio to avoid pop sounds.
This can be disabled by writing to the Codec Registers.

you can check here (Register CHIP_ADCDAC_CTRL 0x000E, Bit 9 VOL_RAMP_ENABLE):

You can use the AudioCodec Tool to change the settings on the fly and test the results:

Just go to Register 0x00E and wite the value 0x003c (from 0x033c)

You can also make these changes persistent by using registry entries:

So in this case you should add:


this will clear Bit 8 and bit 9 removing the RAMP functionality

Where should I add "Reg0x0e"=dword:0x03000000 to?
On the page you linked, I found the path HKEY_LOCAL_MACHINE\Drivers\Builtin\Audio for headphone volume, but I see no registry path for the Reg0x0e.
Should that even be added to the registers?

Kind regards,

Hi @MGlolenstine ,

The Reg0x0e"=dword:0x03000000 should go to the same place as all other audio registry settings: