  We give a formal definition of the musical concept of voice leading in
mathematical terms, based on the idea of partial permutations of certain
ordered multisets. Then we associate a partial permutation matrix with a voice
leading in a unique way and write an algorithm to easily transform any musical
composition into a sequence of such matrices; we then generalise it in order to
include in the model also rhythmic independence and rests. From that we extract
a vector whose components return information about the movements of the voices
in the piece and hence about the complexity of the voice leading. We provide
some examples by analysing three compositions, also visualising complexity as a
point cloud for each piece. Finally, we interpret the sequence of complexity
vectors associated with each composition, thus considering the position of each
observation with respect to time. The Dynamic Time Warping allows us to compute
the distance between two pieces and to show that our approach distinguishes
well the examples that we took into account, exhibiting a strong indication
that the notion of complexity we propose is a good tool to identify and
classify musical pieces.
