Next: , Previous: Tuplets (SAL), Up: SAL Examples


8.10 Instruments

8.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.

process myproc ()
  repeat 1
  fms:note(dur: 2, pitch: 70)
end

begin
  with insts = {{:id "elvla" :template "viola"
                 :name "Electric Viola" :abbr "evla"
                 :min-pitch 48 :max-pitch 108
                 :open-strings {48 55 62 69}}},
       parts = {{:id "mypart" :inst "elvla"}}
  sprout(myproc(), *filename*, insts: insts, parts: parts)
end

sal063.png

Figure 8.45: Instrument Definition

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

process myproc ()
  repeat 1
  fms:note(dur: 2, pitch: 70)
end

begin
  with parts = {{:id "mypart"
                 :inst {:template "viola"
                        :name "Electric Viola" :abbr "evla"
                        :min-pitch 48 :max-pitch 108
                        :open-strings {48 55 62 69}}}}
  sprout(myproc(), *filename*, parts: parts)
end

sal064.png

Figure 8.46: 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).

process myproc ()
  repeat 1
  fms:note(dur: 2, pitch: 70)
end

begin
  with parts = {{: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}}}}}}}
  sprout(myproc(), *filename*, parts: parts)
end

sal065.png

Figure 8.47: Templateless Instrument Definition

8.10.2 Instrument Library

If you find yourself reusing the same instrument definitions, 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).

8.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 (each staff definition appears as smaller list inside the larger list). The clefs parameter inside each staff definition is followed by a list of clef definitions (again, each clef definition appears as a smaller list), 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).

process myproc ()
  for eachp in {70 71 72}
  fms:note(dur: 2, pitch: eachp)
  wait 2
end

begin
  with insts = {{: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}},
       parts = {{:id "prt" :inst "harpsichord"}}
  sprout(myproc(), *filename*, insts: insts, parts: parts)
end

sal066.png

Figure 8.48: 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.

process myproc (n)
  repeat n
  fms:note(part: "prt", dur: 1, pitch: between(key("a1"), key("c7") + 1))
  wait 1
end

begin
  ; a list of instruments--using the built-in piano instrument as a template and replacing it
  ; with a custom piano instrument
  with insts = {{: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
                                    :ledgers-down 2 ; approx. 2 ledger lines allowed below staff
                                    :octs-down 0} ; no 8vb octave signs allowed
                                   {:instclef "bass" ; defines a bass clef
                                    :clef-preference 1/2 ; clef is 1/2 as likely to be chosen
                                    :ledgers-up 2 ; approx. 2 ledger lines allowed above staff
                                    :octs-up 0}}} ; no 8va octave signs allowed
                          {:clefs {{:instclef "treble" ; clef choices for middle staff...
                                    :ledgers-down 2
                                    :octs-down 0 :octs-up 0}
                                   {:instclef "bass"
                                    :ledgers-up 2
                                    :octs-down 0 :octs-up 0}}}
                          {:clefs {{:instclef "bass" ; bass clef is the default for bottom staff
                                    :ledgers-up 2
                                    :octs-up 0}
                                   {:instclef "treble"
                                    :clef-preference 1/2
                                    :ledgers-down 2
                                    :octs-down 0}}}}}},
       parts = {{:id "prt" :inst "piano"}}
  sprout(myproc(20), *filename*, insts: insts, parts: parts)
end

sal023.png

Figure 8.49: Instrument with Three Staves