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
1. Generate a row of random pitches
To generate random pitches, this program randomizes up to 10000 numbers using the ctime library, and then translates them to pitch names by mapping them to fixed table of pitches. It uses a constant table as shown below:
const string TABLE[12] = {"C ", "C# ", "D ", "Eb ", "E ", "F ", "F# ", "G ", "Ab ", "A ", "Bb ", "B "};
Then, a random generator is "seeded" using the following code:
srand(unsigned(time(NULL)));
2. Construct a row with input of any integers
In this program, the user is asked to input a row consisting of up to 50 integers that fall between -2147483647 and 2147483647 (the max number of integer an "int" in C++ can hold). Each integer is then run through a modulation program that transposes it (if it is outside the range of 0 to 11) back to the range, and returns the corresponding pitch number for use. This program can be used to put numbers that are normally larger or smaller than an octave into a "musical" context.
The modulation program is implemented as followed:
The modulation program is implemented as followed:
int mod(int num, int sizeRange) {
while(num >= sizeRange)
num -= sizeRange;
while(num < 0)
num += sizeRange;
return num;
}
while(num >= sizeRange)
num -= sizeRange;
while(num < 0)
num += sizeRange;
return num;
}
This function runs for as long as the integer is larger than 11 or smaller than 0. The final result is a stream of pitches.
3. Construct a twelve-tone row to be mapped to a custom table
Instead of using the default chromatic table (C-C#-D-Eb-etc.), the user is given the option to use a custom table. For example, if using a reverse chromatic table (C-B-Bb-A-etc.), the pitches of (0-1-2-3) mapped to this table would be (C-B-Bb-A) instead of (C-C#-D-Eb). The user is given an option to generate a twelve-tone row randomly to create this table, and it is implemented as below:
void Modules::generateTwelve(int rType) {
bool repeated;
int generatedPitch;
int counter = 0;
srand(unsigned(time(NULL)));
while (counter < 12) {
repeated = false; // control if the counter increments
generatedPitch = rand() % 12; // generate a random number between 0-11
for (int i = 0; i < counter; i++) { // check all items before the current position
if (generatedPitch == getRow(i, 1)) // if a pitch is repeated, repeated = true, do not advance counter
repeated = true; // otherwise, repeated remains false
}
if (repeated == false) { // if there's no repeat before the current position, assign the pitch
setRow(counter, generatedPitch, rType);
counter++; // continue to the next item in array
}
}
}
bool repeated;
int generatedPitch;
int counter = 0;
srand(unsigned(time(NULL)));
while (counter < 12) {
repeated = false; // control if the counter increments
generatedPitch = rand() % 12; // generate a random number between 0-11
for (int i = 0; i < counter; i++) { // check all items before the current position
if (generatedPitch == getRow(i, 1)) // if a pitch is repeated, repeated = true, do not advance counter
repeated = true; // otherwise, repeated remains false
}
if (repeated == false) { // if there's no repeat before the current position, assign the pitch
setRow(counter, generatedPitch, rType);
counter++; // continue to the next item in array
}
}
}
This twelve-tone generator is also used in other programs.