At the Sounding Edge: Music Notation Software for Linux, Part 2

by Dave Phillips

Last month I introduced the ABC music notation system. This month, I continue our tour of notation programs for Linux with a look at the Common Music Notation system from composer/programmer Bill Schottstaedt.

Common Music Notation (CMN) is a Lisp-based language for creating and editing musical scores. It provided a full complement of music symbols and other scoring amenities, such as score sizing and text underlay. Output from CMN is in the Encapsulated PostScript (EPS) format, which is printable by any PostScript-compatible printer. In addition, your output files can be viewed with standard Linux PostScript viewers, such as GhostView and GhostScript.

CMN is a powerful music notation specification language. Although it lacks a mouse-driven graphical interface, the language elements will be immediately familiar to users who know the naming conventions for common, and some not so common, music notation symbols. CMN is capable of handling almost any scoring requirement, including many 20th century additions to the standard notation symbol palette.

Getting It, Building It

To use CMN you must have a working version of the Lisp programming language installed. Most Linux distributions include some version of Lisp as a standard package. See your package management software to determine what version, if any, is installed on your system. Most versions of Lisp should work fine with Common Music Notation, but I recommend the Carnegie-Mellon University Common Lisp (CMUCL), available here. Again, check your distribution's documentation to see if a CMUCL package is available.

Next, download the latest version of Common Music Notation (see Resources) and unpack the tarball with:

tar xzvf cmn.tar.gz 

and then move to the newly created $HOME/cmn directory. Invoke your Lisp interpreter--entering lisp at the prompt should suffice--and enter the following command at the Lisp interpreter prompt:

(load "cmn-all.lisp")

Have a cup of your preferred beverage while Lisp builds the Common Music Notation fasl (fast-load) files. This step may take a while to complete when the files first are built on slower machines. Subsequent loads complete more quickly, however, once the fasl files are built. After CMN has built and loaded its various files, enter this command at the Lisp prompt:

(in-package :cmn) 

The entire wealth of Common Music Notation is now yours to use and enjoy.

The xcmnw Viewer

The source package includes code for building xcmnw, CMN's own EPS file viewer. xcmnw is not distributed in binary form, so you must build it yourself. However, CMN does not require you to use xcmnw, and it is provided only as an amenity for auto-previewing while working with CMN under the X window system.

xcmnw uses the Motif or LessTif graphics toolkit. These toolkits and the other required X libraries are standard packages in most mainstream Linux distributions. If you receive errors regarding X or Motif when compiling xcmnw, consult your distribution's documentation for instructions on installing the necessary development packages. Assuming you have the required components, open an xterm, enter the CMN source directory and run this command at the prompt:

gcc xcmnw.c -o xcmnw -I/usr/X11R6/include -L/usr/X11R6/lib -lXm -lXp -lXt 
	-lXext -lX11 -lm

Congratulations, you have compiled the xcmnw viewer. Become the root user, and then copy the xcmnw binary to /usr/local/bin or /usr/X11R6/bin to make the viewer available system-wide.

Using Common Music Notation

After loading cmn-all.lisp and running the in-package command (see above), the Lisp interpreter will be ready to process Common Music Notation code. Enter this command at the interpreter prompt:

(cmn staff treble c4 q)

This example creates a single staff with a treble clef and a quarter note at middle C. To view the resulting output file--named aaa.eps, the default output filename--in an X session, use a viewer such as GhostView. Or, you can add an output-type designator in order to view it with xcmnw, as seen in the following example:

(cmn (output-type :x) staff treble c4 q)

The xcmnw window should open with the display seen in Figure 1. Close it with this command:


Be sure to close the xcmnw viewer with this command. If you use X's Close or Kill Client function, you may be unable to run subsequent calls to xcmnw.

At the Sounding Edge: Music Notation Software for Linux, Part 2

Figure 1. The xcmnw Viewer

Now, let's add a few more notes to our basic example. Enter this line into the interpreter:

(cmn (output-type :x) staff treble c4 q d4 e e4 e f4 h)

The xcmnw viewer then displays the screenshot seen in Figure 2.

At the Sounding Edge: Music Notation Software for Linux, Part 2

Figure 2. More Activity in xcmnw

You can save your work at any time by entering this command at the Lisp prompt:


The file is saved as hi.cmn by default. If you want to rename it during the save, use this command syntax:

(cmn-store *cmn-score* "my_new.cmn") 

Here's the command to load my_new.cmn in a subsequent session:

(load "my_new.cmn")

Congratulations, you've mastered the basic use of Common Music Notation.

Advanced Use

For entering the simple examples above, we can work from the command prompt in an xterm or from the Linux console, if you don't need a viewer. For the following examples we use the Xemacs text editor. If you don't have Xemacs on your system, consult your distribution's documentation for instructions on installing the editor.

Xemacs is especially well suited for working with any Lisp-based system. Editing and evaluating--Lisp-speak for running your code--cycles are much easier and faster in Xemacs, and I recommend it for any work beyond the size of the simple examples from the prior section.

One thing more: You need to copy the code found here into your $HOME/.xemacs/init.el file. Notice that the executable names in that code are specific to the Planet CCRMA packages. You should change them for your system.

Start Xemacs and load CMUCL as an "inferior lisp" (ilisp) with the following Xemacs command:

	<Esc>-x cmucl

Now you can edit, evaluate and display your CMN scores completely within Xemacs. Type, or copy and paste, the following example code into the Xemacs ilisp-send buffer:

 ;;; This code is a slightly altered version of an example from the
 excellent Common Music Notation documentation.

(cmn (output-type :x) (size 40)
  (system brace
    (staff treble (meter 6 8)
      (c4 e. tenuto) (d4 s) (ef4 e sf)
    (c4 e) (d4 s) (en4 s) (fs4 e (fingering 3)))
    (staff treble (meter 3 4)
      (c5 e. marcato) (d5 s bartok-pizzicato) (ef5 e)
      (c5 e staccato tenuto) (d5 s down-bow) (en5 s) (fs5 e)))
  (system bracket
    (staff bar bass (meter 6 16)
      (c4 e. wedge) (d4 s staccato) (ef4 e left-hand-pizzicato)
      (c4 e tenuto accent rfz) (d4 s mordent) (en4 s pp) (fs4 e fermata))))

Save it as example-01.cmn. Now, press Ctrl-x-h to select the entire code block and then press Ctrl-c-r to evaluate the selected region. Figure 3 shows off the results of the evaluation, as displayed by GhostView.

At the Sounding Edge: Music Notation Software for Linux, Part 2

Figure 3. A More Complicated CMN Score

The code seen in example-01.cmn illustrates CMN's conformance to standard music notation terminology, using the common names for notation symbols, such as brace, staff, meter, tenuto, marcato and so on. Musicians familiar with standard notation symbols should find it relatively easy to understand a CMN score specification file.

Figure 3 also shows off CMN's excellent music symbols font. The system provides a full range of note types, rests and other musical symbols, as well as a variety of instrumental performance technique indicators. You can arrange these symbols freely in virtually any fashion, lending CMN the power to create very complex scores, as seen in Figure 4.

At the Sounding Edge: Music Notation Software for Linux, Part 2

Figure 4. A Complex CMN Score

Here is the code (by Bill Schottstaedt) that produced the display seen in Figure 4:

;;; -*- syntax: common-lisp; package: cmn; base: 10; mode: lisp -*-
;;; This example shows uses of invisible notes (a note with (scale 0 0))
;;; to attach slurs to, and the dy message to an explicit beam.

(cmn (output-file "ghosting.eps") (size 35)
   (automatic-ties nil)
   (automatic-rests nil)
   (system brace
           (setf stf1 (staff treble
                      (a3 (rq 1/16) (scale 0 0) (setf slur1 (begin-slur (dy0 -.5))))
                      (cs4 (rq 1/16) (onset 1/16) (setf ib1 (beam- (dy .25))) (setf sl1 (tie-)))
                      (e4 (rq 1/16) (-beam- ib1) (setf sl2 (tie-)))
                      (b4 (rq 1/16) (-beam- ib1) (setf sl3 (tie- (tie-curvature .33))))
                      (as4 (rq 1/16) (-beam- ib1) (setf sl4 (tie-)))
                      (ds5 (rq 1/16) (-beam- ib1) (setf sl5 (tie- (tie-direction :down))))
                      (g5 (rq 1/16) (-beam- ib1) (setf sl6 (tie- (tie-direction :down))))
                      (as5 (rq 1/16) (-beam- ib1) (setf sl7 (tie-)))
                      (d6 (onset .5) (scale 0 0) (end-slur slur1))
                      (chord (notes (c4 (-tie sl1))
                                    (e4 (-tie sl2))
                                    (a4 (-tie sl3))
                                    (b4 (-tie sl4))
                                    (d5 (-tie sl5))
                                    (g5 (-tie sl6))
                                    (a5 (-tie sl7)))
                             h (onset .5) stem-down (diminuendo (onset-offset .25) (duration 1.25)))
                      (cs4 e (onset (+ 2.5 .25)) stem-down begin-beam)
                      (cn4 s (onset (+ 2.5 .75)) stem-down end-beam (begin-tie (tie-direction :down)))
                      (c4 q (pp (dy -.75)) stem-down end-tie)))

	    (staff treble (tied-to stf1)
                   (eighth-rest (scale 0 0)) (d6 begin-beam stem-up s)
                   (cs6 s stem-up (begin-slur (slur-direction :up)))
                   (ef6 s stem-up) (cn6 end-beam s (begin-tie (tie-direction :up)) stem-up)
                   (c6 q stem-up end-slur end-tie)
                   (d4 s begin-beam (begin-slur (slur-direction :up))) (cs4 s) (ds4 s) (cn4 s end-beam end-slur)
                   (fs4 s. begin-beam (begin-slur (slur-direction :up))) (dn4 (rq 1/8)) (d4 e end-beam end-slur))

            (setf stf2 (staff (dy -1.0) bass
                              (a3 e stem-down (begin-tie (tie-direction :down) (tie-curvature .25))) (a3 h end-tie)
                              (sixteenth-rest (onset 1.5))
                              (fs3 s (begin-beam (dy .25)) stem-up (onset 1.75)
                                   (begin-slur (slur-direction :up)) (setf sl8 (tie- (tie-curvature .25))))
                              (es3 s stem-up (onset 2.0) (setf sl9 (tie- (tie-direction :down))))
                              (g3 s end-beam (onset 2.25) end-slur)
                              (chord (onset 2.5) (notes g3 (f3 (-tie sl8)) (e3 (-tie sl9))) q. stem-down)))

            (staff bass (tied-to stf2) bar
                   (a3 (rq 1/16) stem-up (-beam ib1))
                   (fs3 e no-beam (onset 1.75) (begin-slur (dy -.25) (slur-direction :down)))
                   (es3 e no-beam (onset 2.0))
                   (g3 q stem-down (scale 0 0) end-slur))))

Studying the flow of this code reveals its logic. A rendering size is declared, followed by some configuration directives. Then, the staves are braced and defined--stf1 and stf2, treble and bass. The rest of the code defines the pitches, durations, ties, beams and phrasing.

A tip for GhostView users: You can invoke the viewer to update itself when you produce a new version of your work. Here's how I launch GhostView to auto-update example-01.cmn :

gv -watch ghosting.eps &

Now I can change my code and reevaluate it, and the running instance of GhostView automatically displays the updated output.


CMN has been in development for many years, so there's little about it to criticize. Perhaps the major drawback for new users is its lack of a graphical interface, but more experienced users may consider that lack to be more of a blessing (see the first article in this series). Users also must understand that CMN is a "final stage" for notation. That is, its output files are in EPS format only, and no utilities exist for converting CMN output to MIDI or any other format.

Closing Remarks

Figure 4 nicely demonstrates the flexibility of Common Music Notation. However, our examples here barely scratch the surface of its possibilities. CMN lets you underlay text, colorize symbols, add new graphics and extensively customize the appearance of your score. It also interfaces with the other members of the CCRMA "Common" software family, including the Common Music composition environment and the Common Lisp Music sound synthesis language. Extensive HTML-based help is available, and many examples are included with the source package. In addition, if you run into trouble, programmer Bill Schottstaedt can be contacted on the active CMN mail list. He is quick to help you through any difficulties you might have with what he calls his "simple little hack".

Dave Phillips is a musician, teacher and writer living in Findlay, Ohio. He has been an active member of the Linux Audio community since his first contact with Linux in 1995. He is the author of The Book of Linux Music & Sound, as well as numerous articles in Linux Journal.

Load Disqus comments

Firstwave Cloud