pitchtools.get_pitch — Abjad v1.1.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »

# pitchtools.get_pitch

`abjad.tools.pitchtools.` `get_pitch`(pitch_carrier)

  Get Abjad `Pitch` from Abjad `Pitch`, `Note`, `NoteHead` or `Chord` instance.

      abjad> pitch = Pitch('df', 5)
      abjad> pitch
      Pitch(df, 5)
      abjad> pitchtools.get_pitch(pitch)
      Pitch(df, 5)

      abjad> note = Note(('df', 5), (1, 4))
      abjad> note
      Note(df'', 4)
      abjad> pitchtools.get_pitch(note)
      Pitch(df, 5)

      abjad> note = Note(('df', 5), (1, 4))
      abjad> note.notehead
      NoteHead(df'')
      abjad> pitchtools.get_pitch(note.notehead)
      Pitch(df, 5)

      abjad> chord = Chord([('df', 5)], (1, 4))
      abjad> chord
      Chord(df'', 4)
      abjad> pitchtools.get_pitch(chord)
      Pitch(df, 5)

  Raise `MissingPitchError` when pitch_carrier carries no `Pitch`.

      abjad> note = Note(('df', 5), (1, 4))
      abjad> note.pitch = None
      abjad> note
      Note(None, 4)
      abjad> pitchtools.get_pitch(note)
      MissingPitchError

      abjad> note = Note(('df', 5), (1, 4))
      abjad> note.pitch = None
      abjad> note.notehead
      NoteHead( )
      abjad> pitchtools.get_pitch(note.notehead)
      MissingPitchError

      abjad> chord = Chord([('df', 5)], (1, 4))
      abjad> chord.pitches = [ ]
      abjad> chord
      Chord(, 4)
      abjad> pitchtools.get_pitch(chord)
      MissingPitchError

  Raise `ExtraPitchError` when `Chord` carries more than one pitch.

      abjad> chord = Chord([12, 14, 23], (1, 4))
      abjad> chord
      Chord(c'' d'' b'', 4)
      abjad> pitchtools.get_pitch(chord)
      ExtraPitchError

  Note

  ‘Defective’ `Note` and `NoteHead` instances with no `Pitch` are allowed in the current implementation of Abjad but may deprecate in a future implementation.

  Raise `TypeError` when pitch_carrier is not a valid pitch carrier.

      abjad> staff = Staff([ ])
      abjad> staff
      Staff{ }
      abjad> pitchtools.get_pitch(staff)
      TypeError

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »