Ferneyhough: *Unsichtbare Farben*
=================================

Mikhïal Malt analyzes the rhythmic materials of Ferneyhough's `Unsichtbare Farben` in
`The OM Composer's Book 2`.

Malt explains that Ferneyhough used OpenMusic to create an "exhaustive catalogue
of rhythmic cells" such that:

    1. They are subdivided into two pulses, with proportions from ``1/1`` to ``1/11``.

    2. The second pulse is subdivided successively by ``1``, ``2``, ``3``, ``4``, ``5`` and ``6``.

Let's recreate Malt's results in Abjad.

The proportions
---------------

First we define proportions:

<abjad>
proportions = [(1, n) for n in range(1, 11 + 1)]
</abjad>

<abjad>
proportions
print repr(proportions) <hide
</abjad>

The transforms
--------------

Then we make aliases to give shorter names to two functions with long names:

<abjad>
make_tuplet = tuplettools.make_diminished_tuplet_from_duration_and_proportions_and_encourage_dots
tie_chain_to_tuplet = tietools.tie_chain_to_diminished_tuplet_with_proportions_and_encourage_dots
</abjad>

And then define a helper function:

<abjad>
def divide_tuplet(tuplet, n): <hide
    last_tie_chain = tietools.get_tie_chain(tuplet[-1]) <hide
    proportions = n * [1] <hide
    new = tie_chain_to_tuplet(last_tie_chain, proportions) <hide
    return new <hide
</abjad>

::

    def divide_tuplet(tuplet, n):
        last_tie_chain = tietools.get_tie_chain(tuplet[-1])
        proportions = n * [1]
        new = tie_chain_to_tuplet(last_tie_chain, proportions)
        return new

The rhythms
-----------

We set the duration of each tuplet equal to a quarter note:

<abjad>
duration = Fraction(1, 4)
</abjad>

And then we make the rhythms:

<abjad>
music = [] <hide
for proportion in proportions: <hide
    tuplets = [] <hide
    for n in range(1, 6 + 1): <hide
        tuplet = make_tuplet(duration, proportion) <hide
        divide_tuplet(tuplet, n) <hide
        tuplets.append(tuplet) <hide
    music.extend(tuplets) <hide
</abjad>

::

    music = []
    for proportion in proportions:
        tuplets = []
        for n in range(1, 6 + 1):
            tuplet = make_tuplet(duration, proportion)
            divide_tuplet(tuplet, n)
            tuplets.append(tuplet)
        music.extend(tuplets)

The score
---------

Finally we make the score:

<abjad>
staff = stafftools.RhythmicStaff(music)
score = Score([staff])
lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
</abjad>

Configure containers:

<abjad>
contexttools.TimeSignatureMark((1, 4))(staff)
score.override.bar_number.transparent = True
score.set.proportional_notation_duration = schemetools.SchemeMoment(1, 56)
score.set.tuplet_full_length = True
score.override.spacing_spanner.uniform_stretching = True
score.override.spacing_spanner.strict_note_spacing = True
score.override.tuplet_bracket.padding = 2
score.override.tuplet_bracket.staff_padding = 4
score.override.tuplet_number.text = schemetools.SchemeFunction('tuplet-number::calc-fraction-text')
score.override.time_signature.stencil = False
score.override.bar_line.stencil = False
</abjad>

Import layout tools:

<abjad>
from abjad.tools import layouttools
</abjad>

Configure the LilyPond file:

<abjad>
lilypond_file.default_paper_size = '11x17', 'portrait'
lilypond_file.global_staff_size = 12
lilypond_file.layout_block.indent = 0
lilypond_file.layout_block.ragged_right = True
lilypond_file.paper_block.ragged_bottom = True
lilypond_file.paper_block.system_system_spacing = layouttools.make_spacing_vector(0, 0, 8, 0)
</abjad>

And show the result:

<abjad>
show(lilypond_file)
iotools.write_expr_to_ly(lilypond_file, 'ferneyhough-1', print_status=False) <hide
</abjad>
