- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatChapter9/C091102.cpp

Go to the documentation of this file.

    00001 #include "MusimatChapter9.h"
    00002 MusimatChapter9Section(C091102) {
    00003 Print("*** 9.11.2 The Set Complex ***");
    00004 /*****************************************************************************
    00005
    00006 9.11.2 The Set Complex
    00007
    00008 Using these tools, we can create a matrix containing the prime form, inverse,
    00009 retrograde, and all transpositions of any row, called the set complex. The
    00010 purpose of these transformations is to generate variants that are related to
    00011 the original intervallic structure of the prime row, to be used as material
    00012 in developing compositions.
    00013
    00014 Matrix is simply a two-dimensional grid, or list of lists, all of the same
    00015 length. The individual elements of Matrix can be accessed by extending the
    00016 index operator […]. The first operand is the matrix, the second is the row
    00017 position, and the third is the column position. (Whether row or column comes
    00018 first is arbitrary. The following order is called row/column order.)
    00019
    00020                 0       1
    00021 M =     0       A       B
    00022         1       C       D
    00023
    00024 For example, for this matrix, M[0][0] == A, M[0][1] == B, M[1][0] == C, and
    00025 M[1][1] == D. The following is a method for creating a set complex. It
    00026 basically copies the prime form to the zeroth row, then copies the inverse
    00027 form to the zeroth column, then for each other cell in the matrix sums the
    00028 corresponding row and column value modulo the length of the prime form:
    00029 *****************************************************************************/
    00030         para1(); // Step into this function to continue.
    00031         para2(); // Step into this function to continue.
    00032 }
    00033
    00034 IntegerMatrix setComplex(IntegerList prime) {
    00035         Print("Prime row:", prime);
    00036         Integer len = Length(prime);
    00037         IntegerMatrix M(len, len);
    00038         IntegerList inverted = invert(prime);
    00039         Print("Inverted row:", inverted);
    00040         For (Integer i = 0; i < len; i = i + 1) {
    00041                  M[0][i] = prime[i];
    00042                  M[i][0] = inverted[i];
    00043         }
    00044         For (Integer i = 1; i < len; i = i + 1) {
    00045                 For (Integer j = 1; j < len; j = j + 1) {
    00046                         Integer a = M[i][0];
    00047                         Integer b = M[0][j];
    00048                         // M(i,j) = Mod(M(i,0) + M(0,j), len);
    00049                         M[i][j] = Mod(a + b, len);
    00050                 }
    00051         }
    00052         Return(M);
    00053 }
    00054
    00055
    00056 Static Void para1() {
    00057 /*****************************************************************************
    00058 To demonstrate these tools, table 9.4 shows the set complex the following row:
    00059         (G, As, B, F, E, Cs, C, A, Gs, D, Ds, Fs)
    00060 o  Prime rows are read left to right,
    00061 o  Retrograde rows, right to left
    00062 o  Inverse rows, top to bottom,
    00063 o  Retrograde inverse rows, bottom to top.
    00064 This completes the precomposition phase. Now it’s time to look at methods to
    00065 traverse the rows created with the preceding techniques to generate a
    00066 composition.
    00067
    00068 Table 9.4 Set Complex
    00069 {0, 3, 4, 10, 9, 6, 5, 2, 1, 7, 8, 11}
    00070 {9, 0, 1, 7, 6, 3, 2, 11, 10, 4, 5, 8}
    00071 {8, 11, 0, 6, 5, 2, 1, 10, 9, 3, 4, 7}
    00072 {2, 5, 6, 0, 11, 8, 7, 4, 3, 9, 10, 1}
    00073 {3, 6, 7, 1, 0, 9, 8, 5, 4, 10, 11, 2}
    00074 {6, 9, 10, 4, 3, 0, 11, 8, 7, 1, 2, 5}
    00075 {7, 10, 11, 5, 4, 1, 0, 9, 8, 2, 3, 6}
    00076 {10, 1, 2, 8, 7, 4, 3, 0, 11, 5, 6, 9}
    00077 {11, 2, 3, 9, 8, 5, 4, 1, 0, 6, 7, 10}
    00078 {5, 8, 9, 3, 2, 11, 10, 7, 6, 0, 1, 4}
    00079 {4, 7, 8, 2, 1, 10, 9, 6, 5, 11, 0, 3}
    00080 {1, 4, 5, 11, 10, 7, 6, 3, 2, 8, 9, 0}
    00081
    00082 The functions below perform steps in preparation for calling setComplex().
    00083 getPC() converts a PitchList to an IntegerList by summing the diatonic
    00084 pitch class and accidental of the Pitch.
    00085 generateSetComplex() first calls getPC() to convert the Pitch list to
    00086 an IntegerList, then transposes the resulting set, then
    00087 invokes setComplex() to generate the set complex Matrix.
    00088 *****************************************************************************/
    00089 }
    00090
    00091 IntegerList getPC(PitchList p) {
    00092         IntegerList x;
    00093         For (Integer i = 0; i < Length(p); i++)
    00094                 x[i] = PitchClass(p[i]) + Accidental( p[i] );
    00095         Return( x );
    00096 }
    00097
    00098
    00099 Void generateSetComplex(PitchList P) {
    00100         IntegerList set = getPC(P);
    00101         Print("Starting set:", set);
    00102         Integer offset = set[0];
    00103         IntegerList tSet = transpose(set, -offset);
    00104         Print("Transposed set:", tSet);
    00105         IntegerMatrix sc = setComplex( tSet );
    00106         Print("Set complex:");
    00107         Print(sc);
    00108 }
    00109
    00110 Static Void para2() {
    00111 /*****************************************************************************
    00112 Here we evaluate the set complex for our test set.
    00113 *****************************************************************************/
    00114         PitchList test(G, As, B, F, E, Cs, C, A, Gs, D, Ds, Fs);
    00115         Print("*** Pitch classes for test ***");
    00116         Print(test);
    00117         generateSetComplex(test);
    00118
    00119 }}
    00120
    00122 /* $Revision: 1.2 $ $Date: 2006/09/09 06:22:42 $ $Author: dgl $ $Name:  $ $Id: _c091102_8cpp-source.html,v 1.2 2006/09/09 06:22:42 dgl Exp $ */
    00123 // The Musimat Tutorial © 2006 Gareth Loy
    00124 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy
    00125 // and published exclusively by The MIT Press.
    00126 // This program is released WITHOUT ANY WARRANTY; without even the implied
    00127 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00128 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
    00129 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
    00130 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
    00131 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
    00132 // The Musimat website:                 http://www.musimat.com/
    00133 // This program is released under the terms of the GNU General Public License
    00134 // available here:                      http://www.gnu.org/licenses/gpl.txt
    00135