CCRMA

Music 220b: Introduction


First Time Through -- Music Kit, Edit, Lisp

The NeXT Music Kit is a built-in facility for playing and manipulating musical sounds. The introductory course uses only one capability of the Music Kit, it will be the initial method by which we play notes from a score. Its other capabilities can be studied in detail in the NeXT Music Kit documentation itself.

To familiarize yourself with the act of playing a Music Kit score (and various other facets of life on these machines), here's something to point your mouse at. The ScorePlayer control panel below comes to the screen if you launch the application by double-clicking on one of its data files in the Browser. Bach has been a traditional victim in electronic music -- in this case we are calling up a fugue that was entered in Music Kit ScoreFile format with a text editor. The ScoreFile's full pathname is /LocalLibrary/Music/Scores/BachFugue.score, and here's where it appears when accessed using the Browser:

Clicking on Play starts the piece and you can modify the tempo as it's running...

Clicking on Stop will stop playback...

...if there's no sound, you'll need to check the audio playback status. The best place to check the status is in the Preferences application, by double clicking /NextApps/Preferences, then its monitor icon and making sure volume is up and that sound mute isn't enabled.


Edit vs. BachFugue.score

You can have a look at a score file with an editor, and the one we use in the course is the application Edit ( found in the /NextApps directory). Double-clicking always launchs a file's default application. We've shown above that a file with the extension .score launchs ScorePlayer. To see it with Edit, it's necessary to use the Open command in the Edit Menu and then double-click the file (or click "Edit Scorefile" in the PlayScore application).

A ScoreFile is divided into two sections, the header and the body. The header always precedes the body; the two sections are separated by a BEGIN statement. The end of the scorefile can be marked by an optional END statement:

header
BEGIN;
body
[ END; ]
The header contains statements that establish the context in which the body is interpreted. The body consists of a time-ordered series of statements that represent Note objects.

The following statements can appear only in the header:

This information is found only in the body:

A number of other statements can appear in either the header or the body:

You will see that the Bach uses the Pluck instrument in 6-part polyphony. If you want, make a copy of the file into your own directory and and give it a listen after you change around some notes with Edit. Making a score by hand in a note list is usually a tedious operation, so we turn to...


Lisp and Common Music

We will be writing our score files with the help of a composition language. Stella provides the composer with a language suited for expressing musical ideas in familiar terms and for getting control over the details of sound synthesis. Stella is actually a program written in the Lisp language and, like most programs, takes one form of data as input and has another form as output. For the purposes of this introduction, Stella outputs score file data. The remainder of this document is devoted to studying its input.

The Lisp application is one that you'll want to drag into your dock if it's not already there (that's the ready access set of applications in a column on the right side of the screen). Look for the app in the /LocalApps directory and drag it into an empty space, it'll remain there the next time you log in.

Double-clicking Lisp gets you a window that communicates with the Lisp top-level interpreter. This is sort of a calculator that takes it's instructions in Lisp syntax. When you see the prompt, you can enter an expression and it will be evaluated:

<cl> (+ 1 2 3)

6 
<cl> (print "Hi there!")

"Hi there!" 
"Hi there!" 
<cl> 
To launch stella just evaluate the following function call after you get the prompt.

<cl> (stella)
Hang on a second...

Type ? for help.

Stella [Top-Level]: 
So finally you get to the stella prompt. Stella is also an interpreter, like lisp, and it's just waiting for you to type a command. Typing "?" will give you a list of available commands. Typing "Help" with the name of a command as an argument will type the full description of the command (with examples). So let's load an example by using the "load" command:
Stella [Top-Level]: load /Lisp/cm/doc/tutorials/stella/opus1.cm

Loading /dist/cm/stella/tutorial/opus1.cm
Syntax set to MIDI
Let's return to the MusicKit syntax, open an output stream and finally play (using the "mix" command) the score with the MusicKit:

Stella [Top-Level]: syntax mk
Current syntax is MUSIC-KIT.
Stella [Top-Level]: open /zap/test.score     
New output stream: #.
Stella [Top-Level]: mix * 0

Play file /zap/test.score? (=Yes) 
Playing: /Lisp/cm/site/playscore /zap/test.score &
[1] 3310
Stella [Top-Level]: 
At this point a new scorefile is created and played by Stella. The top-level Lisp window has ordinary cut&paste behavior, so a second way to execute your code is via copy and paste within the window, or from another window -- most probably the editor. In this case you open a file in Edit and use copy and paste to communicate the text back and forth. But that's kind of klunky, so here's one way to reconcile the problem.


Lisp vs. Edit

At CCRMA we've customized Edit, taking advantage of the fact that it can incorporate user-defined functions. You will notice in the menu, under Utilities both User Commands and User Pipes a few Lisp oriented commands.

Note that Edit has parenthesis matching (a must for Lisp) and that you can grab a parenthesis-bounded expression by double-clicking on either the left or right parenthesis of an expression.

As an excersize, put a copy of bach1.lisp in your own directory. You should be able to play the file with Select All and then LispEvaluate from the Edit menu. You will find it convenient to selectively evaluate portions of a file that you are editing.


Updated for 3.0, Stella, 1993-1996 at CCRMA, no ©, no nothing. Mainly because of the extreme plagiarism already undertaken. Prosecutors will be Violated.


©1995 Fernando Lopez-Lezcano. All Rights Reserved.
nando@ccrma.stanford.edu