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

.. note::  Explore the `abjad/demos/ferneyhough/` directory for the complete code to this example,
    or import it into your Python session directly with:

    * `from abjad.demos import ferneyhough`

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
</abjad>

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

Then we define a helper function:

<abjad>[strip_prompt=true]
def divide_tuplet(tuplet, n):
    last_tie_chain = tietools.get_tie_chain(tuplet[-1])
    proportions = n * [1]
    tietools.tie_chain_to_tuplet_with_ratio(last_tie_chain, proportions)
</abjad>

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 = []
for proportion in proportions:
    tuplets = []
    for n in range(1, 6 + 1):
        tuplet = tuplettools.make_tuplet_from_duration_and_ratio(duration, proportion)
        divide_tuplet(tuplet, n)
        tuplets.append(tuplet)
    music.extend(tuplets)
</abjad>

The score
---------

We make the score:

<abjad>
staff = stafftools.RhythmicStaff(music)
time_signature = contexttools.TimeSignatureMark((1, 4))(staff)
score = Score([staff])
</abjad>

And then configure it:

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


The LilyPond file
-----------------

Finally we insert the score into a LilyPond file:

<abjad>
lilypond_file = lilypondfiletools.make_basic_lilypond_file(score)
</abjad>

And then configure it:

<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>

Which looks like this:

<abjad>
show(lilypond_file)
</abjad>
