Dvořák: Symphony No. 9 in E minor, Op. 95, B. 178

This example demonstrates a model of the oboe theme from Antonin Dvořák’s Symphony No. 9 in E minor, Op. 95, B. 178, the part of which is shown below:

A possible context tree representation of this model is:

However, this model contains redundant subtrees. Note that the first and the third measure are exactly identical, corresponding to the first and fourth subtree under the scale node in the tree model. This redundant defintion can be replaced by extracting the corresponding identical subtrees to a so called fragment, which is a referencable named subtree. After the optimization, the model looks like this:

The language representation of this model is:

composer "Antonin Dvořák"
title "Symphony No. 9 in E minor, Op. 95, 2nd Mvmt. Theme"

composition
{
    tempo 50, instrument englishHorn
    {
        key Db
        {
            scale majorPentatonic
            {
                fragmentRef myFragment
                
                rhythm 8. 16
                {
                    pitches 1 2
                    pitches 3 2
                }
                rhythm 2, pitches 1
                
                fragmentRef myFragment
                
                rhythm 8 8 8. 16 2, pitches 1 2 1 0 0
            }
        }
    }
}

fragment myFragment
{
    rhythm 8. 16 4
    {
        pitches 2 3 3
        pitches 2 1 0
    }
}

The source code and the corresponding representations shown in this example are also available in the github example repository.