Chapter 7. ScoreFile Language Reference

Table of Contents
Program Structure
Header Statements
Score Info Statements
part Statements
Part Info Statements
Header or Body Statements
Variable Declarations and Assignments
envelope Statements
waveTable Statements
object Statements
include Statements
print Statements
tune Statements
comment and endComment Statements
Body Statements
Note Statements
Time Statements
Operators
Decibel Computation Operator
Exponentiation Operator
Pitch Transposition Operator
Envelope Lookup Operator
String Concatenation Operator
Character Extraction
Predeclared Variables, Constants, and Special Symbols
Pitch Variables
Key Number Constants
MIDI Constants
Other Constants
Special Symbols
Procedural Statements

ScoreFile is a language designed to represent, create, and manipulate music data. The code for a ScoreFile program is maintained in a file, called a scorefile, on the disk. A scorefile represents a MusicKit MKScore object and its contents in ASCII form. Scorefiles can be created from a text editor or generated automatically by a MKScore or MKScorefileWriter object. A scorefile is interpreted when it's read by a MKScore object or performed by a MKScorefilePerformer object.

There is also a binary format scorefile. The binary format is more than twice as fast to read as the ASCII form. The utility convertscore converts from one to the other. Binary format scorefiles are called “Optimized scorefiles” and have the .playscore file extension.

This chapter describes the syntax and conventions of the ScoreFile language. The presentation in this chapter assumes a familiarity with Chapter 4. A concise outline of ScoreFile syntax can be found in Appendix C. A comparison to other note-list formats is presented in Chapter 8.

Program Structure

A ScoreFile program 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; ]

Either section can be empty. If the body is empty, the BEGIN statement can be omitted.

Both the header and the body are made up of ScoreFile statements. The header contains statements that establish the context in which the body is interpreted. The following statements can appear only in the header:

The body consists of a time-ordered series of statements that represent MKNote objects. This information is found only in the body:

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