Notes
=====

Making notes from a string
--------------------------

You can make notes from string:

<abjad>
note = Note("c'4")
</abjad>

<abjad>
show(note)
measure = measuretools.AnonymousMeasure([note]) <hide
iotools.write_expr_to_ly(measure, 'notes-1', 'oedo.ly') <hide
</abjad>

Making notes from chromatic pitch number and duration
-----------------------------------------------------

You can also make notes from chromatic pitch number and duration:

<abjad>
note = Note(0, Duration(1, 4))
</abjad>

<abjad>
show(note)
measure = measuretools.AnonymousMeasure([note]) <hide
iotools.write_expr_to_ly(measure, 'notes-2', 'oedo.ly') <hide
</abjad>

(You even use ``Note("c'4")`` to create notes with numbers alone.)

Getting the written pitch of notes
----------------------------------

You can get the written pitch of notes:

<abjad>
note.written_pitch
print repr(note.written_pitch) <hide
</abjad>

Changing the written pitch of notes
-----------------------------------

And you can change the written pitch of notes:

<abjad>
note.written_pitch = "cs'"
iotools.write_expr_to_ly(measure, 'notes-3', 'oedo.ly') <hide
</abjad>

(You can use ``note.written_pitch = 1`` to change pitch with numbers, too.)

Getting the duration attributes of notes
----------------------------------------

Get the written duration of notes like this:

<abjad>
note.written_duration
print repr(note.written_duration) <hide
</abjad>

Which is usually the same as preprolated duration:

<abjad>
note.preprolated_duration
print repr(note.preprolated_duration) <hide
</abjad>

And prolated duration:

<abjad>
note.prolated_duration
print repr(note.prolated_duration) <hide
</abjad>

Except for notes inside a tuplet:

<abjad>
tuplet = Tuplet(Fraction(2, 3), [Note("c'4"), Note("d'4"), Note("e'4")])
</abjad>

<abjad>
show(tuplet)
measure = measuretools.AnonymousMeasure([tuplet]) <hide
iotools.write_expr_to_ly(measure, 'notes-4', 'oedo.ly') <hide
</abjad>

<abjad>
note = tuplet[0]
</abjad>

Tupletted notes carry written duration:

<abjad>
note.written_duration
print repr(note.written_duration) <hide
</abjad>

Prolation:

<abjad>
note.prolation
print repr(note.prolation) <hide
</abjad>

And prolated duration that is the product of the two:

<abjad>
note.prolated_duration
print repr(note.prolated_duration) <hide
</abjad>

Changing the written duration of notes
--------------------------------------

You can change the written duration of notes:

<abjad>
tuplet[0].written_duration = Duration(1, 8)
tuplet[1].written_duration = Duration(1, 8)
tuplet[2].written_duration = Duration(1, 8)
spannertools.BeamSpanner(tuplet) <hide
</abjad>

<abjad>
show(tuplet)
iotools.write_expr_to_ly(measure, 'notes-5', 'oedo.ly') <hide
</abjad>

Other duration attributes are read-only.

Overriding notes
----------------

The notes below are black with fixed thickness and predetermined spacing:

<abjad>
staff = Staff("c'4 d'4 e'4 f'4 g'4 a'4 g'2")
slur_1 = spannertools.SlurSpanner(staff[:2])
slur_2 = spannertools.SlurSpanner(staff[2:4])
slur_3 = spannertools.SlurSpanner(staff[4:6])
</abjad>

<abjad>
f(staff)
</abjad>

<abjad>
show(staff)
iotools.write_expr_to_ly(staff, 'notes-6') <hide
</abjad>

But you can override LilyPond grobs to change the look of notes, rests and chords:

<abjad>
staff[-1].override.note_head.color = 'red'
staff[-1].override.stem.color = 'red'
</abjad>

<abjad>
f(staff)
</abjad>

<abjad>
show(staff)
iotools.write_expr_to_ly(staff, 'notes-7') <hide
</abjad>

Removing note overrides
-----------------------

Delete grob overrides you no longer want:

<abjad>
del(staff[-1].override.stem)
</abjad>

<abjad>
f(staff)
</abjad>

<abjad>
show(staff)
iotools.write_expr_to_ly(staff, 'notes-8') <hide
</abjad>
