Through an example, we will describe here how to extend the similarity finder system to be able to find a new kind of similarities. We would like to extend the system to be able to find sequences of notes which are retrograde of each other. A sequence and its retrograde are reverses of each other - for example C D E and E D C.
What we need to do is to
SimLibExample.java
.The SeqViewComparator (which we call
diatonicRetrogradeIntervalDiffCount) must implement a function seqCompare(SeqSimStmt)
which
is responsible for evaluating the subgraphs of the SimilarityStatement
according to the desired view and return a ViewDifference as result.
This function in our case has to examine the diatonic jumps between the
notes in the sequences. The jumps must be compared so that the first
jump in the first subgraph is compared to the negated last jump in the
other subgraph. The next jump in the first subgraph must be compared to
the negated next-to-last jump in the other subgraph and so forth. If all
these are equal (where one of them is negated), the sequences are
reverces of each other. So the seqCompare function compares the
diatonic jumps in this way, and since it is ViewComparator is of kind
DifferenceCount, it counts the mismatches. When seqCompare returns 0 the
sequences are reverses of each other.
We also have to take care of what to do with compound vertices. This
is done as with the other ViewComparators implemented - a jump from a
SimpleVertex to a CompoundVertex is the jump from the simple to
the first note in the compound. Most of the code is concerned comparing
and ensuring that the vertex types are alike in the sequences, and that
compound vertices have the same nonterminal number. This part we have
copied from another viewComparator.
The SeqSimMeasure (which we have called
seqDiatonicRetrogradeInterval) is responsible for deciding what to do
with the ViewDfference returned from the view comparator. The sequential
similarity measure has a vector of viewcomparators evaluations. It is
thus possible to combine results from more than one viewcomparators. In
our example, two ViewComparators are added to the vector: our
diatonicRetrogradeIntervalDiffCount and a absLengthDiffCount. The
SeqSimMeasure must implement a function evaluateSeq(SeqSimStmt)
which is responsible for combining the values. Also the size of
the graphs are given impact here in computing the final value.
Two testprograms are ready to run with the new similarity measure. StartSimFinderExample.java
runs a single run with the SimFinder and StartSimSegmenterExample.java
runs a SimSegmenter. When SimSegmenting, it is maybe not a good idea to
search for occurrences with the retrograde similarity measure, since
the retrograde of the retrograde is the original sequence, and this is
perhaps not the way we want to find that similarity. The other
similarity measures described in the thesis can be found in the files
SimLib.java
SimLibDiffCount.java
SimLibMeanDiff.java
SimLibVertex.java
SimLibEdge.java
We recommend to try the testprograms on the Bach Invention 1 in which it is possible
to find retrograde sequences of length over 20.