How to use the abjad.tools.pitchtools.NamedPitch function in abjad

To help you get started, we’ve selected a few abjad examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Abjad / abjad / abjad / tools / pitchtools / instantiate_pitch_and_interval_test_collection.py View on Github external
NumberedPitchClass(1)

    Use to test pitch and interval interface consistency.

    Returns list.
    '''
    from abjad.tools import pitchtools

    result = []
    result.append(pitchtools.NumberedInversionEquivalentIntervalClass(1))
    result.append(pitchtools.NamedInversionEquivalentIntervalClass('M2'))
    result.append(pitchtools.NumberedInterval(1))
    result.append(pitchtools.NumberedIntervalClass(1))
    result.append(pitchtools.NamedInterval('M2'))
    result.append(pitchtools.NamedIntervalClass('M2'))
    result.append(pitchtools.NamedPitch('c'))
    result.append(pitchtools.NamedPitchClass('c'))
    result.append(pitchtools.NumberedPitch(1))
    result.append(pitchtools.NumberedPitchClass(1))
    return result
github Abjad / abjad / trunk / abjad / tools / pitchtools / PitchRange.py View on Github external
def _contains_pitch(self, pitch):
        from abjad.tools import pitchtools
        if isinstance(pitch, numbers.Number):
            pitch = pitchtools.NamedPitch(pitch)
        elif isinstance(pitch, str):
            pitch = pitchtools.NamedPitch(pitch)
        if self._start is None and self._stop is None:
            return True
        elif self._start is None:
            if self.stop_pitch_is_included_in_range:
                return pitch <= self.stop_pitch
            else:
                return pitch < self.stop_pitch
        elif self._stop is None:
            if self.start_pitch_is_included_in_range:
                return self.start_pitch <= pitch
            else:
                return self.start_pitch < pitch
        else:
            if self.start_pitch_is_included_in_range:
                if self.stop_pitch_is_included_in_range:
                    return self.start_pitch <= pitch <= self.stop_pitch
github Abjad / abjad / abjad / tools / pitchtools / PitchArrayCell.py View on Github external
def _parse_pitch_token(self, pitch_token):
        from abjad.tools import pitchtools
        pitches = []
        if isinstance(pitch_token, (int, float, pitchtools.NamedPitch)):
            pitch = pitchtools.NamedPitch(pitch_token)
            pitches.append(pitch)
        elif isinstance(pitch_token, tuple):
            pitches.append(pitchtools.NamedPitch(*pitch_token))
        elif isinstance(pitch_token, list):
            for element in pitch_token:
                pitch = pitchtools.NamedPitch(element)
                pitches.append(pitch)
        else:
            message = 'pitch item must be number, pitch or list.'
            raise TypeError(message)
        return pitches
github Abjad / abjad / trunk / abjad / tools / instrumenttools / ContrabassSaxophone.py View on Github external
def __init__(self, **kwargs):
        Instrument.__init__(self, **kwargs)
        self._default_instrument_name = 'contrabass saxophone'
        self._default_performer_names.extend([
            'wind player',
            'reed player',
            'single reed player',
            'saxophonist',
            ])
        self._default_short_instrument_name = 'cbass. sax.'
        self._is_primary_instrument = False
        self.sounding_pitch_of_written_middle_c = \
            pitchtools.NamedPitch('ef,,')
        self._starting_clefs = [marktools.ClefMark('treble')]
        self._copy_default_starting_clefs_to_default_allowable_clefs()
        self._default_pitch_range = pitchtools.PitchRange(-36, -4)
github josiah-wolf-oberholtzer / consort / consort / tools / HarmonicField.py View on Github external
consort.tools.HarmonicFieldEntry(
                        leading_pitches=("cs'", "d'"),
                        structural_pitch=pitchtools.NamedPitch("e'"),
                        tailing_pitches=("d'",),
                        ),
                    )
                )

        Returns new harmonic field.
        '''
        from abjad.tools import pitchtools
        matching_entries, nonmatching_entries = self._find_matching_entries(
            structural_pitch_class_subset=structural_pitch_class_subset,
            structural_pitch_range=structural_pitch_range,
            )
        axis = axis or pitchtools.NamedPitch("c'")
        altered_entries = []
        for entry in matching_entries:
            altered_entry = entry.invert(axis=axis)
            altered_entries.append(altered_entry)
        all_entries = nonmatching_entries + altered_entries
        return type(self)(all_entries)
github Abjad / abjad / abjad / tools / pitchtools / transpose_pitch_carrier_by_interval.py View on Github external
elif isinstance(pitch_carrier, scoretools.Note):
            new_note = copy.copy(pitch_carrier)
            number = pitchtools.NumberedPitch(
                pitch_carrier.written_pitch).pitch_number
            number += mci.number
            new_pitch = pitchtools.NamedPitch(number)
            new_note.written_pitch = new_pitch
            return new_note
        elif isinstance(pitch_carrier, scoretools.Chord):
            new_chord = copy.copy(pitch_carrier)
            pairs = zip(new_chord.note_heads, pitch_carrier.note_heads)
            for new_nh, old_nh in pairs:
                number = \
                    pitchtools.NumberedPitch(old_nh.written_pitch).pitch_number
                number += mci.number
                new_pitch = pitchtools.NamedPitch(number)
                new_nh.written_pitch = new_pitch
            return new_chord
        else:
            return pitch_carrier
github Abjad / abjad / trunk / abjad / tools / instrumenttools / transpose_from_written_pitch_to_sounding_pitch.py View on Github external
d'4
        }

    Returns none.
    '''
    from abjad.tools import instrumenttools

    for note_or_chord in iterationtools.iterate_notes_and_chords_in_expr(expr):
        if note_or_chord.written_pitch_indication_is_at_sounding_pitch:
            continue
        instrument = note_or_chord._get_effective_context_mark(
            instrumenttools.Instrument)
        if not instrument:
            continue
        sounding_pitch = instrument.sounding_pitch_of_written_middle_c
        t_n = pitchtools.NamedPitch('C4') - sounding_pitch
        if isinstance(note_or_chord, scoretools.Note):
            note_or_chord.written_pitch = pitchtools.transpose_pitch_carrier_by_interval(
                note_or_chord.written_pitch, t_n)
            note_or_chord.written_pitch_indication_is_at_sounding_pitch = True
        elif isinstance(note_or_chord, scoretools.Chord):
            pitches = [pitchtools.transpose_pitch_carrier_by_interval(pitch, t_n)
                for pitch in note_or_chord.written_pitches]
            note_or_chord.written_pitches = pitches
            note_or_chord.written_pitch_indication_is_at_sounding_pitch = True
github Abjad / abjad / trunk / abjad / tools / lilypondparsertools / LilyPondParser.py View on Github external
            'ly:pitch?':          lambda x: isinstance(x, pitchtools.NamedPitch),
            'markup?':            lambda x: isinstance(x, markuptools.MarkupCommand),
github Abjad / abjad / trunk / abjad / tools / instrumenttools / Marimba.py View on Github external
def __init__(self, **kwargs):
        Instrument.__init__(self, **kwargs)
        self._default_instrument_name = 'marimba'
        self._default_performer_names.extend([
            'percussionist',
            ])
        self._default_short_instrument_name = 'mb.'
        self._is_primary_instrument = False
        self.sounding_pitch_of_written_middle_c = \
            pitchtools.NamedPitch("c'")
        self._starting_clefs = [
            marktools.ClefMark('treble'), marktools.ClefMark('bass')]
        self._copy_default_starting_clefs_to_default_allowable_clefs()
        self._default_pitch_range = pitchtools.PitchRange(-19, 36)
github Abjad / abjad / trunk / abjad / tools / instrumenttools / Contrabassoon.py View on Github external
def __init__(self, **kwargs):
        Instrument.__init__(self, **kwargs)
        self._default_instrument_name = 'contrabassoon'
        self._default_performer_names.extend([
            'wind player',
            'reed player',
            'double reed player',
            'bassoonist',
            ])
        self._default_short_instrument_name = 'contrabsn.'
        self._is_primary_instrument = False
        self.sounding_pitch_of_written_middle_c = \
            pitchtools.NamedPitch('c')
        self._starting_clefs = [marktools.ClefMark('bass')]
        self._copy_default_starting_clefs_to_default_allowable_clefs()
        self._default_pitch_range = pitchtools.PitchRange(-38, -2)