Playing piano tones using C #

I am trying to make a simple piano app in C #.

It should be a very simple piano (maximum 5 or 6 keys). I found different alternatives, and the ones I have found so far:

  • consol.beep (); but I feel his sound is not like the tone of a piano.
  • save and play WAV files. I was thinking about getting wav files of piano tones, but I feel that this is a difficult way to do this and it will not be sold, it may take a lot of unnecessary space.

Is there a library for playing piano-like tones or any different tones of different musical instruments?

+7
source share
3 answers

Checkout Downloadable Source for Mike Gold Virtual Piano in C # . I think he has what you are looking for.

You can also check this message: Is it possible to generate a constant sound in C # when setting its frequency? . The main idea is that you have one sample, and you programmatically control the frequency of the sound file, thereby creating another note.

As for libraries that can help you, you can take a look at:

+9
source

Have you thought about using MIDI?

This may be helpful.

See http://grouplab.cpsc.ucalgary.ca/cookbook/index.php/VisualStudio/HowToPlayMIDIInstruments

This is very interesting, it allows you to play sounds in a simple way:

MidiPlayer.Play( new NoteOn( 0, 1, "C4", 127 ) ); 

You can also take a look at this code project page. See http://www.codeproject.com/KB/audio-video/MIDIToolkit.aspx

+5
source

saving and playing WAV files, which I thought about getting wav piano files, but I feel that this is a difficult way to do this, and it will not be sold can take up a lot of unnecessary space

I don’t know what level of realism you are looking for, but high-level digital pianos have several digital readouts per key to represent different dynamics of hard / soft keystrokes, so I wouldn’t rule it out because of the possibility, A lot of attention is paid to polyphony, those. How many notes can be heard right away.

Minor pitch changes can reduce the number of samples required, for example. one note can usually be split up / down into several semitones without too much degradation.

Alternatively, you can watch the playback of MIDI samples. Almost every modern sound card has a base 128 MIDI patches, although the quality can vary greatly.

+1
source

All Articles