def _transpose_pitch_carrier_by_numbered_interval(pitch_carrier, numbered_interval): mci = pitchtools.NumberedInterval(numbered_interval) if isinstance(pitch_carrier, pitchtools.Pitch): number = pitch_carrier.pitch_number + mci.semitones return type(pitch_carrier)(number) elif isinstance(pitch_carrier, numbers.Number): pitch_carrier = pitchtools.NumberedPitch(pitch_carrier) result = _transpose_pitch_carrier_by_numbered_interval( pitch_carrier, mci) return result.pitch_number 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
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_pitch is None and self.stop_pitch is None: return True elif self.start_pitch is None: if self.stop_pitch_is_included_in_range: return pitch <= self.stop_pitch else: return pitch < self.stop_pitch elif self.stop_pitch 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 else: return self.start_pitch <= pitch < self.stop_pitch else: if self.stop_pitch_is_included_in_range: return self.start_pitch < pitch <= self.stop_pitch else: return self.start_pitch < pitch < self.stop_pitch
def __init__( self, minimum_duration=None, maximum_duration=None, minimum_written_pitch=None, maximum_written_pitch=None, ): if minimum_duration is None: self._minimum_duration = minimum_duration else: self._minimum_duration = durationtools.Duration(minimum_duration) if maximum_duration is None: self._maximum_duration = maximum_duration else: self._maximum_duration = durationtools.Duration(maximum_duration) if minimum_written_pitch is None: self._minimum_written_pitch = minimum_written_pitch else: self._minimum_written_pitch = \ pitchtools.NamedPitch(minimum_written_pitch) if maximum_written_pitch is None: self._maximum_written_pitch = maximum_written_pitch else: self._maximum_written_pitch = \ pitchtools.NamedPitch(maximum_written_pitch)
def voice_scale_degrees_in_open_position(self, scale_degrees): r'''Voice `scale_degrees` in open position: :: >>> scale = tonalanalysistools.Scale('c', 'major') >>> scale_degrees = [1, 3, ('flat', 5), 7, ('sharp', 9)] >>> pitches = scale.voice_scale_degrees_in_open_position( ... scale_degrees) >>> pitches PitchSegment(["c'", "e'", "gf'", "b'", "ds''"]) Return pitch segment. ''' from abjad.tools import pitchtools from abjad.tools import tonalanalysistools scale_degrees = [ tonalanalysistools.ScaleDegree(x) for x in scale_degrees ] pitch_classes = [ self.scale_degree_to_named_pitch_class(x) for x in scale_degrees ] pitches = [pitchtools.NamedPitch(pitch_classes[0])] for pitch_class in pitch_classes[1:]: pitch = pitchtools.NamedPitch(pitch_class) while pitch < pitches[-1]: pitch += 12 pitches.append(pitch) pitches = pitchtools.PitchSegment(pitches) return pitches
def __mul__(self, argument): r'''Multiplies named interval by `argument`. .. container:: example >>> 3 * abjad.NamedInterval('+M9') NamedInterval('+aug25') Returns new named interval. ''' from abjad.tools import pitchtools if not isinstance(argument, int): message = 'must be integer: {!r}.' message = message.format(argument) raise TypeError(message) dummy_pitch = pitchtools.NamedPitch(0) for i in range(abs(argument)): dummy_pitch += self result = NamedInterval.from_pitch_carriers( pitchtools.NamedPitch(0), dummy_pitch, ) if argument < 0: return -result return result
def execute_against_score(self, score): r'''Execute pitch set expression against `score`. ''' statal_server_cursor = self.source_expression.payload leaves = list(self._iterate_selected_leaves_in_score(score)) assert all( isinstance(leaf, (scoretools.Note, scoretools.Chord)) for leaf in leaves) if self.level is None: level = -1 else: level = self.level if self.node_count is None: node_count = len(leaves) else: node_count = self.node_count pitch_numbers = \ statal_server_cursor(n=node_count, level=level) pitch_numbers = \ datastructuretools.CyclicTuple(pitch_numbers) for i, leaf in enumerate(leaves): #leaf.sounding_pitch = pitch_numbers[i] sounding_pitch = pitch_numbers[i] instrument = leaf._get_effective(instrumenttools.Instrument) if instrument: reference_pitch = instrument.sounding_pitch_of_written_middle_c else: reference_pitch = pitchtools.NamedPitch('C4') t_n = reference_pitch - pitchtools.NamedPitch('C4') written_pitch = pitchtools.transpose_pitch_carrier_by_interval( sounding_pitch, t_n) leaf.written_pitch = written_pitch assert inspect_(leaf).get_sounding_pitch() == sounding_pitch
def invert(self, axis=None): r'''Inverts named pitch-class. Not yet implemented. ''' from abjad.tools import pitchtools axis = axis or pitchtools.NamedPitch('c') axis = pitchtools.NamedPitch(axis) this = pitchtools.NamedPitch(self) interval = this - axis result = axis.transpose(interval) result = type(self)(result) return result
def _divide(self, pitch=None): from abjad.tools import scoretools from abjad.tools import markuptools from abjad.tools import pitchtools pitch = pitch or pitchtools.NamedPitch('b', 3) pitch = pitchtools.NamedPitch(pitch) treble = copy.copy(self) bass = copy.copy(self) detach(markuptools.Markup, treble) detach(markuptools.Markup, bass) if isinstance(treble, scoretools.Note): if treble.written_pitch < pitch: treble = scoretools.Rest(treble) elif isinstance(treble, scoretools.Rest): pass elif isinstance(treble, scoretools.Chord): for note_head in reversed(treble.note_heads): if note_head.written_pitch < pitch: treble.note_heads.remove(note_head) else: raise TypeError if isinstance(bass, scoretools.Note): if pitch <= bass.written_pitch: bass = scoretools.Rest(bass) elif isinstance(bass, scoretools.Rest): pass elif isinstance(bass, scoretools.Chord): for note_head in reversed(bass.note_heads): if pitch <= note_head.written_pitch: bass.note_heads.remove(note_head) else: raise TypeError treble = self._cast_defective_chord(treble) bass = self._cast_defective_chord(bass) up_markup = self._get_markup(direction=Up) up_markup = [copy.copy(markup) for markup in up_markup] down_markup = self._get_markup(direction=Down) down_markup = [copy.copy(markup) for markup in down_markup] for markup in up_markup: markup(treble) for markup in down_markup: markup(bass) return treble, bass
def _get_sounding_pitch(self): from abjad.tools import instrumenttools from abjad.tools import pitchtools if self._has_effective_indicator(indicatortools.IsAtSoundingPitch): return self.written_pitch else: instrument = self._get_effective(instrumenttools.Instrument) if instrument: sounding_pitch = instrument.sounding_pitch_of_written_middle_c else: sounding_pitch = pitchtools.NamedPitch('C4') t_n = pitchtools.NamedPitch('C4') - sounding_pitch sounding_pitch = pitchtools.transpose_pitch_carrier_by_interval( self.written_pitch, t_n) return sounding_pitch
def is_equivalent_under_transposition(self, expr): r'''True if equivalent under transposition to `expr`. Otherwise False. Returns true or false. ''' from abjad.tools import pitchtools if not isinstance(expr, type(self)): return False if not len(self) == len(expr): return False difference = -(pitchtools.NamedPitch(expr[0], 4) - pitchtools.NamedPitch(self[0], 4)) new_pitch_classes = (x + difference for x in self) new_pitch_classes = new(self, items=new_pitch_classes) return expr == new_pitch_classes
def __illustrate__(self): r'''Illustrates pitch segment. :: >>> named_pitch_segment = pitchtools.PitchSegment( ... ['bf,', 'aqs', "fs'", "g'", 'bqf', "g'"], ... item_class=NamedPitch, ... ) >>> show(named_pitch_segment) # doctest: +SKIP Returns LilyPond file. ''' from abjad.tools import durationtools from abjad.tools import lilypondfiletools from abjad.tools import markuptools from abjad.tools import pitchtools from abjad.tools import scoretools from abjad.tools.topleveltools import attach from abjad.tools.topleveltools import iterate from abjad.tools.topleveltools import override named_pitches = [pitchtools.NamedPitch(x) for x in self] notes = scoretools.make_notes(named_pitches, [1]) score, treble_staff, bass_staff = \ scoretools.make_piano_sketch_score_from_leaves(notes) for leaf in iterate(score).by_class(scoretools.Leaf): attach(durationtools.Multiplier(1, 8), leaf) override(score).rest.transparent = True lilypond_file = lilypondfiletools.make_basic_lilypond_file(score) lilypond_file.header_block.tagline = markuptools.Markup('""') return lilypond_file
def is_equivalent_under_transposition(self, expr): r'''True if pitch segment is equivalent to `expr` under transposition. Otherwise false. Returns boolean. ''' from abjad.tools import pitchtools if not isinstance(expr, type(self)): return False if not len(self) == len(expr): return False difference = -(pitchtools.NamedPitch(expr[0], 4) - pitchtools.NamedPitch(self[0], 4)) new_pitches = (x + difference for x in self) new_pitches = new(self, items=new_pitch) return expr == new_pitches
def _get_sounding_pitches(self): from abjad.tools import instrumenttools from abjad.tools import pitchtools if 'sounding pitch' in inspect(self).get_indicators(str): return self.written_pitches else: instrument = self._get_effective(instrumenttools.Instrument) if instrument: sounding_pitch = instrument.middle_c_sounding_pitch else: sounding_pitch = pitchtools.NamedPitch('C4') interval = pitchtools.NamedPitch('C4') - sounding_pitch sounding_pitches = [ interval.transpose(pitch) for pitch in self.written_pitches ] return tuple(sounding_pitches)
def transpose_named_pitch_by_numbered_interval_and_respell( pitch, staff_spaces, numbered_interval): '''Transpose named pitch by `numbered_interval` and respell `staff_spaces` above or below: :: >>> pitch = NamedPitch(0) :: >>> pitchtools.transpose_named_pitch_by_numbered_interval_and_respell( ... pitch, 1, 0.5) NamedPitch("dtqf'") Returns new named pitch. ''' from abjad.tools import pitchtools pitch_number = pitch.pitch_number + numbered_interval diatonic_pitch_class_number = (pitch.diatonic_pitch_class_number + staff_spaces) % 7 diatonic_pitch_class_name = \ pitchtools.PitchClass._diatonic_pitch_class_number_to_diatonic_pitch_class_name[ diatonic_pitch_class_number] return pitchtools.NamedPitch(pitch_number, diatonic_pitch_class_name)
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
def transpose_from_written_pitch_to_sounding_pitch(expr): r'''Transpose notes and chords in `expr` from sounding pitch to written pitch: :: >>> staff = Staff("<c' e' g'>4 d'4 r4 e'4") >>> clarinet = instrumenttools.ClarinetInBFlat() >>> attach(clarinet, staff) >>> show(staff) # doctest: +SKIP .. doctest:: >>> print(format(staff)) \new Staff { \set Staff.instrumentName = \markup { Clarinet in B-flat } \set Staff.shortInstrumentName = \markup { Cl. in B-flat } <c' e' g'>4 d'4 r4 e'4 } :: >>> instrumenttools.transpose_from_written_pitch_to_sounding_pitch(staff) >>> show(staff) # doctest: +SKIP .. doctest:: >>> print(format(staff)) \new Staff { \set Staff.instrumentName = \markup { Clarinet in B-flat } \set Staff.shortInstrumentName = \markup { Cl. in B-flat } <bf d' f'>4 c'4 r4 d'4 } Returns none. ''' from abjad.tools import instrumenttools prototype = (scoretools.Note, scoretools.Chord) for note_or_chord in iterate(expr).by_class(prototype): instrument = note_or_chord._get_effective(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) 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
def make_windungen_score( bandwidth=3, compress_reflections=True, leaf_duration=durationtools.Duration(1, 16), length=32, pitches=('c', 'd', 'e'), staff_count=12, ): from experimental.demos.windungen.WindungenScoreTemplate import WindungenScoreTemplate bandwidth = int(bandwidth) compress_reflections = bool(compress_reflections) leaf_duration = durationtools.Duration(leaf_duration) length = int(length) pitches = [pitchtools.NamedPitch(x) for x in pitches] staff_count = int(staff_count) assert 0 < bandwidth assert 0 < leaf_duration assert 0 < length assert 0 < len(pitches) assert 0 < staff_count score_template = WindungenScoreTemplate(staff_count=staff_count) score = score_template() all_pitches = sequencetools.repeat_sequence_to_length(length) matrix = make_cyclic_matrix_for_rotation_by_bandwidth()
def __illustrate__(self): r'''Attempts to illustrate selection. Evaluates the storage format of the selection (to sever any references to the source score from which the selection was taken). Then tries to wrap the result in a staff; in the case that notes of only C4 are found then sets the staff context name to ``'RhythmicStaff'``. If this works then the staff is wrapped in a LilyPond file and the file is returned. If this doesn't work then the method raises an exception. The idea is that the illustration should work for simple selections of that represent an essentially contiguous snippet of a single voice of music. Returns LilyPond file. ''' from abjad.tools import lilypondfiletools from abjad.tools import markuptools from abjad.tools import pitchtools from abjad.tools import scoretools from abjad.tools.topleveltools import mutate music = mutate(self).copy() staff = scoretools.Staff(music) found_different_pitch = False for pitch in pitchtools.list_named_pitches_in_expr(staff): if pitch != pitchtools.NamedPitch("c'"): found_different_pitch = True break if not found_different_pitch: staff.context_name = 'RhythmicStaff' score = scoretools.Score([staff]) lilypond_file = lilypondfiletools.make_basic_lilypond_file(score) lilypond_file.header_block.tagline = markuptools.Markup('""') return lilypond_file
def voice_pitch_class(self, pitch_class): r"""Voices `pitch_class` in this pitch-range. :: >>> a_pitch_range = pitchtools.PitchRange('[C4, C6]') >>> a_pitch_range.voice_pitch_class('c') (NamedPitch("c'"), NamedPitch("c''"), NamedPitch("c'''")) :: >>> a_pitch_range.voice_pitch_class('b') (NamedPitch("b'"), NamedPitch("b''")) :: >>> a_pitch_range = pitchtools.PitchRange('[C4, A4)') >>> a_pitch_range.voice_pitch_class('b') () Returns tuple of zero or more named pitches. """ from abjad.tools import pitchtools named_pitch_class = pitchtools.NamedPitchClass(pitch_class) named_pitch = pitchtools.NamedPitch( named_pitch_class, self.start_pitch.octave_number, ) result = [] while named_pitch <= self.stop_pitch: if named_pitch in self: result.append(named_pitch) named_pitch += 12 return tuple(result)
def __init__( self, instrument_name=None, short_instrument_name=None, instrument_name_markup=None, short_instrument_name_markup=None, allowable_clefs=None, pitch_range=None, sounding_pitch_of_written_middle_c=None, ): from abjad.tools import scoretools self._do_not_format = False if instrument_name is not None: assert isinstance(instrument_name, str), repr(instrument_name) self._instrument_name = instrument_name prototype = markuptools.Markup if instrument_name_markup is not None: assert isinstance(instrument_name_markup, prototype) self._instrument_name_markup = instrument_name_markup if short_instrument_name is not None: assert isinstance(short_instrument_name, str) self._short_instrument_name = short_instrument_name if short_instrument_name_markup is not None: assert isinstance(short_instrument_name_markup, prototype) self._short_instrument_name_markup = short_instrument_name_markup allowable_clefs = allowable_clefs or ['treble'] allowable_clefs = indicatortools.ClefInventory(allowable_clefs) self._allowable_clefs = allowable_clefs if isinstance(pitch_range, str): pitch_range = pitchtools.PitchRange(pitch_range) elif isinstance(pitch_range, pitchtools.PitchRange): pitch_range = copy.copy(pitch_range) elif pitch_range is None: pitch_range = pitchtools.PitchRange() else: raise TypeError(pitch_range) self._pitch_range = pitch_range sounding_pitch_of_written_middle_c = \ sounding_pitch_of_written_middle_c or pitchtools.NamedPitch("c'") sounding_pitch_of_written_middle_c = \ pitchtools.NamedPitch(sounding_pitch_of_written_middle_c) self._sounding_pitch_of_written_middle_c = \ sounding_pitch_of_written_middle_c self._default_scope = scoretools.Staff self._is_primary_instrument = False self._performer_names = ['instrumentalist'] self._starting_clefs = copy.copy(allowable_clefs)
def named_pitch_class_to_scale_degree(self, *args): r'''Changes named pitch-class to scale degree. Returns scale degree. ''' from abjad.tools import tonalanalysistools foreign_pitch_class = pitchtools.NamedPitchClass(*args) letter = foreign_pitch_class.diatonic_pitch_class_name for i, pc in enumerate(self): if pc.diatonic_pitch_class_name == letter: native_pitch_class = pc scale_degree_index = i scale_degree_number = scale_degree_index + 1 break native_pitch = pitchtools.NamedPitch(native_pitch_class, 4) foreign_pitch = pitchtools.NamedPitch(foreign_pitch_class, 4) accidental = foreign_pitch.accidental - native_pitch.accidental return tonalanalysistools.ScaleDegree(accidental, scale_degree_number)
def transpose(self, pitch_carrier): r'''Transposes `pitch_carrier`. .. container:: example Transposes chord: >>> chord = abjad.Chord("<c' e' g'>4") >>> interval = abjad.NumberedInterval(1) >>> interval.transpose(chord) Chord("<cs' f' af'>4") Returns newly constructed object of `pitch_carrier` type. ''' from abjad.tools import pitchtools from abjad.tools import scoretools if isinstance(pitch_carrier, pitchtools.Pitch): number = pitch_carrier.number + self.semitones return type(pitch_carrier)(number) elif isinstance(pitch_carrier, numbers.Number): pitch_carrier = pitchtools.NumberedPitch(pitch_carrier) result = self.transpose(pitch_carrier) return result.number elif isinstance(pitch_carrier, scoretools.Note): new_note = copy.copy(pitch_carrier) number = pitchtools.NumberedPitch(pitch_carrier.written_pitch) number = number.number number += self.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).number number += self.number new_pitch = pitchtools.NamedPitch(number) new_nh.written_pitch = new_pitch return new_chord else: return pitch_carrier
def _clef_name_to_staff_position_zero(self, clef_name): from abjad.tools import pitchtools return { 'treble': pitchtools.NamedPitch('B4'), 'alto': pitchtools.NamedPitch('C4'), 'tenor': pitchtools.NamedPitch('A3'), 'bass': pitchtools.NamedPitch('D3'), 'french': pitchtools.NamedPitch('D5'), 'soprano': pitchtools.NamedPitch('G4'), 'mezzosoprano': pitchtools.NamedPitch('E4'), 'baritone': pitchtools.NamedPitch('F3'), 'varbaritone': pitchtools.NamedPitch('F3'), 'percussion': None, 'tab': None, }[clef_name]
def _transpose_pitch_by_named_interval(pitch, mdi): pitch_number = pitch.pitch_number + mdi.semitones diatonic_pitch_class_number = \ (pitch.diatonic_pitch_class_number + mdi.staff_spaces) % 7 diatonic_pitch_class_name = \ pitchtools.PitchClass._diatonic_pitch_class_number_to_diatonic_pitch_class_name[ diatonic_pitch_class_number] named_pitch = pitchtools.NamedPitch(pitch_number, diatonic_pitch_class_name) return type(pitch)(named_pitch)
def pitches(self, pitches): from abjad.tools import pitchtools if pitches is None: self._pitches = None return if isinstance(pitches, str): pitches = pitches.split() assert isinstance(pitches, (tuple, list)), repr(pitches) pitches = [pitchtools.NamedPitch(_) for _ in pitches] self._pitches = pitches
def append_pitch(self, pitch): r'''Appends `pitch` to cell. Returns none. ''' from abjad.tools import pitchtools if self.pitches is None: self._pitches = [] pitch = pitchtools.NamedPitch(pitch) self._pitches.append(pitch)
def __init__(self, offset=0, pitches=None, attachments=None, index=None): QEvent.__init__(self, offset=offset, index=index) pitches = pitches or [] pitches = tuple([pitchtools.NamedPitch(x) for x in pitches]) if attachments is None: attachments = () else: attachments = tuple(attachments) self._pitches = pitches self._attachments = attachments
def make_piano_score_from_leaves(leaves, lowest_treble_pitch=None): r"""Make piano score from `leaves`: :: >>> notes = [Note(x, (1, 4)) for x in [-12, 37, -10, 2, 4, 17]] >>> score, treble_staff, bass_staff = scoretools.make_piano_score_from_leaves(notes) .. doctest:: >>> print(format(score)) \new Score << \new PianoStaff << \context Staff = "treble" { \clef "treble" r4 cs''''4 r4 d'4 e'4 f''4 } \context Staff = "bass" { \clef "bass" c4 r4 d4 r4 r4 r4 } >> >> :: >>> show(score) # doctest: +SKIP When ``lowest_treble_pitch=None`` set to B3. Returns score, treble staff, bass staff. """ from abjad.tools import pitchtools from abjad.tools import scoretools if lowest_treble_pitch is None: lowest_treble_pitch = pitchtools.NamedPitch('b') score, treble_staff, bass_staff = scoretools.make_empty_piano_score() for leaf in leaves: treble_chord, bass_chord = leaf._divide(lowest_treble_pitch) treble_staff.append(treble_chord) bass_staff.append(bass_chord) return score, treble_staff, bass_staff
def from_pitches( start_pitch, stop_pitch, start_pitch_is_included_in_range=True, stop_pitch_is_included_in_range=True, ): r'''Initializes pitch range from numbers. .. container:: example :: >>> pitchtools.PitchRange.from_pitches(-18, 19) PitchRange(range_string='[F#2, G5]') Returns pitch range. ''' from abjad.tools import pitchtools if start_pitch is None: start_pitch_string = '-inf' else: start_pitch_string = str(pitchtools.NamedPitch(start_pitch)) if stop_pitch is None: stop_pitch_string = '+inf' else: stop_pitch_string = str(pitchtools.NamedPitch(stop_pitch)) start_containment = '[' if not start_pitch_is_included_in_range: start_containment = '(' stop_containment = ']' if not stop_pitch_is_included_in_range: stop_containment = ')' string = '{}{}, {}{}' string = string.format( start_containment, start_pitch_string, stop_pitch_string, stop_containment, ) pitch_range = PitchRange(string) return pitch_range
def written_pitch(self, arg): from abjad.tools import pitchtools from abjad.tools.scoretools.NoteHead import NoteHead if arg is None: if self.note_head is not None: self.note_head.written_pitch = None else: if self.note_head is None: self.note_head = NoteHead(self, written_pitch=None) else: pitch = pitchtools.NamedPitch(arg) self.note_head.written_pitch = pitch