Functions for manipulating Lists as musical rows. More...
Functions | |
template<class Type > | |
Type Reference | Rotate (Type Reference f, Integer n) |
Rotate the elements of a List. | |
template<class Type1 , class Type2 > | |
Type1 | Transpose (Type1 L, Type2 t, Type2 lim) |
Transpose the elements of a List. | |
PitchList | Transpose (PitchList L, Integer t) |
Transpose the elements of a PitchList. | |
template<class Type1 , class Type2 > | |
Type1 | Invert (Type1 L, Type2 lim) |
Invert a List. | |
PitchList | Invert (PitchList L, Integer lim=12) |
Invert a PitchList. | |
template<class Type > | |
Type Reference | Retrograde (Type Reference L) |
Retrograde a List. | |
template<class MatrixType , class ListType > | |
MatrixType | SetComplex (ListType prime) |
Create a set class (matrix) from a List. | |
template<class ElementType , class ListType > | |
ElementType | cycle (ListType L, Integer Reference pos, Integer inc) |
Traverse cyclicly through a List. | |
template<class ElementType , class ListType > | |
ElementType | palindrome (ListType L, Integer Reference pos, Integer Reference inc) |
Traverse a List palindromically. | |
template<class ElementType , class ListType > | |
ElementType | permute (ListType L, Integer Reference pos, Integer Reference count, Integer inc) |
Permute a List. | |
Integer | InterpTendency (Real f, IntegerList L1, Integer Reference pos1, IntegerList L2, Integer Reference pos2, Integer inc) |
Interpolation tendency. | |
Pitch | LinearInterpolate (Pitch x, Pitch xMin, Pitch xMax, Pitch yMin, Pitch yMax) |
Linear interpolation in Pitch space. | |
template<class ElementType , class ListType > | |
ListType | stretch (ListType L, ElementType xMin, ElementType xMax, ElementType yMin, ElementType yMax) |
Use linear interpolation to map an entire function to a different range. | |
template<class ListType > | |
ListType | RandomRow (Integer N) |
RandomRow. | |
template<class ElementType , class ListType > | |
Void | swap (ListType Reference L, Integer from, Integer to) |
Swap two elements in a List. | |
template<class ElementType , class ListType > | |
ListType | shuffle (ListType L) |
Perform swap() operation on every element of List, thereby shuffling it. | |
template<class ElementType , class ListType > | |
ElementType | randTendency (ListType L1, Integer Reference pos1, ListType L2, Integer Reference pos2, Integer inc) |
Use a row to specify an upper boundary and another row to specify a lower boundary, and then pick a pitch in this range. |
Functions for manipulating Lists as musical rows.
ElementType cycle | ( | ListType | L, |
Integer Reference | pos, | ||
Integer | inc | ||
) |
Traverse cyclicly through a List.
cycle() returns to the head of the list when it walks off the end, and returns to the end of the list if it walks off the head.
L | List to be traversed |
pos | Current position in the list. Updated on return to new position in the list. |
inc | Number of list elements to skip. |
Integer InterpTendency | ( | Real | f, |
IntegerList | L1, | ||
Integer Reference | pos1, | ||
IntegerList | L2, | ||
Integer Reference | pos2, | ||
Integer | inc | ||
) |
Interpolation tendency.
f | Factor ranging from 0.0 to 1.0 |
L1 | List 1 |
pos1 | Position parameter for List 1 |
L2 | List 2 |
pos2 | Position parameter for List 2 |
inc | Amount by which to adjust position |
Definition at line 21 of file Row.cpp.
References Return, Round(), and unitInterp().
Invert a PitchList.
L | PitchList to invert |
lim | Modulo limit to apply |
Definition at line 74 of file Row.h.
References For, List< Type >::invert(), List< Type >::length(), and Return.
Type1 Invert | ( | Type1 | L, |
Type2 | lim | ||
) |
Linear interpolation in Pitch space.
x | Value ranging from xMin to xMax |
xMin | Minimum range of x |
xMax | Maximum range of x |
yMin | Target minimum range |
yMax | Target maximum range |
Definition at line 27 of file Row.cpp.
References Pitch::degree(), and Return.
ElementType palindrome | ( | ListType | L, |
Integer Reference | pos, | ||
Integer Reference | inc | ||
) |
Traverse a List palindromically.
palindrome() returns to the head of the list when it walks off the end, and returns to the end of the list if it walks off the head. palindrome() alternates traversal of prime and retrograde form
L | List to be traversed |
pos | Current position in the list. Updated on return to new position in the list. |
inc | Number of list elements to skip. |
ElementType permute | ( | ListType | L, |
Integer Reference | pos, | ||
Integer Reference | count, | ||
Integer | inc | ||
) |
Permute a List.
Iterate the supplied sequence in prime order until exhausted, then permute the entire row by inc steps and repeat from the beginning
L | List to be traversed |
pos | Current position in the list. Updated on return to new position in the list. |
count | Reference parameter that tracks the number of steps so far |
inc | Number of list elements to skip when we permute |
Definition at line 150 of file Row.h.
References If, Length(), and Return.
{ Integer curPos = pos; // save the current position ElementType x = cycle<ElementType,ListType>( L, pos, 1 ); // update pos and get list value count = count + 1; // increment counter If ( count == Length( L ) ) { // have we output L items from list? count = 0; // reset count pos = curPos + inc; // permute position for next time } Return( x ); }
ListType RandomRow | ( | Integer | N ) |
RandomRow.
N | Length of row |
Definition at line 198 of file Row.h.
References For, If, IRandom(), and Return.
{ IntegerList L; // Keep track of the pitches chosen so far ListType M; // Used to build up our random 12-tone row Integer i; // First, set all list elements to zero, which means "unused" For ( i = 0; i < N; i = i + 1 ) { L[ i ] = 0; } // Now build up M, marking off elements in L when they are chosen For ( i = 0; i < N; i = i ) { Integer x = IRandom( 0, N - 1 ); If ( L[ x ] == 0 ) { // Hasn't been chosen yet? L[ x ] = 1; // Mark it "used" M[ i ] = x; // Save the result i = i + 1; // Now increment the control variable } } Return( M ); }
ElementType randTendency | ( | ListType | L1, |
Integer Reference | pos1, | ||
ListType | L2, | ||
Integer Reference | pos2, | ||
Integer | inc | ||
) |
Use a row to specify an upper boundary and another row to specify a lower boundary, and then pick a pitch in this range.
L1 | List specifying upper boundary |
pos1 | Current position in L1 |
L2 | List specifying upper boundary |
pos2 | Current position in L2 |
inc | Amount to increment |
Type Reference Retrograde | ( | Type Reference | L ) |
Type Reference Rotate | ( | Type Reference | f, |
Integer | n | ||
) |
MatrixType SetComplex | ( | ListType | prime ) |
Create a set class (matrix) from a List.
prime | Prime form of the list |
Definition at line 92 of file Row.h.
References For, Invert(), Length(), Mod(), and Return.
{ Integer len = Length( prime ); MatrixType M( len, len ); ListType inverted = Invert( prime, 12 ); Integer i; For ( i = 0; i < len; i = i + 1 ) { M[0][i] = prime[i]; M[i][0] = inverted[i]; } For ( i = 1; i < len; i = i + 1 ) { For ( Integer j = 1; j < len; j = j + 1 ) { M[ i ][ j ] = Mod( M[ i ][ 0 ] + M[ 0 ][ j ], len); } } Return( M ); }
ListType shuffle | ( | ListType | L ) |
ListType stretch | ( | ListType | L, |
ElementType | xMin, | ||
ElementType | xMax, | ||
ElementType | yMin, | ||
ElementType | yMax | ||
) |
Use linear interpolation to map an entire function to a different range.
L | List to stretch |
xMin | Minimum value range of L |
xMax | Maximum value range L |
yMin | Minimum range of resulting stretched list |
yMax | Maximum range of resulting stretched list |
Definition at line 187 of file Row.h.
References For, Length(), linearInterpolate(), and Return.
{ For ( Integer i = 0; i < Length( L ); i = i + 1 ) { L[ i ] = ElementType( linearInterpolate( L[ i ], xMin, xMax, yMin, yMax ) ); } Return( L ); }
Transpose the elements of a PitchList.
Transpose performs modulus arithmetic on pitches within the scale. That is, pitches transposed outside the span of the scale are wrapped back into the scale.
L | PitchList to transpose |
t | Number of degrees to transpose by |
Definition at line 54 of file Row.h.
References For, List< Type >::length(), and Return.
Type1 Transpose | ( | Type1 | L, |
Type2 | t, | ||
Type2 | lim | ||
) |