Green Arches Music
Maker - Melody Grid (frmMelodyGrid)
This screen displays all notes of the currently loaded melody, into an MSFlexGrid, using a new row for each note, with columns displaying pitch, volume, instrument etc.
The grid is filled during the form load event, using the MelodyGrid object’s TestMatrix property to reference cells by row and column number. Each row is filled with the corresponding note object’s pitch, volume properties etc.
The first row (number 0) is used for column headings, so the FixedRows property is set to 1.
Cells can be edited by mouse clicking or by typing onto a cell. As FlexGrid does not support direct writing, this is achieved by opening up a text box positioned exactly over the cell, into which the user can type new note data. When the user presses ENTER, the changed data is stored into the tune object, in the note object member corresponding to the current grid row, and the property according to the grid column.
When a melody is played, a yellow highlight is shown over the note currently playing. This is triggered by the noteStarted event of the tune object "ThisTune", which passes the current note object as a parameter. The AbsRef property of the note determines the row of the flexGrid to be highlighted. The appropriate row is found by searching the left col containing the absref for each note, to match it against the absref of the current note being played. This yellow highlight is set back to white CellBackColor by the NoteStopped event. Sort order should be set to bar, beat, tick, to make the moving highlight display meaningful.
To ensure that the highlight does not fall off the visible grid, the TopRow property of the MelodyGrid objevt is reset to 15 less than the current row, every new beat of the bar. Beats of the bar are indicated by the Ticked event of the tune object.
In order to show effectively on the screen, the tone members of the tune collection must be sorted in ascending order by bar, beat, and tick. Two sort command buttons are provided, one by track, the other by bar, beat and tick. These set the range of columns to be sorted, from the col property to the colsel property, then they set the sort property of the flexgrid object to numeric. This causes the grid to be sorted.