transposer

[Class]
  `transposer`

A pattern that combines transposition data with transposition offsets to return notes, key numbers or lists of the same. Transposed data may be optionally retrograded and inverted.

`transposer` supports the following slot initializations:

`:of` {list | pattern}
  The transposition data. Elements in list or pattern can be notes or key numbers. A list is treated as a single unit by the transposer.
`:by` {note | keynum | pattern}
  Sets the transposition offset. If a pattern is specified a new offset is selected each period of the transposition data. The alias name `:on` can also be used for this initialization.
`:stepping` {pattern}
  Like `:by` except that a new transposition offset is selected each time an element is transposed rather than once each period.
`:form` {`:p` | `:i` | `:r` | `:ri` | pattern}
  A symbol or pattern of symbols that specifies the "row form" for list data returned by the transposer, where `:p` stands for prime, `:i` for inversion, `:r` for retrograde and `:ri` for retrograde-inversion. Either symbols or keywords can be used to specify the row form. A new row form is read each time the transposition offset changes.
`:mod` {number | pattern}
  Optional modulus on list data.
`:scale` {scale}
  The scale to transpose data in. The default value is the *chromatic-scale*.

See generic pattern initializations for documentation on additional keyword initializations to the pattern.

#### Examples:

Example 1. Wandering chords.

    (define pat1
      (new transposer
           :of (new random :of '(((0 2 6 11) :weight 1)
                                 ((0 3 5 10) :weight .25)
                                 ((0 4 9 15) :weight .5)
                                 ((0 3 11) :weight .5)
                                 ((0 8 11) :weight .5)))
           :stepping (new range :from 60 :to 70 :downto 50
                          :stepping (new random
                                         :of '(-1 1 -2 2 -3 3)))))

    (define (play-pat reps pat rate)
      (process repeat reps
               each k in (next pat)
               output (new midi :time (now)
                           :keynum k
                           :duration (* rate 1.5))
               wait rate))

    (events (play-pat 50 pat1 .3) "test.mid")
    ⇒ "test.mid"

Example 2. Random 12-tone generator

    (define (ran-row end)
      (let ((rows (new transposer
                    :of (new cycle :of '(0 1 6 -5 10 11 5 16 15 21 26 20))
                    :on (new random :keynums '(c4 cs3 b3 fs4 fs3))))
            (rhys (new random
                    :of `((t :min 4) (s :min 2)
                          (q :weight 3)
                          (te :min 3) (tq :min 3)
                          ,(new cycle :of '(e. s))
                          (e :weight 2))))
            (amps (new random :of '((mf :weight 7)
                                    (mp :weight 3)
                                    p))))
        (process while (< (now #t) end)
                 for k = (next rows)
                 for r = (rhythm (next rhys) 70)
                 for a = (amplitude (next amps))
                 output (new midi :time (now)
                             :keynum k :amplitude a
                             :duration r)
                 wait r )))
    (events (ran-row 30) "test.mid")
    ⇒ "test.mid"

#### See also:

- Pattern classes [Topic]