# Sequence Example

A sequence of notes is often specified by a "note list," consisting of times, durations, other transformations, and a parameterized behavior to generate the sound. The following is an example. Note: examples are given in SAL syntax followed by Lisp syntax in a smaller font.

    function ringpat1()
      return sim(0.6 * ring(0.6, 45, 2) @ 0.0,
                 0.5 * ring(0.8, 40, 1.5) @ 0.2,
                 0.8 * ring(1 44, 1) @ 0.6,
                 0.7 * ring(1.2, 32, 0.8) @ 0.8) * 0.8

    (defun ringpat1 ()
      (scale 0.8
        (sim
          (scale 0.6 (at 0.0 (ring 0.6 45 2)))
          (scale 0.5 (at 0.2 (ring 0.8 40 1.5)))
          (scale 0.8 (at 0.6 (ring 1 44 1)))
          (scale 0.7 (at 0.8 (ring 1.2 32 0.8)))
        )))

Notice that there are 4 sounds. The sounds are shifted in time using the @ (at) transformation, and all four sounds are combined using the `sim` construction. Because of the time shifts, the sounds do not take place simultaneously, but they may overlap somewhat.

Durations are specified by the first parameter to `ring`, so no `stretch` transformations are used here. Each sound is individually scaled.

To play this sound, you need the `ring` function from Vinyl Scratch Tutorial. Then you can type:

    play ringpat1()

    (play (ringpat1))

Try the following combination, which plays a short and long version of `ringpat1` at about the same time:

    play sim(1.0 * ringpat1() @ 0.0,
             0.7 * ringpat1() ~ 1.5 @ 0.05)

    (play (sim
            (scale 1.0 (at 0.0 (ringpat1)))
            (scale 0.7 (at 0.05 (stretch 1.5 (ringpat1)))) ))