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 list_octave_transpositions(self, pitch_carrier): r"""Lists octave transpositions of `pitch_carrier` in pitch range. .. container:: example :: >>> chord = Chord("<c' d' e'>4") >>> pitch_range = pitchtools.PitchRange.from_pitches(0, 48) >>> result = pitch_range.list_octave_transpositions(chord) :: >>> for chord in result: ... chord ... Chord("<c' d' e'>4") Chord("<c'' d'' e''>4") Chord("<c''' d''' e'''>4") Chord("<c'''' d'''' e''''>4") Returns a list of `pitch_carrier` objects. """ from abjad.tools import pitchtools from abjad.tools import scoretools if isinstance(pitch_carrier, collections.Iterable): if all(isinstance(x, (int, float)) for x in pitch_carrier): return self._list_numeric_octave_transpositions(pitch_carrier) prototype = (scoretools.Chord, pitchtools.PitchSet) if not isinstance(pitch_carrier, prototype): message = 'must be chord or pitch-set: {!r}' message = message.format(pitch_carrier) raise TypeError(message) result = [] interval = pitchtools.NumberedInterval(-12) while True: pitch_carrier_copy = copy.copy(pitch_carrier) candidate = pitchtools.transpose_pitch_carrier_by_interval( pitch_carrier_copy, interval) if candidate in self: result.append(candidate) interval -= pitchtools.NumberedInterval(12) else: break result.reverse() interval = pitchtools.NumberedInterval(0) while True: pitch_carrier_copy = copy.copy(pitch_carrier) candidate = pitchtools.transpose_pitch_carrier_by_interval( pitch_carrier_copy, interval) if candidate in self: result.append(candidate) interval += pitchtools.NumberedInterval(12) else: break return result
def _transpose_pitch_carrier_into_pitch_range(pitch_carrier, pitch_range): from abjad.tools import pitchtools while pitch_carrier < pitch_range: pitch_carrier = pitchtools.transpose_pitch_carrier_by_interval(pitch_carrier, 12) while pitch_range < pitch_carrier: pitch_carrier = pitchtools.transpose_pitch_carrier_by_interval(pitch_carrier, -12) if pitch_carrier not in pitch_range: raise ValueError('can not transpose pitch carrier %s into pitch range.' % pitch_carrier) return pitch_carrier
def _transpose_pitch_carrier_into_pitch_range(pitch_carrier, pitch_range): from abjad.tools import pitchtools while pitch_carrier < pitch_range: pitch_carrier = pitchtools.transpose_pitch_carrier_by_interval(pitch_carrier, 12) while pitch_range < pitch_carrier: pitch_carrier = pitchtools.transpose_pitch_carrier_by_interval(pitch_carrier, -12) if pitch_carrier not in pitch_range: message = 'can not transpose pitch carrier {} into pitch range.' message = message.format(pitch_carrier) raise ValueError(message) return pitch_carrier
def _transpose_pitch_carrier_into_pitch_range(pitch_carrier, pitch_range): from abjad.tools import pitchtools while pitch_carrier < pitch_range: pitch_carrier = pitchtools.transpose_pitch_carrier_by_interval( pitch_carrier, 12) while pitch_range < pitch_carrier: pitch_carrier = pitchtools.transpose_pitch_carrier_by_interval( pitch_carrier, -12) if pitch_carrier not in pitch_range: message = 'can not transpose pitch carrier {!r} into pitch range.' message = message.format(pitch_carrier) raise ValueError(message) return pitch_carrier
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 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 __add__(self, named_interval): from abjad.tools import pitchtools dummy = pitchtools.NamedPitch( self.pitch_class_name, 4) mdi = named_interval new = pitchtools.transpose_pitch_carrier_by_interval( dummy, mdi) return type(self)(new)
def __sub__(self, arg): from abjad.tools import pitchtools if isinstance(arg, type(self)): return pitchtools.NamedInterval.from_pitch_carriers( self, arg) else: interval = arg return pitchtools.transpose_pitch_carrier_by_interval( self, -interval)
def transpose_from_written_pitch_to_sounding_pitch(self, note_or_chord): r'''Transposes `expr` from written pitch of instrument to sounding pitch of instrument. Returns `note_or_chord` with adjusted pitches. ''' from abjad.tools import scoretools sounding_pitch = self.sounding_pitch_of_written_middle_c index = 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, index) elif isinstance(note_or_chord, scoretools.Chord): pitches = [ pitchtools.transpose_pitch_carrier_by_interval(pitch, index) for pitch in note_or_chord.written_pitches ] note_or_chord.written_pitches = pitches
def __sub__(self, arg): r"""Subtracts `arg` from numbered pitch. Returns numbered interval. """ from abjad.tools import pitchtools if isinstance(arg, type(self)): return pitchtools.NumberedInterval.from_pitch_carriers(self, arg) else: interval = arg return pitchtools.transpose_pitch_carrier_by_interval(self, -interval)
def __sub__(self, arg): r'''Subtracts `arg` from numbered pitch. Returns numbered interval. ''' from abjad.tools import pitchtools if isinstance(arg, type(self)): return pitchtools.NumberedInterval.from_pitch_carriers(self, arg) else: interval = arg return pitchtools.transpose_pitch_carrier_by_interval( self, -interval)
def __add__(self, interval): r'''Adds named pitch to `interval`. :: >>> pitch + pitchtools.NamedInterval('+M2') NamedPitch("ds''") Returns new named pitch. ''' from abjad.tools import pitchtools interval = pitchtools.NamedInterval(interval) return pitchtools.transpose_pitch_carrier_by_interval( self, interval)
def sounding_pitches(self): r"""Sounding pitches in chord. .. container:: example **Example.** :: >>> staff = Staff("<c''' e'''>4 <d''' fs'''>4") >>> glockenspiel = instrumenttools.Glockenspiel() >>> glockenspiel = attach(glockenspiel, staff) >>> instrumenttools.transpose_from_sounding_pitch_to_written_pitch( ... staff) >>> show(staff) # doctest: +SKIP .. doctest:: >>> f(staff) \new Staff { \set Staff.instrumentName = \markup { Glockenspiel } \set Staff.shortInstrumentName = \markup { Gkspl. } <c' e'>4 <d' fs'>4 } :: >>> staff[0].sounding_pitches (NamedPitch("c'''"), NamedPitch("e'''")) Returns tuple. """ from abjad.tools import instrumenttools from abjad.tools import pitchtools if self.written_pitch_indication_is_at_sounding_pitch: return self.written_pitches else: instrument = self._get_effective_context_mark( instrumenttools.Instrument) if not instrument: message = 'effective instrument of note can not be determined.' raise InstrumentError(message) sounding_pitch = instrument.sounding_pitch_of_written_middle_c interval = pitchtools.NamedPitch('C4') - sounding_pitch sounding_pitches = [ pitchtools.transpose_pitch_carrier_by_interval( pitch, interval) for pitch in self.written_pitches] return tuple(sounding_pitches)
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 __add__(self, named_interval): r'''Adds `named_interval` to named pitch-class. :: >>> pitch_class + pitchtools.NamedInterval('+M9') NamedPitchClass('ds') Return new named pitch-class. ''' from abjad.tools import pitchtools dummy = pitchtools.NamedPitch(self.pitch_class_name, 4) mdi = named_interval new = pitchtools.transpose_pitch_carrier_by_interval(dummy, mdi) return type(self)(new)
def transpose_from_sounding_pitch_to_written_pitch(self, note_or_chord): r'''Transposes `note_or_chord` from sounding pitch of instrument to written pitch of instrument. Returns `note_or_chord` with adjusted pitches. ''' from abjad.tools import scoretools sounding_pitch = self.sounding_pitch_of_written_middle_c index = pitchtools.NamedPitch('C4') - sounding_pitch index *= -1 if isinstance(note_or_chord, scoretools.Note): note_or_chord.written_pitch = \ pitchtools.transpose_pitch_carrier_by_interval( note_or_chord.written_pitch, index) elif isinstance(note_or_chord, scoretools.Chord): pitches = [ pitchtools.transpose_pitch_carrier_by_interval(pitch, index) for pitch in note_or_chord.written_pitches ] note_or_chord.written_pitches = pitches else: message = 'must be note or chord: {!r}.' message = message.format(note_or_chord) raise TypeError(message)
def __add__(self, named_interval): r'''Adds `named_interval` to named pitch-class. :: >>> pitch_class + pitchtools.NamedInterval('+M9') NamedPitchClass('ds') Return new named pitch-class. ''' from abjad.tools import pitchtools dummy = pitchtools.NamedPitch( self.pitch_class_name, 4) mdi = named_interval new = pitchtools.transpose_pitch_carrier_by_interval( dummy, mdi) return type(self)(new)
def __sub__(self, arg): r'''Subtracts `arg` from named pitch. :: >>> NamedPitch("cs''") - NamedPitch("b'") NamedInterval('-M2') Returns named interval. ''' from abjad.tools import pitchtools if isinstance(arg, type(self)): return pitchtools.NamedInterval.from_pitch_carriers( self, arg) else: interval = arg return pitchtools.transpose_pitch_carrier_by_interval( self, -interval)
def transpose(self, expr): r'''Transposes named pitch-class by named interval `expr`. :: >>> named_interval = pitchtools.NamedInterval('major', 2) >>> pitchtools.NamedPitchClass('cs').transpose(named_interval) NamedPitchClass('ds') Returns new named pitch-class. ''' from abjad.tools import pitchtools named_interval = pitchtools.NamedInterval(expr) pitch = pitchtools.NamedPitch(self, 4) transposed_pitch = \ pitchtools.transpose_pitch_carrier_by_interval( pitch, named_interval) return type(self)(transposed_pitch)
def fset(self, arg): from abjad.tools import instrumenttools from abjad.tools import pitchtools pitch = pitchtools.NamedPitch(arg) if self.written_pitch_indication_is_at_sounding_pitch: self.written_pitch = pitch else: instrument = self._get_effective_context_mark( instrumenttools.Instrument) if not instrument: message = 'effective instrument of note' message += ' can not be determined.' raise InstrumentError(message) sounding_pitch = instrument.sounding_pitch_of_written_middle_c t_n = pitchtools.NamedPitch('C4') - sounding_pitch t_n *= -1 self.written_pitch = \ pitchtools.transpose_pitch_carrier_by_interval( pitch, t_n)
def transpose(self, n): r'''Transpose named pitch-class by `named_interval`: :: >>> pitchtools.NamedPitchClass('cs').transpose( ... pitchtools.NamedInterval('major', 2)) NamedPitchClass('ds') Emit new named pitch-class. ''' from abjad.tools import pitchtools named_interval = pitchtools.NamedInterval(n) pitch = pitchtools.NamedPitch(self, 4) transposed_pitch = \ pitchtools.transpose_pitch_carrier_by_interval( pitch, named_interval) return type(self)(transposed_pitch)
def transpose(self, expr): r'''Transposes named pitch by `expr`. :: >>> NamedPitch("c'").transpose('m2') NamedPitch("df'") :: >>> NamedPitch("c'").transpose('-M2') NamedPitch('bf') Returns new named pitch. ''' from abjad.tools import pitchtools named_interval = pitchtools.NamedInterval(expr) transposed_pitch = pitchtools.transpose_pitch_carrier_by_interval( self, named_interval) return type(self)(transposed_pitch)
def execute_against_score(self, score): r'''Execute aggregate set expression against `score`. ''' aggregate = self.source_expression.payload for leaf in self._iterate_selected_leaves_in_score(score): assert isinstance(leaf, scoretools.Note), repr(leaf) sounding_pitch = inspect_(leaf).get_sounding_pitch() sounding_pitches = \ pitchtools.register_pitch_class_numbers_by_pitch_number_aggregate( [sounding_pitch.pitch_number], aggregate) #leaf.sounding_pitch = sounding_pitches[0] 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') sounding_pitch = sounding_pitches[0] 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 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 transpose_from_sounding_pitch_to_written_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.BFlatClarinet() >>> attach(clarinet, staff) BFlatClarinet()(Staff{4}) .. doctest:: >>> f(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_sounding_pitch_to_written_pitch(staff) .. doctest:: >>> f(staff) \new Staff { \set Staff.instrumentName = \markup { Clarinet in B-flat } \set Staff.shortInstrumentName = \markup { Cl. in B-flat } <d' fs' a'>4 e'4 r4 fs'4 } Returns none. ''' from abjad.tools import instrumenttools for note_or_chord in iterationtools.iterate_notes_and_chords_in_expr(expr): if not 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 t_n *= -1 if isinstance(note_or_chord, notetools.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 = False 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 = False
def list_octave_transpositions_of_pitch_carrier_within_pitch_range(pitch_carrier, pitch_range): r"""List octave transpositions of `pitch_carrier` in `pitch_range`: :: >>> chord = Chord("<c' d' e'>4") >>> pitch_range = pitchtools.PitchRange(0, 48) :: >>> result = pitchtools.list_octave_transpositions_of_pitch_carrier_within_pitch_range( ... chord, pitch_range) :: >>> for chord in result: ... chord ... Chord("<c' d' e'>4") Chord("<c'' d'' e''>4") Chord("<c''' d''' e'''>4") Chord("<c'''' d'''' e''''>4") Returns list of newly created `pitch_carrier` objects. """ from abjad.tools import scoretools from abjad.tools import pitchtools if not isinstance(pitch_range, pitchtools.PitchRange): raise TypeError('must be pitch range.') if all(isinstance(x, (int, long, float)) for x in pitch_carrier): return _pitch_number_list_octave_transpositions(pitch_carrier, pitch_range) if not isinstance(pitch_carrier, (scoretools.Chord, pitchtools.PitchSet)): raise TypeError('must be chord or pitch set.') result = [] interval = pitchtools.NumberedInterval(-12) while True: pitch_carrier_copy = copy.copy(pitch_carrier) candidate = pitchtools.transpose_pitch_carrier_by_interval(pitch_carrier_copy, interval) if candidate in pitch_range: result.append(candidate) interval -= pitchtools.NumberedInterval(12) else: break result.reverse() interval = pitchtools.NumberedInterval(0) while True: pitch_carrier_copy = copy.copy(pitch_carrier) candidate = pitchtools.transpose_pitch_carrier_by_interval(pitch_carrier_copy, interval) if candidate in pitch_range: result.append(candidate) interval += pitchtools.NumberedInterval(12) else: break return result
def add_artificial_harmonic(self, named_interval=None): r'''Adds artifical harmonic to note at `named_interval`. .. container:: example **Example.** Add artificial harmonic to note at the perfect fourth above. :: >>> staff = Staff("c'4 d'4 e'4 f'4") >>> beam = spannertools.BeamSpanner() >>> attach(beam, staff[:]) >>> show(staff) # doctest: +SKIP .. doctest:: >>> f(staff) \new Staff { c'4 [ d'4 e'4 f'4 ] } :: >>> staff[0].add_artificial_harmonic() Chord("<c' f'>4") >>> show(staff) # doctest: +SKIP .. doctest:: >>> f(staff) \new Staff { < c' \tweak #'style #'harmonic f' >4 [ d'4 e'4 f'4 ] } Sets `named_interval` to a perfect fourth above when ``named_interval=None``. Creates new chord from `note`. Moves parentage and spanners from `note` to chord. Returns chord. ''' from abjad.tools import scoretools from abjad.tools import scoretools from abjad.tools import mutationtools from abjad.tools import pitchtools if named_interval is None: named_interval = \ pitchtools.NamedInterval('perfect', 4) chord = scoretools.Chord(self) chord.append( chord[0].written_pitch.numbered_pitch._pitch_number) chord[1].written_pitch = \ pitchtools.transpose_pitch_carrier_by_interval( chord[1].written_pitch, named_interval) chord[1].tweak.style = 'harmonic' parent = self._parent if self._parent: index = parent.index(self) parent[index] = chord return chord
def fget(self): r'''Get sounding pitch of note: :: >>> staff = Staff("d''8 e''8 f''8 g''8") >>> piccolo = instrumenttools.Piccolo() >>> attach(piccolo, staff) Piccolo()(Staff{4}) :: >>> instrumenttools.transpose_from_sounding_pitch_to_written_pitch( ... staff) .. doctest:: >>> f(staff) \new Staff { \set Staff.instrumentName = \markup { Piccolo } \set Staff.shortInstrumentName = \markup { Picc. } d'8 e'8 f'8 g'8 } >>> staff[0].sounding_pitch NamedPitch("d''") Set sounding pitch of note: :: >>> staff[0].sounding_pitch = "dqs''" >>> f(staff) \new Staff { \set Staff.instrumentName = \markup { Piccolo } \set Staff.shortInstrumentName = \markup { Picc. } dqs'8 e'8 f'8 g'8 } ''' from abjad.tools import instrumenttools from abjad.tools import pitchtools if self.written_pitch_indication_is_at_sounding_pitch: return self.written_pitch else: instrument = self._get_effective_context_mark( instrumenttools.Instrument) if not instrument: message = 'effective instrument of note' message += ' can not be determined.' raise InstrumentError(message) sounding_pitch = instrument.sounding_pitch_of_written_middle_c t_n = pitchtools.NamedPitch('C4') - sounding_pitch sounding_pitch = \ pitchtools.transpose_pitch_carrier_by_interval( self.written_pitch, t_n) return sounding_pitch
def __add__(self, interval): from abjad.tools import pitchtools return pitchtools.transpose_pitch_carrier_by_interval( self, interval)