Show - Displaying music in jMusic

This tutorial introduces you to one of the jMusic music utilities - ShowScore. ShowScore displays a score as pseudo notation - half way between a piano roll display and common practice notation. A score, part, or phrase can be viewed with ShowScore with the command . The View class is part of the jm.util packagage so classes using the Show utility will need to include the line import jm.util.*; (This will already be in many classes which require the Write utility for MIDI files.) When a score is viewed in this way it looks like this:

The ShowScore display has a number of features:

  • Each part has a random colour. Notes in the one part will be displayed with the same colour.
  • The intensity of colour indicates the dynamic value of the note. Lighter is louder.
  • Chromatic notes are indicated with a sharp '#' symbol just before their onset.
  • Each phrase has a retangle around it so you can visualise phrase groupings.
  • The ruler bar along the bottom the window is divided into beat increments. Every two beats a taller line is drawn.
  • Clicking and dragging on the ruler bar can expand or contract the horizontal scale of the display.
  • Beat numbers will appear in the ruler bar every two beats when the horizontal scale allows enough space.

At present showing only displays jMusic data and connot be used to edit it. If you want to add that feature, all in the jMusic community would be most grateful to you :-)

Click here to view source.

Lets have a closer look.

import jm.JMC;
import jm.util.*;
Import statements will give us acess to certain classes and packages: *    for the Score, Parts, Phrases etc.
        jm.JMC          for constants like PIANO
        jm.util.*         for View

public final class ShowFractal implements JMC{
public static void main(String[] args){
Score s = new Score("JMDemo - Show Fractal");
Part p = new Part("Piano", PIANO, 0);
Phrase phr = new Phrase(0.0);

// create a phrase of fractal pitches quavers over the full MIDI
// range.

. . . . Fractal generating code goes here . . .

// add the phrase to a part and that part to the score
This code segment is simplified from the Fractal tutorial.

Here it is! Easy isn't it. To display the score simply ask the View class to show an instance of Score, in this case 's'. An optional constructor can take two integer arguments which specify the x,y location of the display window, eg., 20);

Note: We've left out any MIDIfile and jm file saving routines from this explanation, to focus on the visualisation.