Csgrouper lumps together many permutational functions needed also to understand discussions about serial music that may occur on this blog. Thus it is useful to provide here a list of these functions linking to separate and explicit code excerpts. This work will be done progressively as needs arise. Each one of the following programs should contain some usage tips made available when running it with no argument.
Creating the set of all permutations of distinct elements takes quite a bit of time and is faster done in C by a recursive function like this one:
With Perl and other object oriented languages, one gets the best results using iterators as in:
which is mostly copied from Mark Jason Dominus’ valuable “Higher Order Perl“. It offers the asset of letting you stop in the middle of a computation and restart later where you left off.
A permutation is always a manner of arranging signs in a particular order. The signs chosen are normally the well ordered list of figures available in a given base. For example, 0123 are the signs which can be permuted in base 4. Now a permutation can be applied to itself so that it gets a power higher than one. If this process is done enough times you get back to the original well ordered list of signs, having created a cyclic set with only one original permutation. The number of elements in the cycle varies according to the chosen permutation and can be called the “degree” of the permutation which in itself has power one when each other permutation in the cyclic set has a higher power till the last, which is the well ordered list of signs and can be called “natural series” and has the power of the degree or also power zero. This cyclic set can be called a “gradual suite”. It is widely used in Csgrouper, and here is the code to produce it for each permutation till base 24:
Now that we can apply a permutation onto itself, we see that we can also apply a permutation on another one. This process is called “composition”. The following script requires as arguments two permutations in the same base. If provided, a third numeric argument n will make the subroutine apply the permutation recursively as in a gradual suite, but n times:
Permutations can be analyzed as lists of binary substitutions of signs. 0 can take the place of 3 when 3 takes the place of 1, 1 the place of 0, and 2 remains in its original position for example, and that is 1320. In this schema we have a group of 3 signs that do permute and one that does not and we can write that 130 2 where the first group of signs is called a 3-tuple. This expression of a permutation shows immediately which signs permute and how. We call it the “uplets” of a permutation or its “elementary partition”. It can have several n-tuples but each singleton will mean that the sign doesn’t move. Here is a script to extract the elementary partition of a permutation:
Now we can also have to do the reverse operation and rebuild a permutation from its given uplets:
Knowing the elementary partition of a permutation allows to procede to further analysis and find for example which are the gradual suites that do contain a given permutation in their cycles. The nature of some specific elementary partition can be expressed as a series of uplet cardinalities which has some importance in the same perspective. This expression can be called the “type” of the permutation (or of the partition); for instance, the type of 1320 is 1010. Here is a script to get this value:
Searching for a particular permutation
With the above can we write a little script to search the permutations set for some particular contents. In the following code, we enabled a condition to search for the presence of a particular permutation in gradual suites. It’s useful for small bases but too long when we come to higher bases; thus we need a better function for our musical research. However, this script will serve as a verification tool in our building more appropriate methods.
Using the function Gradual(Omap())
The only main concept missing is the Mapped Opposite which enables the musician to choose among sets of series sensitive to their permutational properties (Cf. J.Palfi et al., 2008, Le dodécaphonisme comme outil d’analyse).
To say things quickly, the mapped opposite uses what group theory calls an invariant, in order to have a suite transposed permutationnally. If you do the gradual suite of the opposite of any series S mapped onto S, you get a suite G that is the same for each transposition of S. Now if you unmap each element of G from S+1 you get a transposed suite Q+1, and you can get Q+2 by unmapping G from S+2. Capisce?
print Csgrouper::Gradual(Csgrouper::Omap(“32014”),’a’) =
12340 23401 34012 40123 # The gradual suite made upon the mapped opposite of 32014. print Csgrouper::Gradual(Csgrouper::Omap(Csgrouper::Transpose("32014","00000",1,5,'')),'a') = 12340 23401 34012 40123 # We see that however transposed, the result is the same. print Csgrouper::Gradomap("32014",'a') = 20143 01432 14320 43201 # This is the gradual suite made of the mapped opposite, where each row has been unmapped from 32014. print Csgrouper::Gradomap(Csgrouper::Transpose("32014","00000",1,5,''),'a') = 31204 12043 20431 04312 # Here each row from the previous suite is transposed, permutationally.
The only thing to care about is that these gradual suites – as they are produced by Gradomap() in the Csgrouper sequence creation process (and not as in here with the command line) – will contain an additionnal row in the beggining, which is the original row S itself, or S+n if transposed. This allows us to keep in touch with our starting point musically, and it is not unsound permutationally, since S is the last element in the cyclic suite (we could have made it last too). The difference, with normal, not unmapped, Gradual suites – which contain one row less – comes from the fact that in normal Gradual suites, as in the above example, Csgrouper does not add the last element which is always equivalent to Natural(S) i.e. the chromatic scale (for this has rarely a nice effect in music).
Note: in the preceding example Gradual(Omap(S)) is the original function without unmapping, unlike Gradomap(S) which proceeds to the unmapping. However, in Csgrouper’s Sequence Details tab, where one can choose functions by menu, the menu item Gradual(Omap(S)) implies automatic unmapping and in fact calls internally Gradomap(). This is due to the fact that musically speaking, Gradomap() is much more interesting as it yields transposed suites. If a user wants to create a bare Gradual(Omap(S)), she will have to do it through command line as above and then paste the result as a Suite() into the chosen Sequence window. So all this naming is fallacious, and I should have named the menu item Unmap(Gradual(Omap(A)),A) and Gradomap() Ugradomap() or something.
Using the function metana.pl
Now are we finally almost able to use the function Metana() provided in Csgrouper. Here’s an extracted version of this function together with the reproduction of a howto on its use: