To play the piano in the program, simply click the left mouse button on a virtual key on the keyboard. The piano only contains a little more than one octave, but you can easily extend it given the extensible design shown below:įigure 2 - Virtual Piano UML Design reverse engineered using WithClass 2000 In this article we use DirectSound in conjunction with GDI+ (instead of DirectDraw) to create a virtual piano. Table 1 - DirectSound classes used in this project The buffer object where audio data is written to and played from. The description object for the buffer that sets some of the properties of the buffer The table below lists the classes in the assembly: Playing the sound is accomplished through a method on the secondary buffer. You can also change properties of the secondary buffer (such as frequency) to alter the attributes of the soundĤ. All sound is played using this buffer object. Use the device, description, and the name of the. The description contains information describing how the buffer will behave.ģ. (Here we just use a default constructor for the default device.)Ģ. There are four steps to using the DirectSound technology in C#.ġ. This application takes advantage of DirectSound, one of the many media technologies packaged with DirectX 9.
The API's usually involved COM which sometimes requires a degree in Rocket Science or equivalent. NET, I was loathe to touch those convoluted API's. I was impressed to find that it has several assemblies encapsulating. Having finally got around to installing DirectX 9.0.