Keyboard Simulator Benchmark
The keyboard simulator is a simple graphical representation of a piano
keyboard that allows the user to press a key and play the corresponding
note. The pressed note is also placed in a musical staff within the program,
and the user may replay all of the notes that have been played, allowing
the user to create a simplistic musical composition.
This benchmark utilizes several different interface styles. The primary
function of the program is to provide both visual and audio feedback to
the user that a virtual piano key has been pressed. The user may also insert
a note anywhere into the staff, as well as delete old notes. These features
are indicative of a direct manipulation style of interface. The benchmark
also uses several menus, which enables it to test the menu interface style.
Single character commands (keyboard shortcuts) are also included for more
efficient use of the program.
This benchmark is similar to many keyboard and midi simulators found
on the market today. CakeWalk, a popular music composition program
for Macintosh and Windows, allows the user to press virtual piano keys
to compose music. The
midikeys program available on IRIX (SGI) platforms
is another program which provides a virtual keyboard on which the user
The keyboard simulator benchmark tests the ability of the implementing
toolkit to provide semantic feedback to the user in the form of polygon
coloring and sound playing using a MIDI interface. The benchmark also tests
the ability to directly manipulate the notes through insertion and deletion.
The menus and single character commands (keyboard shortcuts) are quite
typical of many commercial applications and are direct representations
of the menu and single character command interface styles. Since both playing
sounds and supporting undo/multiple undo are common features in many modern
programs, these features were included to test the capabilities of the
toolkit being used to implement the benchmark. The keyboard simulator benchmark
also tests the ability of the implementing system to draw different filled
and unfilled polygonal shapes.
The figure below shows a sample implementation of the keyboard simulator.
The program has two main sections:
The top section, which contains a musical staff and a play button.
The staff consists of five horizontal lines that are equally spaced.
The staff is placed in panel that can be scrolled on the x-axis. In other
words, as new notes are played, if more are drawn than can fit in the initially
visible staff area, the staff is scrolled to the left to provide more room
for drawing notes.
The user can insert a note anywhere in the staff by clicking the mouse
while over the staff. The staff only allows the user to place the cursor,
insert notes, or delete notes.
To the right of the staff and scrollable panel, there is a button labeled
The bottom section, which contains a 'keyboard' and a group of three radio
The keyboard contains several sets of polygons: the main set of keys, which
are 14 rectangles, and the sharps/flats which are rectangles about half
the length and size of the main keys (see figure).
The keys are also labeled according to their corresponding note - allowing
for novice users to know which key is being played.
A panel beside the keyboard, which has a label 'Notes:', below which are
three radio buttons - these buttons are mutually exclusive.
The buttons are labeled, from top to bottom, 'Quarter Note', 'Half Note',
and 'Whole Note'.
There are two command menus located at the top of the main window. These
Note: the keyboard shortcuts refer to a 'Meta-?' key combination,
where 'Meta' is the appropriate key for the platform that the benchmark
is implemented on, such as Esc, Ctrl, or Cmd, and '?' is the other key,
to be pressed concurrently.
File - which contains:
Quit - choosing this causes the program to exit. There should also
be a keyboard shortcut equivalent for the quit option, of the form 'Meta-q'.
Save - allows the current composition (all of the notes in the staff)
to be saved to a file. A dialog should pop-up when 'Save' is chosen, allowing
the user to choose a file name. A keyboard shortcut of 'Meta-s' should
The format for the saved file is not particularly important. It should
simply allow a file to be saved (and later opened) that accurately represents
the current notes in the staff.
Open - allows the user to open a previously generated composition.
Choosing this option should open a file choosing dialog. The notes
from the file should be inserted into an empty staff. 'Meta-o' should be
the keyboard shortcut for 'Open'.
Edit - which contains:
Delete - the note to the left of the cursor is deleted.The backspace/delete
key should provide the shortcut functionality.
Undo - the last action performed is undone. For example, if
a note is cut, pressing undo un-cuts the note. If a note is pasted,
undo should un-insert it. The undo function should allow multiple
undo, so a history of actions involving cut/past/delete and new note playing
(which is just inserting the notes at the rightmost end of the staff) should
be kept to be undone. The keyboard shortcut for undo should be 'Meta-z'.
Keyboard Shortcuts: There should be shortcut keys available
for switching between the three radio buttons for the note types:
'q': enables the Quarter Note radio button
'h': enables the Half Note radio button
'w': enables the Whole Note radio button
Playing a Key
A key is played when the user moves the mouse (pointer) inside one of the
rectangles representing a key and presses the mouse button. (Left mouse
button only if a multiple button mouse).
Important: The sharps and flats (the smaller, black keys) are present
only for consistency with a piano keyboard. For this benchmark, they can't
actually be played so should not provide any semantic feedback to the user
indicating that they have been pressed, and no notes should sound/be drawn
if the user presses a mouse button when the mouse is inside one of the
When a key is played, the rectangle representing that key should change
color for 1/2 of a second. If the current foreground color for that key
is light gray, it should turn dark gray for 1/2 of a second, then back
to the foreground color. (Note: the length of the color change can be modified
for a more realistic keyboard effect if necessary).
Synchronously with the key press, the note should be played. For more information
on playing the sounds, see the section 'Playing Sounds' below
The key press also results in the corresponding note being drawn onto the
staff in the top section of the program. For more info on the drawing of
the note, see the section entitled
'Drawing Notes' below.
Important: The radio button which is currently selected should directly
affect both the sound that is played as well as the note that is drawn
in the staff. Each key should be played as a quarter, half, or whole
note, and the note that is drawn should correspond to the radio button
that was selected when it was played (see 'Drawing Notes').
Sounds should be played using MIDI and the computer's sound card.
The sounds will be for each of the keys (two octaves), and will include
quarter, half, and whole notes. Since the sharps/flats are present for
visual consistency with a piano keyboard and can't actually be 'played',
no sounds should be played for the sharps and flats.
The sounds will be played when the user presses a key on the keyboard,
and when all of the notes are being played (when the 'Play' button is pushed
- see 'Playing a Composition' below).
A note is drawn in the staff when a user plays a key.
The notes should be drawn from left to right in the staff. If there is
no more room visible in the staff, the staff panel should auto scroll to
the left when a note is added.
The staff should behave like a 'text field', with the individual notes
acting like characters in a text field. The user should be able to
select a location by clicking in that location, and the user should be
able to either (a) delete the note to the left, or (b) insert a new note.
Group selection, cut and paste, and drag and drop do not need to
Note: If the user has a specific location selected on the staff
(by clicking with the mouse), a newly played note should be inserted into
this location. If there are notes to the right of this insertion
point, those notes should be shifted to the right.
The cursor, to indicate the current insert/delete position, should be placed
directly over a note. In effect, the cursor should 'snap' to the closest
The user can insert a note into the staff. It may be useful to have the
divided into an invisible horizontal grid, so that if the user selects
anywhere in a cell the note
is inserted at a specific horizontal position. This grid will
allow equal horizontal spacing of the notes in the staff.
If the user deletes a note, any notes to the right of this note should
shift to the left - effectively removing any 'blank' spaces in the staff.
Likewise, If a note is inserted with blank space to the left of it, the
note should be shifted to the left until the blank space is removed.
The basic idea is that the notes should be 'packed' from the left to the
right. Any blank space between notes should be removed by re-drawing the
By convention, notes between the first 'C' key and up to (but not including)
the first 'B' are drawn with their tail up and attached to the right side
of the circle, while keys from the 'B' through the next octave are drawn
with their tail pointing down from the left side of the circle.
In the figure above - the 14 notes drawn on the staff correspond to the
14 keys from left to right. The first six notes drawn are from the C to
B range, while the next eight are from B through the next octave.
Quarter notes should be filled circles with tails.
Half notes are non-filled circles with tails.
Whole notes are non-filled circles with no tails.
The exact size is not essential - but it is important that the circle part
of each note should fit between the lines of the staff - so the diameter
should be equivalent to the line spacing of the staff. The tail should
be about twice the diameter.
The notes should be drawn with an equidistant spacing - the exact distance
is up to the implementer of the benchmark, but approximately 3 times the
diameter of the note is recommended.
Playing a Composition
When the user chooses Undo from the Edit menu (or presses
the keyboard shortcut key), the last action (cut, delete, paste/insert
-- including a new note added by playing a key) should be undone.
The benchmark should support multiple undo - so if the user chooses undo
three times after pressing three piano keys in a row, the last three notes
added to the staff should be removed.
If the user inserts a note, then deletes a different note, then inserts
another note, pressing undo three times should do the following: remove
the last note played, un-delete the note, remove the note.
When the 'Play' button is pressed, the appropriate sounds for all of the
notes currently in the staff will be played.
The notes in the staff should be played from left to right.
It may be necessary, depending upon the implementation, to have a short
delay between notes if, when played, they all run together.
Because there are quarter, half, and whole notes for each key, however,
it should be possible to just play the notes one after the other to get
the correct sound.
Features Not Included
In order to keep the number of sounds to play to a reasonable number, the
sharp/flat keys on the keyboard are not actually implemented. This restriction
also eliminates some of the complicated symbols that need to be drawn in
the staff. Since drawing the notes already tests the ability of the implementing
system to draw polygons, adding more symbols just complicates the benchmark
without adding more testing utility.
Daniel A Yocum