./../../src/instruments.lsp

## sc/instruments [ Modules ]

[ Top ] [ Modules ]

NAME

     instrument

     File:             instruments.lsp

     Class Hierarchy:  none (no classes defined)

     Version:          1.0.0-beta1

     Project:          slippery chicken (algorithmic composition)

     Purpose:          Definition of various standard instruments and other
                       data/functions useful to slippery-chicken users.

     Author:           Michael Edwards: m@michael-edwards.org

     Creation date:    30th December 2010

     $$ Last modified: 14:59:08 Tue May  8 2012 BST

     SVN ID: $Id: instruments.lsp 1764 2012-05-17 11:49:59Z medward2 $

## instruments/+slippery-chicken-standard-instrument-palette+ [ Global Parameters ]

[ Top ] [ instruments ] [ Global Parameters ]

FUNCTION

     A palette of standard instruments (by no means exhaustive...) for use
     directly in projects or for combining with user palettes e.g.

     (combine
      +slippery-chicken-standard-instrument-palette+
      (make-instrument-palette
       'esoteric-stuff
        '((toy-piano
           (:staff-name "toy piano" ....

SYNOPSIS

    (defparameter +slippery-chicken-standard-instrument-palette+
      (make-instrument-palette
       'slippery-chicken-standard-instrument-palette
       ;; SAR Fri Jan 20 11:43:32 GMT 2012: Re-ordering these to Adler's "standard"
       ;; score order for easier look-up
       '((piccolo
          (:staff-name "piccolo" :staff-short-name "picc"
           :lowest-written d4 :highest-written c7 :transposition-semitones 12
           :missing-notes nil
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 73))
         (flute
          (:staff-name "flute" :staff-short-name "fl"
           :lowest-written c4 :highest-written d7
           :missing-notes (cqs4 dqf4)
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 74))
         (alto-flute
          (:staff-name "alto flute" :staff-short-name "alt fl"
           :lowest-written c4 :highest-written c7 :transposition-semitones -5
           :missing-notes (cqs4 dqf4)
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 74))
         ;; SAR Fri Jan 20 11:46:45 GMT 2012: Modified bass flute range to that
         ;; stated by Adler.
         (bass-flute
          (:staff-name "bass flute" :staff-short-name "bass fl"
           :lowest-written c4 :highest-written c7 :transposition-semitones -12
           :missing-notes (cqs4 dqf4)
           :clefs-in-c (treble bass) :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 74))
         ;; SAR Fri Jan 20 12:01:37 GMT 2012: Added oboe. Conservative range taken
         ;; from the Adler
         (oboe
          (:staff-name "oboe" :staff-short-name "ob"
           :lowest-written bf3 :highest-written a6
           :starting-clef treble
           :chords nil
           :midi-program 69))
         (e-flat-clarinet
          (:staff-name "E-flat clarinet" :staff-short-name "E-flat cl"
           :lowest-written e3 :highest-written a6 :transposition-semitones 3
           :missing-notes (aqs4 bqf4 bqs4 cqs5 dqf5 gqf3 fqs3 fqf3)
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 72))
         (b-flat-clarinet
          (:staff-name "B-flat clarinet" :staff-short-name "B-flat cl"
           :lowest-written e3 :highest-written a6 :transposition-semitones -2
           :missing-notes (aqs4 bqf4 bqs4 cqs5 dqf5 gqf3 fqs3 fqf3)
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 72))
         (a-clarinet
          (:staff-name "A clarinet" :staff-short-name "A cl"
           :lowest-written e3 :highest-written a6 :transposition-semitones -3
           :missing-notes (aqs4 bqf4 bqs4 cqs5 dqf5 gqf3 fqs3 fqf3)
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 72))
         (bass-clarinet
          (:staff-name "bass clarinet" :staff-short-name "bass cl"
           :lowest-written c3 :highest-written g6 :transposition-semitones -14
           :missing-notes (aqs4 bqf4 bqs4 cqs5 dqf5 gqf3 fqs3 fqf3 eqf3 dqs3 dqf3
                                cqs3)
           :prefers-notes low
           :clefs (treble) :clefs-in-c (treble bass) :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 72))
         (soprano-sax
          (:staff-name "soprano saxophone" :staff-short-name "sop sax"
           :lowest-written bf3 :highest-written fs6 :transposition-semitones -2
           :missing-notes (gqs4 gqs5)
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 65))
         (alto-sax
          (:staff-name "alto saxophone" :staff-short-name "alt sax"
           ;; altissimo extra....by hand...
           :lowest-written bf3 :highest-written fs6 :transposition-semitones -9
           :missing-notes (gqs4 gqs5)
           :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 66))
         (tenor-sax
          (:staff-name "tenor sax" :staff-short-name "ten sax"
           :lowest-written bf3 :highest-written fs6 :transposition-semitones -14
           :missing-notes (gqs4 gqs5)
           :starting-clef treble :clefs-in-c (treble bass)
           :chords nil
           :microtones t
           :midi-program 67))
         (baritone-sax
          (:staff-name "baritone sax" :staff-short-name "bar sax"
           :lowest-written bf3 :highest-written fs6 :transposition-semitones -21
           :missing-notes (gqs4 gqs5)
           :clefs-in-c (treble bass) :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 68))
         (bassoon
          (:staff-name "bassoon" :staff-short-name "bsn"
           ;; of course it can go higher but best not to algorithmically select
           ;; these
           :lowest-written bf1 :highest-written c5
           ;; Wolfgang Ruediger says all 1/4 tones are OK above low E
           :missing-notes (bqf1 bqs1 cqs2 dqf2 dqs2 eqf2)
           :largest-fast-leap 13
           :clefs (bass tenor) :starting-clef bass
           :chords nil
           :microtones t
           :midi-program 71))
         (french-horn
          (:staff-name "french horn" :staff-short-name "hn"
           :lowest-written c3 :highest-written c6 :transposition-semitones -7
           :clefs (treble bass) :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 61))
         (c-trumpet
          (:staff-name "trumpet in c" :staff-short-name "c tpt"
           :lowest-written fs3 :highest-written c6
           :clefs (treble) :starting-clef treble
           :chords nil
           :microtones t
           :midi-program 57))
         ;; SAR Fri Jan 20 12:09:41 GMT 2012: Added b-flat-trumpet from Adler
         ;; MDE Mon Feb 20 20:02:55 2012 -- modified to keep in line with clarinet
         (b-flat-trumpet
          (:staff-name "B-flat trumpet" :staff-short-name "b-flat tpt"
           ;; the -flat should be convereted in CMN and Lilypond to the flat sign
           :lowest-written fs3 :highest-written d6 :transposition-semitones -2
           :starting-clef treble
           :chords nil
           :midi-program 57))
         ;; SAR Fri Jan 20 12:17:24 GMT 2012: Added tenor trombone from Adler
         (tenor-trombone
          (:staff-name "trombone" :staff-short-name "tbn"
           :lowest-written e2 :highest-written bf4
           :clefs (bass tenor) :starting-clef bass
           :chords nil
           :midi-program 58))
         (vibraphone
          (:staff-name "vibraphone" :staff-short-name "vib"
           :lowest-written f3 :highest-written f6
           :starting-clef treble
           :chords t
           :microtones nil
           :midi-program 12))
         (marimba
          (:staff-name "marimba" :staff-short-name "mba"
           :lowest-written c3 :highest-written c7
           :starting-clef treble :clefs (treble) ; (treble bass)
           :chords t
           :microtones nil
           :midi-program 13))
         (piano
          (:staff-name "piano" :staff-short-name "pno"
           :lowest-written a0 :highest-written c8
           :largest-fast-leap 9
           :clefs (treble bass double-treble double-bass) :starting-clef treble
           :chords t :chord-function piano-chord-fun
           :microtones nil
           :midi-program 1))
         ;; We generally treat the piano as two instruments (LH, RH), generating
         ;; lines separately. So this is the same as the piano instrument but has
         ;; no staff-name and starts with bass clef. Use set-limits to change the
         ;; range of the two hands, as they're both set to be full piano range
         ;; here.
         (piano-lh
          (:lowest-written a0 :highest-written c8
           :largest-fast-leap 9
           :chords t :chord-function piano-chord-fun
           :clefs (treble bass double-treble double-bass) :starting-clef bass
           :microtones nil
           :midi-program 1))
         (tambourine
          (:staff-name "tambourine" :staff-short-name "tmb"
           :lowest-written c4 :highest-written c4
           :starting-clef percussion
           :midi-program 1))
         (guitar
          (:staff-name "guitar" :staff-short-name "gtr"
           :lowest-written e3 :highest-written b6 :transposition-semitones -12
           :largest-fast-leap 31
           :starting-clef treble
           :chords t :chord-function guitar-chord-selection-fun
           :microtones nil
           :midi-program 28))
         (soprano
          (:staff-name "soprano" :staff-short-name "s"
           :lowest-written c4 :highest-written c6
           :starting-clef treble
           :midi-program 54))
         (violin
          (:staff-name "violin" :staff-short-name "vln"
           :lowest-written g3 :highest-written c7
           :largest-fast-leap 13
           :starting-clef treble
           :chords t :chord-function violin-chord-selection-fun
           :microtones t
           :midi-program 41))
         (viola
          (:staff-name "viola" :staff-short-name "vla"
           :lowest-written c3 :highest-written f6
           :largest-fast-leap 13
           :clefs (alto treble) :starting-clef alto
           :chords t :chord-function viola-chord-selection-fun
           :microtones t
           :midi-program 42))
         (viola-d-amore
          (:staff-name "viola d'amore" :staff-short-name "vla d'am"
           :lowest-written a2 :highest-written f7
           :largest-fast-leap 13
           :clefs (alto treble) :starting-clef alto
           :chords t :chord-function nil
           :microtones t
           :midi-program 41))
         (cello
          (:staff-name "cello" :staff-short-name "vc"
           ;; of course it can go higher but best not to algorithmically select
           ;; these
           :lowest-written c2 :highest-written a5
           :largest-fast-leap 12
           :clefs (bass tenor treble) :starting-clef bass
           :chords t :chord-function cello-chord-selection-fun
           :microtones t
           :midi-program 43))
         (double-bass
          (:staff-name "double bass" :staff-short-name "db"
           :lowest-written e2 :highest-written g5 :transposition-semitones -12
           :prefers-notes low
           :largest-fast-leap 10
           :clefs (bass tenor treble) :starting-clef bass
           :chords nil
           :microtones t
           :midi-program 44))
         ;; SAR Thu Apr 12 18:19:21 BST 2012: Added "computer" part for "silent"
         ;; parts in case the user would like to create rhythmically independent
         ;; computer parts.
         (computer
          (:staff-name "computer" :staff-short-name "comp"
           :starting-clef percussion)))))

## instruments/cello-chord-selection-fun [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     Create a double-stop chord object using the core string-chord-selection-fun
     and a value of 'G2 for the open III string.

SYNOPSIS

    (let ((vc-III (make-pitch 'g2)))
      (defun cello-chord-selection-fun (curve-num index pitch-list pitch-seq
                                        instrument set)

## instruments/chord-fun-aux [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     An auxiliary function that allows users to create moderately tailored chord
     functions by setting values for the number of notes in the current set to
     skip, the number of desired notes in the resulting chord, and the maximum
     span of the resulting chord in semitones.

     This function must be called within a call to the defun macro to create a
     new chord function, as demonstrated below.

ARGUMENTS

     The first six arguments -- curve-num, index, pitch-list, pitch-seq,
     instrument, and set -- are inherited and not required to be directly
     accessed by the user.

     - An integer that is the step by which the function skips through the
       subset of currently available pitches. A value of 2, for example, will
       instruct the method to build chords from every second pitch in that
       subset.
     - An integer that is the number of pitches that should be in each resulting
       chord. If the list of pitches available to an instrument is too short to
       make a chord with x notes, a chord with fewer pitches may be made
       instead.
     - An integer that is the largest interval in semitones allowed between the
       bottom and top notes of the chord. If a chord made with the specified
       number of notes surpasses this span, a chord with fewer pitches may be
       made instead.

EXAMPLE

    (defun new-chord-function (curve-num index pitch-list pitch-seq instrument set)
      (chord-fun-aux curve-num index pitch-list pitch-seq instrument set 4 3 14))

    => NEW-CHORD-FUNCTION

SYNOPSIS

    (defun chord-fun-aux (curve-num index pitch-list pitch-seq instrument set
                          skip num-notes max-span)

## instruments/chord-fun1 [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     Generate three-note chords where possible, using every second pitch from
     the list of pitches currently available to the given instrument from the
     current set, and ensuring that none of the chords it makes span more than
     an octave.

SYNOPSIS

    (defun chord-fun1 (curve-num index pitch-list pitch-seq instrument set)

## instruments/chord-fun2 [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     Generates 4-note chords where possible, using every third pitch from the
     list of pitches currently available to the given instrument from the
     current set, with (almost) no limit on the total span of the chord.

SYNOPSIS

    (defun chord-fun2 (curve-num index pitch-list pitch-seq instrument set)

## instruments/guitar-chord-selection-fun [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     Create chord objects with differing numbers of pitches, drawing the pitches
     from set-palette object subsets with the ID 'guitar.

     This function was written for the composition "Cheat Sheet", in which the
     pitch sets were defined explicitly such that all of the pitches available
     to the guitar at any moment were playable as a guitar chord. As such, this
     function always assumes that the pitch-list it is drawing from contains
     pitches that are already playable as a guitar chord.  It also adds the
     fingering as mark above each chord when outputting to CMN, which may or may
     not be desirable.

SYNOPSIS

    (let ((last-chord '()))
      (defun guitar-chord-selection-fun (curve-num index pitch-list pitch-seq
                                         instrument set)

## instruments/piano-chord-fun [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     Generate four-note chords, where possible, from consecutive notes in the
     current set, with the number enclosed in parentheses in the pitch-seq being
     the top note of that chord, where possible.

SYNOPSIS

    (defun piano-chord-fun (curve-num index pitch-list pitch-seq instrument set)

## instruments/string-chord-selection-fun [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     This is the core function for creating instances of double-stop chords for
     strings, ensuring that the highest note of the double-stop is not lower
     than the open III string. The pitch of the open III string is passed as an
     argument in the chord-selection functions for the individual stringed
     instruments.

     This function implements the best-string-diad function. If no double-stops
     instances can be created using best-string-diad, two-note chords will be
     created using the default-chord-function. If neither of these are possible,
     a single pitch will be returned instead.

SYNOPSIS

    (defun string-chord-selection-fun (curve-num index pitch-list pitch-seq
                                       instrument set string-III)

## instruments/viola-chord-selection-fun [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     Create a double-stop chord object using the core string-chord-selection-fun
     and a value of 'G3 for the open III string.

SYNOPSIS

    (let ((vla-III (make-pitch 'g3)))
      (defun viola-chord-selection-fun (curve-num index pitch-list pitch-seq
                                        instrument set)

## instruments/violin-chord-selection-fun [ Functions ]

[ Top ] [ instruments ] [ Functions ]

FUNCTION

     Create a double-stop chord object using the core string-chord-selection-fun
     and a value of 'D4 for the open III string.

SYNOPSIS

    (let ((vln-III (make-pitch 'd4)))
      (defun violin-chord-selection-fun (curve-num index pitch-list pitch-seq
                                         instrument set)