How to manage the virtual MIDI piano keyboard
Active MIDI DJ Console, through the MidiVirtualKeyboard property which encapsulates functionalities of the MidiVirtualKeyboard COM object, implements a graphical gadget called "virtual MIDI piano keyboard" which allows playing notes by pressing the mouse over the available keys or to display notes being played by an external MIDI physical keyboard connected to the system.
The virtual piano keyboard can be displayed with three different orientations as seen on the screenshots below
and can have a variable number of keys with a maximum of 128.
The virtual piano keyboard can be instanced on the user interface of your application through the MidiVirtualKeyboard.Create method; as for all of the other windows control, the virtual piano keyboard can be moved and resized (MidiVirtualKeyboard.Move method), shown or hidden (MidiVirtualKeyboard.Show method), refreshed (MidiVirtualKeyboard.Refresh method) or destroyed (MidiVirtualKeyboard.Destroy method).
Once the virtual piano keyboard has been instanced, the user can establish a connection with an external input MIDI device through the MidiVirtualKeyboard.MidiInputConnect method and with an external output MIDI device through the MidiVirtualKeyboard.MidiOutputConnect method. Disconnection can be respectively managed at a later time through the MidiVirtualKeyboard.MidiInputDisconnect and MidiVirtualKeyboard.MidiOutputDisconnect methods.
Once the connection has been established, the virtual piano keyboard can start sending notes to an eventually connected output MIDI device by clicking keys through the left button of the mouse (but also through his fingers in case of availability of a touch screen) or by calling the MidiVirtualKeyboard.Note method. The container application can be informed when a specific key is pressed or released through the MidiKeyboardNotification event.
In case you should simply need to display on the virtual piano keyboard that a note was played through an external MIDI input device connected to the system, the MidiVirtualKeyboard.Note method allows simulating a key pressure without generating a clone of the same note that would be normally sent to an eventually connected output MIDI device: the purpose of its bSimulated parameter is exactly this.
The range of displayed keys can be modified at any time through the MidiVirtualKeyboard.RangeSet method and its graphical settings can be retrieved and modified through the MidiVirtualKeyboard.GraphicalSettingsGet and MidiVirtualKeyboard.GraphicalSettingsSet methods.
A sample of usage of the MIDI virtual piano keyboard profiling and testing can be found inside the "PianoKeyboard" Visual Basic 6 and Visual C++ projects installed with the component's setup package.