TransWikia.com

How to play a wave file using Windows Multimedia API (winmm.dll) in WPF?

Stack Overflow Asked by Shiasu-sama on February 7, 2021

I’m working on a wave file playback system, but I’m having trouble getting proper playback output using winmm.dll

The problems I’m experiencing are:

  1. The playback stops abruptly.
  2. The playback speeds up or breaks up or both.
  3. There is no playback at all.
  4. The ‘Stop’ method causes the system to hang on a Thread.Join call.

I do realize that there are alternatives to playing sound files in C#, WPF, but I’m trying to achieve it through winmm.dll with .wav files specifically because it will allow me *(I hope) to build specific features such as: Wave File Visualization and Sound Effect Filters.

I have looked at this Code Project link:

Programming Audio Effects in C#

It’s very insightful, but I’m unable to achieve similar results in WPF. I’m not sure if the problems have to do with Garbage Collection that works differently from Windows Forms to WPF.

Here’s my project on GitHub:

Wave Player – Base – WPF and Windows Forms

The solution has 2 projects: One is Windows Forms and the other is WPF.
The Windows Forms project works fine, the WPF doesn’t. Both the projects, however, uses the same winmm.dll code logic.

I’ve also found this Microsoft link on ‘Waveform Audio’ :

Microsoft – About Waveform Audio

Any help or advice will be appreciated.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP