Question

Is there some possibility to generate sounds in C#? I mean not just beep or open and play wave-file. I mean build the signal using different kinds of waves (sin, saw, etc.) and their options (frequencies, amplitudes, etc.)

Was it helpful?

Solution

Check out NAudio on codeplex.

NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET. It has been in development since 2001 and has grown to include a wide variety of features. While some parts of the library are relatively new and incomplete, the more mature features have undergone extensive testing and can be quickly used to add audio capabilities to an existing .NET application.

You could either use the library directly, or check out its source code to find out how it works at a low level.

OTHER TIPS

Here's a blog post I wrote about how to create a sine wave with NAudio. Obviously that's just a first step to making a full blown synthesizer as you will also want to create other waveforms, ADSR envelopes, filters etc, but it should at least get you started.

I highly recommend that you look at the platform VST .Net. This would allow you to create your own VSTs in .Net. If you want to do synthesis, you will probably find that is easier to create a VST and host it in your DAW of choice rather than create a once off app. This is because if you create a VST, you don't have to worry about dealing with the audio interface drivers or ASIO etc. https://vstnet.codeplex.com/

Also, you'll also need a set of controls for the user interface. The standard Windows Forms, or WPF controls might do the trick, but synth enthusiasts usually like to see nicely skinned controls. I recently released these controls which behave like normal WPF controls, but are designed for synthesis: https://bitbucket.org/MelbourneDeveloper/vst-controls-.net/

You can use FLooping. It is a library written in F#, providing common building blocks for audio synthesis like oscillators, envelopes, filters, etc. It is currently in an experimental state.

Disclosure: I am the developer of FLooping.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top