2

I wish to play Tones in WPF from a sound card device (not system speaker). Im disappointed to find that apart from playing a beep or a wav file WPF does not have any native way to play simple sound frequencies. ie play(freq, duration);

Looking into using DirectX DirectSound Ive hit a problem on how WPF using windows handles, as Direct X needs a Windows Form handle.

Does anyone have a solution to play tones in WPF?

PrimeTSS
  • 2,683
  • 3
  • 23
  • 26
  • I wouldn't expect WPF (or any modern framework) to be able to generate simple tones like this. Not much practical application for it, and it's relatively easy to create and play your own WAV file containing the tone. – MusiGenesis Aug 13 '09 at 12:27
  • Not sure about no paractical application for it, lets say you want to output different frequencies and waveforms out of the sound card, like an audio generator. Seems a bit resource inefficient to have to first create a WAV file then play it. Especially if you want to change it on the fly! – PrimeTSS Aug 13 '09 at 12:36
  • @Prime: there's obviously a practical application for software synthesis (that's what I do for a living), but that involves a whole lot more than just a simple tone with frequency and duration, which I thought was what you were asking about. If you're actually interested in sound synthesis, I'd ask a different question. – MusiGenesis Aug 13 '09 at 12:51
  • 1
    You should accept answers to your questions by clicking the green check mark next to your favorite answer each question. This will make people more likely to answer your questions in the future, and also give you some more reputation. – SLaks Oct 06 '09 at 21:32

2 Answers2

4

You can always use the WindowInteropHelper to get the native handle for your WPF window.

1

You can use WindowformHost to create window form control and then pass handle of this control to DirectSound, i have done this with DirectShow, it showing video n playing sound for me

Firoz
  • 7,224
  • 10
  • 41
  • 56