16. Scores

16.1. Creating scores

Create a score like this:

abjad> treble_staff_1 = Staff("e'4 d'4 e'4 f'4 g'1")
abjad> treble_staff_2 = Staff("c'2. b8 a8 b1")
abjad> score = Score([treble_staff_1, treble_staff_2])
abjad> show(score)
../../../_images/scores-1.png

16.2. Inspecting score music

Return score components with music:

abjad> score.music
(Staff{5}, Staff{4})

16.3. Inspecting score length

Get score length with len():

abjad> len(score)
2

16.4. Inspecting score duration

Score contents duration is equal to the duration of the longest component in score:

abjad> score.contents_duration
Duration(2, 1)

16.5. Adding one component to the bottom of a score

Add one component to the bottom of a score with append:

abjad> bass_staff = Staff("g4 f4 e4 d4 d1")
abjad> contexttools.ClefMark('bass')(bass_staff)
abjad> score.append(bass_staff)
abjad> show(score)
../../../_images/scores-2.png

16.6. Finding the index of a score component

Find the index of a score component with index:

abjad> score.index(treble_staff_1)
0

16.7. Removing a score component by index

Use pop to remove a score component by index:

abjad> score.pop(1)
abjad> show(score)
../../../_images/scores-3.png

16.8. Removing a score component by reference

Remove a score component by reference with remove:

abjad> score.remove(treble_staff_1)
abjad> show(score)
../../../_images/scores-4.png

16.9. Testing score containment

Use in to find out whether a score contains a given component:

abjad> treble_staff_1 in score
False
abjad> treble_staff_2 in score
False
abjad> bass_staff in score
True

16.10. Naming scores

You can name Abjad scores:

abjad> score.name = 'Example Score'

Score names appear in LilyPond input:

abjad> f(score)
\context Score = "Example Score" <<
        \new Staff {
                \clef "bass"
                g4
                f4
                e4
                d4
                d1
        }
>>

But do not appear in notational output:

abjad> show(score)
../../../_images/scores-5.png