Next: , Previous: Tuplets (File), Up: `.fms' File Examples


6.10 Instruments

6.10.1 Defining Instruments

FOMUS has many built-in instruments, but you will probably want to modify some of them or define your own. The electric viola instrument defined here uses the built-in ‘viola’ instrument as a template, replacing the values of a few typical settings. name and abbr set the name and abbreviated name of the instrument as it should appear in the score. min-pitch and max-pitch set the minimum and maximum pitch so that FOMUS prints warning messages if the pitches fall out of range. open-strings is a list of pitches representing the open strings of the instrument, used by FOMUS to calculate notation for harmonics.

inst <id: elvla template: viola
      name: "Electric Viola" abbr: "evla"
      min-pitch: 48 max-pitch: 108
      open-strings: (48 55 62 69)>

part <id: mypart inst: elvla>

part: mypart
time: 0.0 dur: 0.333 pitch: 70.1 ;
time: 0.333 dur: 0.666 pitch: 65.6 ;
time: 1.0 dur: 2.0 pitch: 68.4 ;

ex072.png

Figure 6.52: Instrument Definition

The same instrument is defined inline inside the part in this example.

part <id: mypart
      inst: <template: viola
             name: "Electric Viola" abbr: "evla"
             min-pitch: 48 max-pitch: 108
             open-strings: (48 55 62 69)>>

part: mypart
time: 0.0 dur: 0.333 pitch: 70.1 ;
time: 0.333 dur: 0.666 pitch: 65.6 ;
time: 1.0 dur: 2.0 pitch: 68.4 ;

ex073.png

Figure 6.53: Inline Instrument Definition

The same instrument is defined once again, only this time without using a template (i.e., the template parameter is missing). Since the definition is not based on a built-in instrument, some essential pieces of information missing in the above examples must be provided (the staff and clef definitions, which there are more examples of below).

part <id: mypart
      inst: <name: "Electric Viola" abbr: "evla"
             min-pitch: 48 max-pitch: 108
             open-strings: (48 55 62 69)
             staves: <clefs: (<instclef: alto octs-up: 0>
        		      <instclef: treble octs-down: 0>)>>>

part: mypart
time: 0.0 dur: 0.333 pitch: 70.1 ;
time: 0.333 dur: 0.666 pitch: 65.6 ;
time: 1.0 dur: 2.0 pitch: 68.4 ;

ex074.png

Figure 6.54: Templateless Instrument Definition

6.10.2 Instrument Library

If you find yourself reusing the same instrument definitions in multiple files, you could insert something resembling the following in your .fomus file located in your home directory (make sure you use ‘+=’ instead of ‘=’ to append the values to FOMUS's default list). See the section below on defining staves in instruments for more on the staves parameter that appears in this example.

     inst-defs += (<id: ukulele name: "Ukulele"
                    staves: <clefs: <instclef: treble>>
                    min-pitch: 60 max-pitch: 81
                    open-strings: (67 60 64 69)>
                   <id: banjo name: "Banjo"
                    staves: <clefs: <instclef: bass>>
                    min-pitch: 67 max-pitch: 74
                    open-strings: (67 50 55 59 62)>)

All of FOMUS's built-in instruments are contained in the file fomus.conf, which is located in /install_prefix/shared/ (install_prefix is most likely /usr/local or /usr).

6.10.3 Defining Staves in Instruments

Below is an instrument definition that contains a grand staff and uses a treble and bass clef. staves is followed by a list of two staff definitions. The clefs parameter inside each staff definition is followed by a list of clef definitions, each of which actually represents a clef choice in that staff. The instclef setting is mandatory and determines the clef sign that appears in the score. Each of the two staves in the instrument below, then, are allowed to display either a treble or bass clef. The first clef definition to appear in a list is the default clef, which means that in the example below, the default clef for staff 1 (the top staff) is treble clef and the default for staff 2 (the bottom staff) is bass clef. The ledgers-up and ledgers-down settings specify how many ledger lines should be allowed to appear before FOMUS begins to consider switching staves or clefs. octs-up and octs-down specify whether or not octave change signs are allowed to appear (a value of 1 means an 8va sign is allowed while a value of 2 means 15va is allowed). clef-preference affects the probability that FOMUS will choose that clef over other choices (a value of 2, for example, doubles the chance of it being chosen while a value of 1/2 reduces it by one half).

inst <id: harpsichord name: "Harpsichord"
      staves: (<clefs: (<instclef: treble // top staff
        		 ledgers-up: 3 ledgers-down: 2
        		 octs-up: 2 octs-down: 0>
        		<instclef: bass
        		 clef-preference: 1/3
        		 ledgers-up: 2 ledgers-down: 3
        		 octs-up: 0 octs-down: 2>)>
               <clefs: (<instclef: bass // bottom staff
        		 ledgers-up: 2 ledgers-down: 3
        		 octs-up: 0 octs-down: 2>
        		<instclef: treble
        		 clef-preference: 1/3
        		 ledgers-up: 3 ledgers-down: 2
        		 octs-up: 2 octs-down: 0>)>)
      min-pitch: 29 max-pitch: 89>

part <id: prt inst: harpsichord>

part prt

time 0 dur 2 pitch 70;
time 2 dur 2 pitch 71;
time 4 dur 2 pitch 72;

ex075.png

Figure 6.55: Staves and Clefs

The following example shows how to define an instrument with a grand staff made up of three staves. Three staff objects are created, each one containing two clef objects representing the choices allowed in that staff.

// 3-staff piano instrument
inst <id piano, template piano,
      // a list of staff objects, each containing a list of clef objects
      // the first clef object in the list is the default for that staff
      staves (<clefs (<instclef treble, // defines a treble clef
                       octs-down 0, // no 8vb octave signs allowed
                       ledgers-down 2> // approx. 2 ledger lines allowed below staff
                      <instclef bass, // defines a bass clef
                       octs-up 0, // no 8va octave signs allowed
                       ledgers-up 2, // approx. 2 ledger lines allowed above staff
                       clef-preference 1/2>)> // clef is 1/2 as likely to be chosen
              <clefs (<instclef treble, // clef choices for middle staff...
                       octs-up 0,
                       octs-down 0,
                       ledgers-down 2>
                      <instclef bass,
                       octs-up 0,
                       octs-down 0,
                       ledgers-up 2>)>
              <clefs (<instclef bass, // bass clef is the default for bottom staff
                       octs-up 0,
                       ledgers-up 2>
                      <instclef treble,
                       octs-down 0,
                       ledgers-down 2,
                       clef-preference 1/2>)>)>

// parts
part <id prt, inst piano>

// events
part prt
duration 1
time 0 pitch 49 ;
time 1 pitch 65 ;
time 2 pitch 40 ;
time 3 pitch 67 ;
time 4 pitch 66 ;
time 5 pitch 68 ;
time 6 pitch 59 ;
time 7 pitch 78 ;
time 8 pitch 78 ;
time 9 pitch 59 ;
time 10 pitch 54 ;
time 11 pitch 38 ;
time 12 pitch 78 ;
time 13 pitch 69 ;
time 14 pitch 51 ;
time 15 pitch 35 ;
time 16 pitch 90 ;
time 17 pitch 94 ;
time 18 pitch 70 ;
time 19 pitch 49 ;

ex044.png

Figure 6.56: Instrument with Three Staves