I am trying to build a virtual piano in C#, and want a way to create a scale of musical notes from scratch.
I know that I can simply find or create a bunch of .wav files, 1 for each note, but this will create too much space on the User's Hard disk and not be very intuative for myself in the future.
So is there a way to create a proper sound - e.g B flat, in C# without using a .wav file, all in code thorugh c#, and if not, is there a way to do this in a different language - C++.
Thanks, I have tried to make it as clear as possible.
To do this you need a Sound block ( play sound ), with Meow selected in the dropdown box. Now when you click the green flag and move the mouse around, the cat will meow all of the time.
I think this looks like it should get you started:
http://blogs.msdn.com/b/dawate/archive/2009/06/24/intro-to-audio-programming-part-3-synthesizing-simple-wave-audio-using-c.aspx
EDIT : I should add that generating sounds without .wav samples and emulating a piano are at odds with each other.
If you want to get a 'real' piano sound, it's best to work with samples (hold them in memory if you don't want to keep them in the filesystem). If you just want a simple way of emitting accurate notes (which sound nothing like a real piano) then doing it programmatically is the way to go!
If you want to emulate a piano specifically you only have two options, one of which is to use samples and the other is physical modelling. Physical modelling requires some pretty advanced knowledge of DSP (filtering, convolution, etc.) and a piano would be a challenging instrument to tackle but it has been done by the likes of Pianoteq
On the subject of samples, to create a piano that is anywhere near a convincing analogue you would ideally require more than one sample per note for different velocities with crossfades between them but you can probably get away with using a sample over a limited range of notes to reduce the total number of samples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With