Skip to content

Commit

Permalink
(closes #830) Reimplemented pitchtools functions as methods.
Browse files Browse the repository at this point in the history
(#83) Removed pitchtools.tranpose_pitch_carrier_by_interval().
    Use Interval.transpose() instead.
(#830) Removed pitchtools.transpose_pitch_carrier_by_interval().
(#830) Documented quartertone NamedPitch('A+5')-style initialization.
(#830 Migrated respell_with_flats(), sharps() from MutationAgent to NamedPitch.
  • Loading branch information
trevorbaca committed Jul 31, 2017
1 parent 186cb69 commit 6e84978
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 434 deletions.
108 changes: 0 additions & 108 deletions abjad/tools/agenttools/MutationAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,114 +598,6 @@ def replace_measure_contents(self, new_contents):
# return iterated measures
return result

def respell_with_flats(self):
r'''Respells named pitches in mutation client with flats.
.. todo:: Move to pitchtools package.
.. container:: example
Respells notes in staff:
::
>>> staff = Staff("c'8 cs'8 d'8 ef'8 e'8 f'8")
>>> show(staff) # doctest: +SKIP
.. docs::
>>> f(staff)
\new Staff {
c'8
cs'8
d'8
ef'8
e'8
f'8
}
::
>>> mutate(staff).respell_with_flats()
>>> show(staff) # doctest: +SKIP
.. docs::
>>> f(staff)
\new Staff {
c'8
df'8
d'8
ef'8
e'8
f'8
}
Returns none.
'''
from abjad.tools import scoretools
for leaf in iterate(self._client).by_leaf():
if isinstance(leaf, scoretools.Note):
leaf.written_pitch = leaf.written_pitch.respell_with_flats()
elif isinstance(leaf, scoretools.Chord):
for note_head in leaf.note_heads:
pitch = note_head.written_pitch.respell_with_flats()
note_head.written_pitch = pitch

def respell_with_sharps(self):
r'''Respells named pitches in mutation client with sharps.
.. todo:: Move to pitchtools package.
.. container:: example
Respells notes in staff:
::
>>> staff = Staff("c'8 cs'8 d'8 ef'8 e'8 f'8")
>>> show(staff) # doctest: +SKIP
.. docs::
>>> f(staff)
\new Staff {
c'8
cs'8
d'8
ef'8
e'8
f'8
}
::
>>> mutate(staff).respell_with_sharps()
>>> show(staff) # doctest: +SKIP
.. docs::
>>> f(staff)
\new Staff {
c'8
cs'8
d'8
ds'8
e'8
f'8
}
Returns none.
'''
from abjad.tools import scoretools
for leaf in iterate(self._client).by_leaf():
if isinstance(leaf, scoretools.Note):
leaf.written_pitch = leaf.written_pitch.respell_with_sharps()
elif isinstance(leaf, scoretools.Chord):
for note_head in leaf.note_heads:
pitch = note_head.written_pitch.respell_with_sharps()
note_head.written_pitch = pitch

def rewrite_meter(
self,
meter,
Expand Down

This file was deleted.

This file was deleted.

8 changes: 8 additions & 0 deletions abjad/tools/pitchtools/Interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,11 @@ def is_named_interval_quality_abbreviation(argument):
return False
return bool(Interval._named_interval_quality_abbreviation_regex.match(
argument))

@abc.abstractmethod
def transpose(self, pitch_carrier):
r'''Transposes `pitch_carrier` by interval.
Returns new pitch carrier.
'''
raise NotImplementedError
Loading

0 comments on commit 6e84978

Please sign in to comment.