7. Glossaries

Two ready-made glossaries are supplied with BP2: "-gl.D50" and "-gl.GeneralMIDI". The first one contains information relative to Roland D-50 synthesiser, and the second one information that is common to all General MIDI synthesisers. If your synth is neither Roland D-50 nor General MIDI, you may edit a specific glossary on the basis of supplied examples.

A glossary is altogether a grammar and a script... Let us first look at it as a grammar. Load "-gl.GeneralMIDI" to the glossary window for instance:

// This glossary defines program changes used to select instruments following General MIDI specifications.
// Note that MIDI programs are numbered 0 to 127 here (following MIDI spec. 1.0) instead of 1 to 128 as per General MIDI specs.
// You may change variable names, but names should remain consistent in all your projects. (See acceptable variable names under "variable" in the Help menu.)
// Beware that program change messages will be sent on the current channel, which should be the basic channel of the synthesizer (i.e. the one on which it receives mode messages). This channel (default 1) may be changed by script instruction: MIDI set basic channel to ...
[1] AcousticGrandPiano --> _script(MIDI program 1)
[2] BrightAcousticPiano --> _script(MIDI program 2)
[3] ElectricGrandPiano --> _script(MIDI program 3)
[4] HonkyTonkPiano --> _script(MIDI program 4)
[5] RhodesPiano --> _script(MIDI program 5)
[6] ChorusedPiano --> _script(MIDI program 6)
[7] Harpsichord --> _script(MIDI program 7)

It clearly looks like a grammar (a subgrammar) with its rewrite rules. Because of speed optimisation it is always taken as a 'SUB1' type subgrammar, i.e. it performs one single substitution of the start string. Rule syntax is limited: the left argument should contain a single variable. If that variable already appears in the left argument of a rule belonging to the grammar, the compiler warns you that it may be a mistake, but proceeds anyway. If the same variable is defined twice in the same glossary, or if the glossary generates undefined variables, then en error message is returned.

How does it work practically?

Suppose that BP2 has produced an item and is about to play it, or you have selected an item in the text window. It first scans the item looking for variables that are used in the glossary. If no such variable is found then the glossary is not used. Otherwise it uses the glossary as a subgrammar in order to get the final string, which will then be expanded (as a polymetric expression), set in time, and then played on the MIDI output.

Since the glossary makes a single substitution, a variable appearing in the right argument of a glossary rule will only be rewritten if it is defined in a following rule. (See for example variables 'Internal' and 'Expansion' in "-gl.D50".)

Let us now look at the glossary as a script. Any rewrite rule may equivalently be put as a "Define" script instruction, e.g.

ChorusedPiano --> _script(MIDI program 6)

is equivalent to:

Define ChorusedPiano _script(MIDI program 6)

In addition, script instructions that influence compilation are acceptable in glossaries, notably:

Note convention = key numbers

You may use glossaries for any other purpose than setting a MIDI device. The good thing about glossaries is that they can perform transformations on a string representing a musical item even when no grammar is used to produce it. It makes sense that the design of device-specific procedures is not part of a grammar which is only meant to produce symbolic representations of musical items.