MusicTool is a simple command line and file interpreter coded in C. Like it's name suggests it's main purpose is to be a tool for Music operations such as scale generation, triad prog generations and analyzing various properties of musical sets and objects.
to represented musical scales, MusicTool uses sets of numbers%12. Each number present in the set represents a note present in the scale, with the number indicating how many semitones separate the fundamental note of the scale from the note. for example , the major scale would be represented as { 0 2 4 5 7 9 11 }. If we take C as the fundamental note of the major scale, it would be C D E F G A B How are scales encoded ? Scales are stored on 11 bits as unsigned short integers. It is assumed that every scale contains a fundamental note, each other note present in the scale is stored as a bit set to 1. If the first bit of the u_short is set it means that the scale contains a minor second, if the second is set a major second, ... This representation is different from the standart pitch class set representation , if you want to learn more on abstract set and pitch class set you can visit Ian Ring's website.
If you need to learn about the notion of a mode in Music Theory please visit the wikipedia article on modes harmonised scale are a list of abstract scale. And are stored as such. I assumed that it was more to store the whole harmonised scale once it is generated rather than storing it as it's fundamental mode and generating it each time it is called for an operation. Harmonised scale being a list of u_shorts of length between 2 and 11 they don't take much space. I might change this implementation if I realise it's more interresting to store them as their fundamental mode and generate them if need be (to print them for example)
A triad prog is a list of abstract triads using the degree notation of chords. An abstract triad consists on the root degree of the
triad relative to a tonic chord and the type of the triad.
Due to it being easier to store , the triads are noted as such :
major triad: [DEGREE]
minor triad: [DEGREE]m
diminished triad: [DEGREE]-
augmented triad: [DEGREE]+
sus2 triad: [DEGREE]sus2
sus4 triad: [DEGREE]sus4
I didn't use ° to represent the diminished chord bc it's an UTF-8 character and I didn't feel like working with them.
triad progs are noted between brackets.
For example: the triad prog [ IVm, V, Im] represents the triad progression from a minor triad located at the fourth degree of a scale
to a major one located at the fifth to another major one located on the tonic.
if we take the C harmonic minor scale, the progression [ IVm , V, I] would be Fm, G, Cm
A chord prog is a list of abstract chords using the degree notation of chords. An abstract chord consists on the root degree of the
triad relative to a tonic chord and the type of the triad as well as the extensions of the triad, which is why it's called "chord".
Due to it being easier to store , the chords are noted as such :
major chords: [DEGREE] add i,j,..,n
minor chords: [DEGREE]m add i,j,..,n
diminished chords: [DEGREE]- add i,j,..,n
augmented chords: [DEGREE]+ add i,j,..,n
sus2 chords: [DEGREE]sus2 add i,j,..,n
sus4 chords: [DEGREE]sus4 add i,j,..,n
The "add" is necessary only if the chord has one or more extensions. The extensions are separated by ",".
if you wish to parse a triad (chord without extensions) you can simply write the chord without add.
nb: I didn't use ° to represent the diminished chord bc it's an UTF-8 character and I didn't feel like working with them.
chord progs are noted between brackets.
For example: the chord prog [ IIm add 7 ; V add b7 ; Iadd7] represents the chord progression from a IVmaj7 chord located at the fourth degree of a scale
to a dominant 7 chord located at the fifth to another major 7 one located on the tonic.
if we take the C harmonic major scale, the progression would be Dm7, G7, Cmaj7.
Specifity of extension syntax:
-the notation of chords that omits the "add" is not supported. a Imaj7 chord HAS to be passed as "Iadd 7"
-similarly, the extensions are written as degrees. A IV add 6,9 chord HAS to be written IVadd 6,2 (or IVadd2,6 the order doesn't matter)
-the 7 always stands for major 7 degree and b7 for a minor 7th. Thus the chord Vadd7 is Vmaj7 and not V7.
a V7 chord is written Vaddb7.
the same thing applies for every other extension.
Dodecaphonic series (or tone rows) are an orderer set of every 12-tet note. They are commonly used in serial and dodecaphonic music. If you want to learn more about serialism and dodecaphonic series please check out the wikipedia article on serialism or Robert Hutchinson's course on serialism In music tool series are stored as 64 bits integer. However only the first 48 bits are relevants, the 16 remaining are used as an error flag. Each number in the serie is stored on 4 bits; the first number of the serie is stored from the LSB to bit 3 ,the second from bit 4 to 7 and so on. The MusicTool syntax for series is the same as the scale one, except a serie MUST be of length 12 (contain every note). For example: { 11 4 5 2 3 6 7 9 8 1 0} is a valid serie. MusicTool implements the common serie operations such as inversion, retrograde, prime and 12 tone matrix calculation
The progbook is an array containing abstract chord progressions that only consists of their degrees.
It is used to generate chord/triad progressions by stacking entries to create a longer prog.
The progbook thus allows to create progressions that can be more "coherent" than if they were generated
with the standart rand functions.
At the start of a session, a default progbook is loaded from the file called book_basenv.txt .
Morever, a progbook can be saved by writing the current environment to a file and can then be loaded. during a session.
It is important to notice than when a progbook is active in a session and another one is loaded, they will "fuse" and won't replace one another
DISCLAIMER: the progbook's implementation is absolutely awful. It should be some sort of hashtable but it's not.
I will have to fix it at some point.
The scale keyword is used to pass commands on scale. The commands currently available are :
-rand : rand generates random scale;
it can be passed with or without argument, if passed with an integer argument the scale
generated will be the length of the argument, otherwise the length of the scale and
the scale itself will be random. rand also makes the generated scale
the current temporary saved scale
-save : save is used to save scales , if passed with a scale argument the scale passed will
be saved;
if passed without argument, the interpreter will check if there is currently a temporary
scale saved and save it if it's the case.
-print : print can be passed with one integer argument or the env keuword. If passed with an integer it will print the scale stored at the
index passed; If passed with env, it will print every scale currently saved
-remove : remove has to be passed with one integer argument, it will remove the scale stored at
the index passed as argument if it exists and reindex the saved scales.
-invert : can be passed without argument , with a scale argument or "saved n" with n being the index of a saved scale.
If passed with an argument calculates the inverse of the scale passed or saved at index n and saves it into tmp saved.
if passed without argument calculates the inverse of the temp saved scale and stores it in temp saved scale.
-comp : can be passed without argument , with a scale argument or "saved n" with n being the index of a saved scale.
If passed with an argument it calculates the complementary of the scale passed or saved at index n and saves it into tmp saved.
if passed without argument calculates the complementary of the temp saved scale and stores it in temp saved scale.
-prime : can be passed without argument, with a scale argument or "saved n" with n being the index of a saved scale.
If passed with an argument it calculates the prime form of the scale passed or saved at index n and saves it into tmp saved.
if passed without argument calculates the prime form of the temp saved scale and stores it in temp saved scale.
-nearby : can be passed without argument, with a scale argument or "saved n" with n being the index of a saved scale.
If passed with an argument it generates a nearby scale of the scale passed or saved at index n and saves it into tmp saved.
if passed without argument it generates a nearby scale of the temp saved scale and stores it in temp saved scale.
The harmo keyword is used to pass commands on harmonised scales. The commands currently available are:
-rand : rand generates a random harmonised sscale;
it can be passed with or without argument, if passed with an integer argument the harmonised scale
generated will be the length of the argument, otherwise the length of the harmonised scale and
the harmonised scale itself will be random. rand also makes the generated harmonised scale
the current temporary saved harmonised scale
-save : save is used to save scales , if passed with a scale argument the scale passed will
be harmonised and saved as an harmonised scale;
if passed without argument, the interpreter will check if there is currently a temporary
harmonised scale saved and save it if it's the case.
-save as scale : save as scale must be passed with two integers argument J I, it will save the
Ith mode of the Jth harmonised scale as a scale if it exists and do nothing otherwise.
-scale : must be passed with one scale argument, will generate the harmonised scale of the scale
passed as arg. And make it the current temporary saved harmonised scale
-saved scale : must be passed with one integer argument, harmonises the saved scale stored at the
index passed if it exists and generates it's harmonised scale. The harmonised scale
generated is saved as the temporary saved harmonised scale
-print : can be passed with one integer argument or with env, if passed with an integer will print the harmonised scale
stored at the index passed if it exists. If passed with env, prints every harmonised scale currently stored
-remove : remove has to be passed with one integer argument, it will remove the harmonised scale
stored at the index passed as argument if it exists and reindex the saved harmonised
scales.
The triad keyword is used to pass commands on triad progs. The commands currenlty available are :
-rand : can be passed without arguments, if passed like so a fully randomised triad prog will be generated.
it can also be passed with one or more of the following args:
The prog keyword is used to pass commands on chord progs. The commands currenlty available are :
-rand : can be passed without arguments, if passed like so a fully randomised chord prog will be generated.
it can also be passed with one or more of the following args:
The dodec keyword is used to pass commands on dodecaphonic series/tone rows. The commands currenlty available are :
-rand : must be passed without argument. Retrieves a random serie by shuffling the serie {0 1 2 3 4 5 6 7 8 9 10 11} 100 times.
-save : passed with a serie or no arguments; if passed with a serie will save the serie
if passed without will save the temporary saved serie if it exists.
-print : passed with one integer argument or the env keyword prints the serie stored at index n if it exists or all the series currenlty saved if passed with env.
-remove : passed with one integer argument removes the serie stored at index n if it exists
and reindexes the remaining saved series.
-matrix: can be passed without arguments, with a serie, or with saved and an integer argument.
when passed without argument will calculate and print out the matrix of the last generated serie (if the serie is set).
when passed with a serie will calculate and print out the matrix of the serie passed.
when passed with saved n will calculate and print out the matrix of the serie saved at the nth index.
in this case they will aplly the function passed on the prime form of last serie generated (if a serie was generated).
in this case they will aplly the function passed on the Pn form (with n being the argument passed) of last serie generated (if a serie was generated).
in this case they will apply the function passed on the Pn form (with n being the argument passed) on the serie passed
in this case they will aplly the function passed on the Pn form (with n being the argument passed) on the serie saved at the index passed.
in this case they will apply the function passed on the prime form of the serie passed
in this case they will apply the function passed on the prime form of the serie saved at the index passed.
-read command: must be passed with one filename argument, will read and execute the commands on a
MusicTool:command file if it exists.
-read env: must be passed with one filename argument, will load the environment stored on a
MusicTool:filename file and add it to the current environment if it exists.
-write env: must be passed with one filename argument. If the file passed already exists,
and is a MusicTool:environment file will append the current environment to the one
stored on the environment file. If the file passed as argument doesn't exist,
will create it and write the current environment on it.
-book print: passed without argument ; prints the current progbook
-book add : passed with a degree prog argument (a chord prog containing only degrees and no triads/extensions)
adds an entry to the current session's progbook.
-help keyword : the help keyword can be passed without argument or with a string argument. if
passed without keyword it will print out general informations on MusicTool,
if passed with a the string of another keyword it will print out informations
on that keyword.
-quit keyword: must be passed without arguments. Exits MusicTool
-commentaries : MusicTool supports one line commentaries, everything after a '#' character in a
line will be considered as a commentary and won't be interpreted.
-MusicTool currently support being called with the arguments -syntaxcheck=YES and -syntaxcheck=NO.
this will set a global variable called _syntaxcheck.
If disabled, any string passed to musictool
will directly be interpreted and won't go through the MusicTool syntaxchecker.
The stability and behavior of MusicTool is not guaranteed when ran without syntax checking enabled.
MusicTool commands can be written on files. A file that contains MusicTool commands must begin by "MusicTool:commands". The commands available and their syntax are the same than the command line ones.
MusicTool environment can be written on files from command line with the command "write env" or by hand. An environment file must begin by "MusicTool:environment". to write an environment, you must begin by the keyword "env" followed by the type of the objects. The beginning and the end of the environment are marked by parenthesis For example, to write a scale environment you must write "env scale" then open a parenthesis then write the scales you want to load as MusicTool scale. writing down harmonised scales works the same as scales except the environment must begin by env harmo" writing down a triad prog env also works the same except the env must begin by "env triad". dodecaphonic series environment works similarly, but the environment must begin with "env dodec". chord prog environment works similarly, but the environment must begin with "env prog". Multiple environments can be written in a single environment file.
Shell MusicTool (for short smtool) is a program that tries to emulate the syntax of a shell command to do MusicTool operations. The goal of smtool in the long run is to maximize it's compatibility with shell scripts and make it a practical way of testing MusicTool functions or doing short operations.
smtool implements all the commands that can be parsed from music tool except the "read env" and "write env" functions Instead of launching an interpreter an smtool command is called from command line and takes two arguments; the first one corresponding to a MusicTool keyword (scale, harmo , triad,...) preceeded by a single "-" the second argument is a MusicTool command available with the keyword. To parse the command correctly, it has to be contained between double quotes. Example: the MusicTool command 'scale rand 7' would be 'smtool -scale "rand 7" ' if called from smtool. The syntax for most of the MusicTool command is the same for smtool ones; except the "read command" function which is simplified to : 'smtool -read "filename.txt" ' NB: the save family of command aren't disabled in smtool; however they are useless as each smtool command takes place in a new environment.