composing tools for the command line
Title: "ctools"
Version: 2.0
Year: 2015-2016
Development Language: C++
Platform: Mac OSX/Windows
Interface: CLI
Description: This program lets you construct pitch sets, rows or matrixes from input, then display them or outputs them to a text file in the same directory. There are thirteen sub-programs available.
Download the latest build release for Max OSX (2016-04-17): ctools-2.0-release-Mac.zip
Download the latest build release for Windows 10 (2016-04-17): ctools-2.0-release-Win.zip
Version: 2.0
Year: 2015-2016
Development Language: C++
Platform: Mac OSX/Windows
Interface: CLI
Description: This program lets you construct pitch sets, rows or matrixes from input, then display them or outputs them to a text file in the same directory. There are thirteen sub-programs available.
Download the latest build release for Max OSX (2016-04-17): ctools-2.0-release-Mac.zip
Download the latest build release for Windows 10 (2016-04-17): ctools-2.0-release-Win.zip
10. Compute the prime set from a given set
This program calculates the Prime Set of a given set. It first populates a two-dimensional array with all possible transpositions of all normal sets, then it subtracts the sets with the smallest pitch in each, reducing them to all start on pitch 0, before doing an insertion sort of all the sets. Insertion sorts of arrays and two-dimensional arrays are embedded in one function, where it access the private members from the Modules object:
void Modules::sortRow(int choice) {
if (choice == 1) {
for (int i = 0; i < rowSize; i++) { // insertion sort of rowPrime
int j = i;
while (j > 0 && rowPrime[j] < rowPrime[j - 1]) {
swap(rowPrime[j], rowPrime[j - 1]);
j--;
}
}
} else {
for (int k = 0; k < rowSize * 4; k++) { // insertion sort of all normal sets
for (int i = 0; i < rowSize; i++) {
int j = i;
while (j > 0 && rowMulti[k][j] < rowMulti[k][j - 1]) {
swap(rowMulti[k][j], rowMulti[k][j - 1]);
j--;
}
}
}
}
}
if (choice == 1) {
for (int i = 0; i < rowSize; i++) { // insertion sort of rowPrime
int j = i;
while (j > 0 && rowPrime[j] < rowPrime[j - 1]) {
swap(rowPrime[j], rowPrime[j - 1]);
j--;
}
}
} else {
for (int k = 0; k < rowSize * 4; k++) { // insertion sort of all normal sets
for (int i = 0; i < rowSize; i++) {
int j = i;
while (j > 0 && rowMulti[k][j] < rowMulti[k][j - 1]) {
swap(rowMulti[k][j], rowMulti[k][j - 1]);
j--;
}
}
}
}
}
Then, the program stores the positions in the two-dimensional array where the smallest outer pitches occur. Using those positions and the above process again, the program finds where the smallest pitches occur starting on the first pitch, then the second pitch, etc., until it finds a position where all pitches are smallest.
int position = 0;
int posarr[48]; // store the smallest numbers from each column
smallest = 12;
// find smallest pitch on last column of all rows
for (int i = 0; i < module.getrowsize(1) * 4; i++)
smallest = (module.getmultirow(i, module.getrowsize(1) - 1) < smallest) ? module.getmultirow(i, module.getrowsize(1) - 1) : smallest;
// store the positions where the smallest outer pitch occurs
// if the position's value is not the smallest, store -1
for (int i = 0; i < module.getrowsize(1) * 4; i++)
posarr[i] = (module.getmultirow(i, module.getrowsize(1) - 1) == smallest) ? i : -1;
int column = 1; // start the above process again on second pitch
while (column < module.getrowsize(1) - 1) {
smallest = 12; // initialize smallest to 12 every time
// find smallest pitch on each column
for (int i = 0; i < module.getrowsize(1) * 4; i++) {
if (posarr[i] >= 0) // only check posarr[i] that are positive
smallest = (module.getmultirow(posarr[i], column) < smallest) ? module.getmultirow(posarr[i], column) : smallest;
}
// store the positions where the smallest 2nd pitch occurs
// when the loop comes back, it finds smallest 3rd pitch, etc, but only on positions
// where the previous pitch is smallest
for (int i = 0; i < module.getrowsize(1) * 4; i++) {
if (posarr[i] >= 0) // only check posarr[i] that are positive
posarr[i] = (module.getmultirow(posarr[i], column) == smallest) ? i : -1;
}
column++;
}
int posarr[48]; // store the smallest numbers from each column
smallest = 12;
// find smallest pitch on last column of all rows
for (int i = 0; i < module.getrowsize(1) * 4; i++)
smallest = (module.getmultirow(i, module.getrowsize(1) - 1) < smallest) ? module.getmultirow(i, module.getrowsize(1) - 1) : smallest;
// store the positions where the smallest outer pitch occurs
// if the position's value is not the smallest, store -1
for (int i = 0; i < module.getrowsize(1) * 4; i++)
posarr[i] = (module.getmultirow(i, module.getrowsize(1) - 1) == smallest) ? i : -1;
int column = 1; // start the above process again on second pitch
while (column < module.getrowsize(1) - 1) {
smallest = 12; // initialize smallest to 12 every time
// find smallest pitch on each column
for (int i = 0; i < module.getrowsize(1) * 4; i++) {
if (posarr[i] >= 0) // only check posarr[i] that are positive
smallest = (module.getmultirow(posarr[i], column) < smallest) ? module.getmultirow(posarr[i], column) : smallest;
}
// store the positions where the smallest 2nd pitch occurs
// when the loop comes back, it finds smallest 3rd pitch, etc, but only on positions
// where the previous pitch is smallest
for (int i = 0; i < module.getrowsize(1) * 4; i++) {
if (posarr[i] >= 0) // only check posarr[i] that are positive
posarr[i] = (module.getmultirow(posarr[i], column) == smallest) ? i : -1;
}
column++;
}
11. Print the table of pitch class sets
This program prints out a table of all pitch class sets. They are complimented with commentaries by theorist Larry Solomon. More info can found here.