Next: , Previous: Some Basic Lisp Examples, Up: Lisp Examples


7.2 Settings

7.2.1 Score-Level Settings

The following examples contain three score-level settings, title, author and quartertones, which affect the entire score.

All settings in FOMUS can be set at the score level.

(fms:with-score
    (:filename *filename*
     :sets '((:title "Random")
             (:author "David Psenicka")
             (:quartertones t)))
  (loop
     for o from 0 below 20 by 1/2
     do (fms:note :time o :dur 1/2 :pitch (+ 65 (random 15.0)))))

lsp034.png

Figure 7.9: Score-Level Settings

(fms:setting :filename *filename*)
(fms:setting :title "Random")
(fms:setting :author "David Psenicka")
(fms:setting :quartertones t)

(loop
   for o from 0 below 20 by 1/2
   do (fms:note :time o :dur 1/2 :pitch (+ 65 (random 15.0))))

(fms:run)

lsp035.png

Figure 7.10: Score-Level Settings without with-score

7.2.2 Object Settings

Each list of keyword/argument pairs following the percinsts, insts and parts keywords is the definition for a percussion instrument, instrument or part. See Objects for a better explanation of these objects—the purpose here is only to point out settings. perc-note and perc-name are typical settings for percussion instruments (they specify the note and the text for a percussion change mark). Because they are set in a percussion instrument definition, they affect only that object and any woodblock percussion note events. The settings name and abbr usually belong in an instrument definition (they are the name and abbreviated name of the instrument). When they are defined in a part as they are here, they override the definitions that are in the instrument that they are based on. transpose-part (whether or not to transpose all of the notes in a part) should probably be defined at the score level, but can also exist in instruments or parts (as they are here). id, template, percinsts (inside the instrument definition) and insts (inside the part definitions) aren't really settings—they are special assignments that only affect the instrument or part that they are defined in (see Objects for complete lists and descriptions of these special parameters).

(defun notes (maxtim parts perc pnotes)
  (loop
     for tim = 0 then (+ tim (if (< (random 1.0) 0.5) 1/2 1))
     while (< tim maxtim)
     if (< (random 1.0) 0.666)
     do (fms:note :part (nth (random (length parts)) parts) ; woodwind note
                  :time tim
                  :dur 1/2
                  :pitch (+ 72 (random 7)))
     else do (fms:note :part perc ; percussion note
                       :time tim
                       :dur 1/2
                       :pitch (nth (random (length pnotes)) pnotes))))

(fms:with-score
    (:filename *filename*
     :sets '(:layout "orchestra")
     :percinsts '((:id "wb1" :template "low-woodblock" :perc-note 57 :perc-name "woodblocks")
                  (:id "wb2" :template "high-woodblock" :perc-note 64 :perc-name "woodblocks"))
     :insts '((:id "prcdef" :template "percussion" :percinsts ("wb1" "wb2")))
     :parts '((:id "cl1" :name "Bf Clarinet 1" :abbr "cl 1" :inst "bflat-clarinet" :transpose-part nil)
              (:id "cl2" :name "Bf Clarinet 2" :abbr "cl 2" :inst "bflat-clarinet" :transpose-part nil)
              (:id "ob" :name "Oboe" :abbr "ob" :inst "oboe")
              (:id "prc" :name "Percussion" :abbr "perc" :inst "prcdef")))
  (notes 16 '("cl1" "cl2" "ob") "prc" '("wb1" "wb2")))

lsp027.png

Figure 7.11: Object Settings

(defun notes (maxtim parts perc pnotes)
  (loop
     for tim = 0 then (+ tim (if (< (random 1.0) 0.5) 1/2 1))
     while (< tim maxtim)
     if (< (random 1.0) 0.666)
     do (fms:note :part (nth (random (length parts)) parts) ; woodwind note
                  :time tim
                  :dur 1/2
                  :pitch (+ 72 (random 7)))
     else do (fms:note :part perc ; percussion note
                       :time tim
                       :dur 1/2
                       :pitch (nth (random (length pnotes)) pnotes))))

(fms:setting :filename *filename*)
(fms:setting :layout "orchestra")

(fms:percinst :id "wb1" :template "low-woodblock" :perc-note 57 :perc-name "woodblocks")
(fms:percinst :id "wb2" :template "high-woodblock" :perc-note 64 :perc-name "woodblocks")

(fms:inst :id "prcdef" :template "percussion" :percinsts '("wb1" "wb2"))

(fms:part :id "cl1" :name "Bf Clarinet 1" :abbr "cl 1" :inst "bflat-clarinet" :transpose-part nil)
(fms:part :id "cl2" :name "Bf Clarinet 2" :abbr "cl 2" :inst "bflat-clarinet" :transpose-part nil)
(fms:part :id "ob" :name "Oboe" :abbr "ob" :inst "oboe")
(fms:part :id "prc" :name "Percussion" :abbr "perc" :inst "prcdef")

(notes 16 '("cl1" "cl2" "ob") "prc" '("wb1" "wb2"))

(fms:run)

lsp026.png

Figure 7.12: Object Settings without with-score

7.2.3 Measure/Note Event Settings

This pair of examples shows a few settings being defined in measure and note events. The two settings in the measure definition are comp (compound meter) and keysig (key signature), both of which could be set at the score level or in a part definition instead. The settings in the note events are staff (staff number) and acc (accidental choices), which override any decision FOMUS makes regarding staff and accidental choices. All other keyword/value pairs (e.g., time, dur, pitch, etc.) are not settings, they are special parameters that belong only to that particular event.

(fms:with-score (:filename *filename*)
  (fms:meas :time 0 :dur 2 :comp t :keysig "gmaj")
  (loop
     for n from 0 below 20
     for tim from 0 by 1/3
     do (fms:note :time tim
                  :dur 1/3
                  :pitch (+ 55 (* 11 (sin tim)))
                  :staff (if (< n 10) 2 1)
                  :acc (if (< n 10) '(n f) '(n s)))))

lsp036.png

Figure 7.13: Measure/Note Settings

(fms:setting :filename *filename*)

(fms:meas :time 0 :dur 2 :comp t :keysig "gmaj")

(loop
   for n from 0 below 20
   for tim from 0 by 1/3
   do (fms:note :time tim
                :dur 1/3
                :pitch (+ 55 (* 11 (sin tim)))
                :staff (if (< n 10) 2 1)
                :acc (if (< n 10) '(n f) '(n s))))

(fms:run)

lsp037.png

Figure 7.14: Measure/Note Settings without with-score