next up previous contents
Next: Displaying and Removing Objects: Up: A Manual for SAWDUST Previous: Transforming linkIn into linkOut:   Contents

Subsections

Transforming linkIn into linkOut: turn

turn transforms an initial link into a final one.

Example:

    *    turn
    name:        t2                    
    first link name:    l1            
       3 elem;   60 samples            
    position?    1                    
    last  link name:    l2            
       4 elem;  100 samples
    position?    1                    
    rotate?    n                        
    play last link?    y                
    Amplitude range 1000 to 4000
    use default values ?    y        
    Linkstates = 41, linksum 3280
    turnsum?    44100                
    statements=    10                    
    Wavy ? y

Explanation:

    *    turn
    name:        t2                 # name of turn (identifier)
    first link name:    l1          # initial link
       3 elem;   60 samples         # duration of link in samples
    position?    1                  # which element should the
                                    # initial link start with?

    last  link name:    l2          # final link
       4 elem;  100 samples         # duration of link in samples
    position?    1                  # which element should the final
                                    # link start with?

    rotate?    n                    # if 'no' then
                                    #    (e1 e2 e3) (e1 e2 e3) (etc)
                                    # else
                                    #    (e1 e2 e3) (e2 e3 e1) (e3 e1 e2) (etc)

    play last link?    y            # 

    Amplitude range 1000 to 4000
    use default values ?    y       # 

    Linkstates = 41, linksum 3280   # 
    turnsum?    44100               # duration of turn in samples

    statements=    10               # how many times should it be played?

    Wavy ? y                        # if Wavy is 'y', then:
                                    #    l1 -> l2 -> l1 -> l2 (etc.)
                                    # if Wavy is 'n', then:
                                    #    l1 -> l2    l1 -> l2 (etc.)

The problem addressed by turn

The algorithm turn is a solution to the problem: how to maintain a constant rate of change of pitch during a transformation?

This problem is a result of a premise of SAWDUST, and applies to both vary and turn: An inital link is linearly transformed into a final link.

For example, if there are two links, with a sum of 100 samples and 50 samples, and a transformation is made from the first to the second, the resulting sound would go up in pitch by one octave. (The first link would create a frequency of 441 Hz, and the second 882 Hz, at a sampling rate of 44100.)

However, the resulting in a sound would appear to be ascending at a faster and faster rate.

The opposite is true when moving from the second to the first link: as the pitch went down, it would appear to be getting slower and slower.

Brün invented a remarkable solution for this problem, that remained consistent with the linear change premises of SAWDUST.

The turn algorithm

In a turn, linkIn is transformed into linkOut.

Both linkIn and linkOut have constituent elements (but not necessarily the same number of elements). Each element has an amplitude (0-4096) and a duration (in samples).

The duration of each element in linkIn is transformed (step-wise, by integers) into the duration of the corresponding element in linkOut.

The amplitude of each element in linkIn follows the path of a triangle wave, as it is transformed into the corresponding element's amplitude in linkOut.

Thus, the transformations of the durations and the amplitudes are mutually independent.

If linkIn and linkOut do not have the same number of elements, SAWDUST will add $n$ ``empty''elements to the smaller of the two, where $n$ is the difference between the number of elements in linkIn and linkOut. (An ``empty'' element has zero amplitude and zero duration.)

turn amplitudes

In a turn, each elements' amplitude in linkIn follows the path of a triangle wave, as it is transformed into its corresponding elements' amplitude in linkOut.

The amplitudes' paths are determined by the following:

    if ( amp >= midpoint ) then
        1. amp descends until it reaches minimum. 
        2. ascends until it reaches maximum.
        3. descends to its destination value
    else if ( amp < midpoint ) then
        1. amp ascends until it reaches maximum.
        2. descends until it reaches minimum.
        3. ascends to its destination value.

midpoint is equal to 4096/2. By default, $minimum$ and $maximum$ are set to the smallest and largest amplitudes in linkIn and linkOut.

If amp >= midpoint, the amplitude increment is:


\begin{displaymath}inc_i ~=~ {{2 max - 2 min + linkIn_i - linkOut_i} \over turnsum}\end{displaymath}

if amp < midpoint, the amplitude increment is:


\begin{displaymath}inc_i ~=~ {{2 max - 2 min + linkOut_i - linkIn_i} \over turnsum}\end{displaymath}

In both cases, $turnsum$ is the duration of the turn in samples.

Here is a plot of the amplitude paths for three elements, where linkIn has amplitudes 100, 4000, 2000, and linkOut has amplitudes 4000, 100, 3200.

\includegraphics*{amps.eps}

In the above plot, the element that starts with an amplitude of 2000, rises to its maximum (4096), then descends to its minimum (0), and then rises to its final value (3200).

In contrast the element whose initial value is 4000, first descends to its minimum value (0), then rises to its maximum (4096), and then descends to its final value (100).

turn samples

The transformation of durations in a turn follows a step-wise, integer path, from the inital to the final link. However, each state in the transformation is repeated, with the shorter states (the higher pitched ones) repeated more often than the longer states (the lower pitched ones).

The following function (written by Elizabeth Mitro) determines the number of steps in the transformation between the initial and the final link:


\begin{displaymath}linkStates~=~\sum_{i~=~0}^{N} \vert~initial\_link_i~-~final\_link_i~\vert\end{displaymath}

where

$linkStates$ is thus the sum of the difference in durations of the inital and final elements: it is the minimum number of steps necessary for the transformation.

$linkSum$ is the sum of durations of the $linkStates$: it is the minimum duration necessary for the transformation.

Once the $linkStates$ in the transformation is known, the duration of each step in the transformation can be determined:


\begin{displaymath}step\_duration~=~{ turnsum \over linkStates}\end{displaymath}

where

Once the $step\_duration$ is known, the number of repetitions of the link at that step is calculated:


\begin{displaymath}number\_of\_repeats~=~{step\_duration \over link\_duration}\end{displaymath}

The above calculation ensures that the smaller the link, the greater the number of repetitions.

Thus, in a transformation from a high-pitched to a low-pitched link, the high-pitched links will be repeated more times than the low-pitched links, resulting in an ``even'' descent.

The command turn

To define a turn, you must input

A name for the turn.

The first and last link names.

The element starting position of the first and last links.

Whether the turn should be ``rotated''.

Whether the last link should be played.

Whether the default values should be used for the amplitudes.

The duration of the turn in samples (the ``turnsum'').

The number of statements (iterations) of the turn.

Whether sequential statements are to be ``wavy'' or not.

name, first link name, and last link name

name asks for an identifier for this turn.

first link name asks for the name of the link to be assgned as linkIn.

last link name asks for the name of the link to be assgned as linkOut.

position? and rotate

rotate? and position? need each other.

If rotate? is answered ``y'', then at every state of the transformation, the sequence of elements will cycle.

For example, if there are three elements:


\begin{displaymath}e1 ~ e2 ~ e3 ~ \vert ~ e2 ~ e3 ~ e1 ~ \vert ~ e3 ~ e1 ~ e2 ~ \vert ~ e1 ~ e2 ~
e3 ~ (etc.)\end{displaymath}

were every group of three above is a state of the transformation.

The number given in response to position? determines the starting element for the first state in the rotation, and the starting element for the final state in the rotation.

In effect, rotate increases the period length of the transformation by the number of elements in the transformation. So, if there are three elements in the transformation, the period of a rotated transformation will be three times the length of a non-rotated transformation.

Amplitude range; use default values?

By default, turn uses the greatest and smallest amplitudes in the first and last links for the minimum and maximum values to which all the amplitudes will grow and shrink.

If you wish, you can override these default values, and enter other values.

turnsum?

turnsum? asks for the duration of the turn in samples.

At a sampling rate of 44100 samples per second, if you wanted a turn to last for 10 seconds, you would type in 441000.

statements and Wavy?

``Statements'' is the number of times the turn will be played.

If ``statements'' is greater than 1, then the question ``Wavy?'' will be asked.

A ``wavy'' turn alternates transformations between linkIn to linkOut, and linkOut to linkIn:


\begin{displaymath}linkIn ~\rightarrow~linkOut ~\rightarrow~linkIn ~\rightarrow~linkOut \ldots \end{displaymath}

The first statement makes a transformation from linkIn to linkOut, the second statement makes a transformation from linkOut to linkIn, the third statement is the same as the first, the fourth is the same as the second, etc.

A non-``wavy'' turn has all the statements the same: the transformations are only from linkIn to linkOut.


next up previous contents
Next: Displaying and Removing Objects: Up: A Manual for SAWDUST Previous: Transforming linkIn into linkOut:   Contents
Arun Chandra 2001-05-18