./../../src/change-map.lsp

## change-map/cm-get-data [ Methods ]

[ Top ] [ change-map ] [ Methods ]

FUNCTION

     cm-get-data:

ARGUMENTS

RETURN VALUE

EXAMPLE

DATE

SYNOPSIS

    (defmethod cm-get-data ((cm change-map) section
                            &optional (sequence 1) (bar 1))

## change-map/find-nearest [ Methods ]

[ Top ] [ change-map ] [ Methods ]

FUNCTION

     find-nearest:

ARGUMENTS

RETURN VALUE

EXAMPLE

DATE

SYNOPSIS

    (defmethod find-nearest (section (cm change-map))

## sc-map/change-map [ Classes ]

[ Top ] [ sc-map ] [ Classes ]

NAME

     change-map

     File:             change-map.lsp

     Class Hierarchy:  named-object -> linked-named-object -> sclist ->
                       circular-sclist -> assoc-list -> recursive-assoc-list ->
                       sc-map -> change-map

     Version:          1.0.0-beta1

     Project:          slippery chicken (algorithmic composition)

     Purpose:          Implementation of the change-map class where, unlike
                       normal sc-maps (data is given for each sequence) gives
                       data sporadically when the parameter changes, for
                       instance tempo.

                       It is assumed that maps will be typed in in the order in
                       which sections occur so that previous-data slots can be
                       kept up-to-date; also, unless all data will be given,
                       that the sections (but not instrument ids)
                       will be in integer sequential order so that nearest
                       sections can be returned when given a non-existent
                       section reference.

                       For example, the following change-map indicates tempo
                       (though tempo-maps have their own class now).
                       It has sections within sections so that the tempo for
                       section '(1 2 3) can be defined, that is, section 1 has
                       subsections 1, 2, and 3 and subsection 2 has further
                       subsections 1, 2, and 3.  This can be nested to any
                       depth.  The tempo information itself is given in sublists
                       where (3 27) means that in the third sequence of the
                       section, the tempo is 27.  (3 2 27) means the 2nd bar of
                       the third sequence has tempo 27: when only two numbers
                       are in the list, bar 1 is assumed.  The trick is, that
                       this tempo then remains, as would be expected, until the
                       next tempo change is indicated, which means that
                       requesting the tempo of section (2 2 3) with any sequence
                       and bar in the map below would return 25, because that is
                       the last tempo given in section 1 and no tempo is defined
                       for section 2.

                       (setf x
                         (make-change-map
                          'test nil
                          '((0 ((3 27) (9 3 45)))
                            (1
                             ((1 ((1 21) (5 28) (8 35) (3 2 40) (3 1 54)))
                              (2
                               ((1 ((1 23) (6 28) (18 35)))
                                (2 ((2 2 24) (7 28) (18 22)))
                                (3 ((3 34) (7 28) (18 42)))))
                              (3 ((1 22) (5 34) (10 5 25)))))
                            (4
                             ((1 ((1 21) (5 28) (8 36) (3 2 40) (3 1 55)))
                              (2 ((1 22) (5 34) (10 5 103)))))
                            (5 ((2 28) (6 3 45)))
                            (10
                             ((1 ((1 21) (5 28) (8 37) (3 2 40) (3 1 56)))
                              (2 ((1 22) (5 34) (10 5 27))))))))

                       You have to be careful with change-maps however as the
                       nesting is flexible and therefore ambigous.  For
                       instance, in the following the bcl, tape1 etc. ids are
                       not subsections of section 1, rather these are the hint
                       pitches assigned to the instruments in section 1 (which
                       has no subsections).  This is where the last-ref-required
                       class slot comes in:  If this slot is t (this is the
                       second argument to make-change-map) then the last
                       reference in a call to cm-get-data is always respected,
                       i.e. not the last data given will be returned when the
                       section doesn't exist, rather the last data for this
                       reference.  E.g. In the following map, if
                       last-ref-required  were nil, then the call to
                       (cm-get-data x '(2 tape2) 1) would fail (because we can't
                       find nearest data when references aren't numbers), but
                       because it's t, we get the last data given for tape2 and
                       return cs5.

                       (setf x
                         (make-change-map
                             'hint-pitches t
                             '((1 ((bcl ((1 a4) (2 b4) (3 c5) (4 d6)))
                                   (tape1 ((1 a3) (2 ds2) (3 e4)))
                                   (tape2 ((1 a3) (2 ds2) (3 cs5)))
                                   (tape3 ((1 a3) (2 ds2) (3 eqf4)))))
                               (2 ((bcl ((1 a4) (2 b4) (3 c5) (4 d6)))
                                   (tape1 ((1 a3) (2 ds2) (5 fs4)))))
                               (3 ((bcl ((1 a4) (2 b4) (3 c5) (4 d6)))
                                   (tape1 ((1 a3) (2 ds2) (5 f4))))))))

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

     Creation date:    2nd April 2001

     $$ Last modified: 21:14:11 Thu Dec  8 2011 ICT

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