How to create sounds in C#?
Any idea of class, that can be used to crate sounds?
Printable View
How to create sounds in C#?
Any idea of class, that can be used to crate sounds?
Do you want to play wav files, mp3 files, etc..?
No
I want to design a small program that can produce sounds.
I am thinking of a class that when u give the frequency produce the sound…
Or something like that…
I have no idea. Wish I did, it would be pretty cool. I am sure there are ways, just none that I know. Sorry.
i already have though of that...it is the only thing that the framework is missing: sound! maybe with directx or something..
Direct access to the sound card might be a bit limited from the dot net framework, but nothing is stopping you from creating a wav file and playing that with windows media player. You can use the player through COM Interop.
Or, you might want to look at the WaveIn/OutXXX functions in the platform SDK.
If you've used DirectX, then you might find the DirectSound functions pretty straight forward.
Anyone know how to play mp3's then? I would love to make a C# mp3 player.
Playing an MP3 is easy if you've got Windows Media Player installed (like MS would let you not install it :D ).
Add the Windows Media Player ActiveX control to your toolbox and then drop it onto a form in your Winform project...
This code will play a song:
PHP Code:axMediaPlayer1.FileName = FileNameAndPathToMP3;
axMediaPlayer1.Play();
Very cool. Thanks...
Ok that is all nice..:rolleyes: :rolleyes:
But is there a way to play some sounds?
:D
Seems only through media player.
The .NET framework has nearly no multimedia capabilities. This will change with the release of DirectX 9, which will provide a .NET interface (just as DirectX 7 finally provided a VB interface).
With DirectX 9 you will then be able to do advanced (fast) 2D, 3D, Sound and Music programming, as well as using DirectShow to display movies or play MP3s, DirectPlay for network connections beyond the encapsulated protocols of the .NET framework etc.
My opinion? The high performance of DirectX is nice for .NET, but that won't make it any more useful for games, and it's sad that the only multimedia part of the CLR is non-portable.
*bump*
bump yourself...
there's no easy way to do what you are asking.
you might need to look into APIs from SoundBlaster etc. or you can create the WAV file yourself and play it via the media player.
Maybe al little late (8 years) but you could usevb Code:
Console.Beep(frequency,duration)