Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW. Added abjad.VoiceNumber(n=None) indicator. #1528

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions abjad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
StopTrillSpan,
Tie,
TimeSignature,
VoiceNumber,
)
from .instruments import (
Accordion,
Expand Down Expand Up @@ -483,6 +484,7 @@
"Viola",
"Violin",
"Voice",
"VoiceNumber",
"WellformednessError",
"Wrapper",
"Xylophone",
Expand Down
1 change: 1 addition & 0 deletions abjad/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ def list_all_classes(modules="abjad", ignored_classes=None):
<class 'abjad.indicators.StopTrillSpan'>
<class 'abjad.indicators.Tie'>
<class 'abjad.indicators.TimeSignature'>
<class 'abjad.indicators.VoiceNumber'>
<class 'abjad.instruments.Accordion'>
<class 'abjad.instruments.AltoFlute'>
<class 'abjad.instruments.AltoSaxophone'>
Expand Down
6 changes: 6 additions & 0 deletions abjad/contributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Types(enum.Enum):
STEM_TREMOLOS = enum.auto()
STOP_BEAM = enum.auto()
TRILL_SPANNER_STARTS = enum.auto()
VOICE_NUMBER = enum.auto()


@dataclasses.dataclass(slots=True)
Expand All @@ -56,6 +57,7 @@ class _ContributionsByType:
stem_tremolos: list[str] = dataclasses.field(default_factory=list)
stop_beam: list[str] = dataclasses.field(default_factory=list)
trill_spanner_starts: list[str] = dataclasses.field(default_factory=list)
voice_number: list[str] = dataclasses.field(default_factory=list)

def __iter__(self):
for type_ in (
Expand All @@ -71,6 +73,7 @@ def __iter__(self):
self.stem_tremolos,
self.stop_beam,
self.trill_spanner_starts,
self.voice_number,
):
yield type_

Expand All @@ -92,6 +95,7 @@ def tag(self, tag, deactivate=None):
self.trill_spanner_starts = _tag.double_tag(
self.trill_spanner_starts, tag, deactivate
)
self.voice_number = _tag.double_tag(self.voice_number, tag, deactivate)

def update(self, contributions):
"""
Expand Down Expand Up @@ -122,6 +126,8 @@ def update(self, contributions):
self.stop_beam.append(contributions.stop_beam)
if contributions.trill_spanner_starts:
self.trill_spanner_starts.append(contributions.trill_spanner_starts)
if contributions.voice_number:
self.voice_number.append(contributions.voice_number)


@dataclasses.dataclass(slots=True)
Expand Down
8 changes: 4 additions & 4 deletions abjad/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ class Dynamic:

>>> voice_1 = abjad.Voice("e'8 g'8 f'8 a'8")
>>> abjad.attach(abjad.Dynamic('f'), voice_1[0], context='Voice')
>>> literal = abjad.LilyPondLiteral(r"\voiceOne", "opening")
>>> abjad.attach(literal, voice_1)
>>> command = abjad.VoiceNumber(1)
>>> abjad.attach(command, voice_1[0])
>>> abjad.override(voice_1).DynamicLineSpanner.direction = abjad.UP
>>> voice_2 = abjad.Voice("c'2")
>>> literal = abjad.LilyPondLiteral(r"\voiceTwo", "opening")
>>> abjad.attach(literal, voice_2)
>>> command = abjad.VoiceNumber(2)
>>> abjad.attach(command, voice_2[0])
>>> abjad.attach(abjad.Dynamic("mf"), voice_2[0], context="Voice")
>>> staff = abjad.Staff([voice_1, voice_2], simultaneous=True)
>>> abjad.show(staff) # doctest: +SKIP
Expand Down
70 changes: 35 additions & 35 deletions abjad/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def after_grace_container(argument):
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -294,9 +294,9 @@ def before_grace_container(argument):
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -389,9 +389,9 @@ def contents(argument) -> list[_score.Component]:
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -583,9 +583,9 @@ def descendants(argument) -> list[_score.Component]:
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -752,9 +752,9 @@ def duration(
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -959,10 +959,10 @@ def effective(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -1461,9 +1461,9 @@ def effective_staff(argument) -> typing.Optional["_score.Staff"]:
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -1593,10 +1593,10 @@ def effective_wrapper(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -1712,9 +1712,9 @@ def grace(argument) -> bool:
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -1813,10 +1813,10 @@ def has_effective_indicator(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -1966,10 +1966,10 @@ def has_indicator(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -2164,10 +2164,10 @@ def indicator(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -2321,10 +2321,10 @@ def indicators(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -2380,9 +2380,9 @@ def indicators(
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }"):
[]
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16"):
[LilyPondLiteral(argument='\\set fontSize = #-3', site='opening', directed=False)]
[]
Chord("<e' g'>16"):
[StartBeam(), LilyPondLiteral(argument='\\slash', site='opening', directed=False), StartSlur(), LilyPondLiteral(argument='\\voiceOne', site='opening', directed=False), Clef(name='alto', hide=False), Articulation(name='>')]
[LilyPondLiteral(argument='\\set fontSize = #-3', site='opening', directed=False), StartBeam(), LilyPondLiteral(argument='\\slash', site='opening', directed=False), StartSlur(), VoiceNumber(n=1, leak=False), Clef(name='alto', hide=False), Articulation(name='>')]
Note("gs'16"):
[Articulation(name='.')]
Note("a'16"):
Expand All @@ -2392,9 +2392,9 @@ def indicators(
Voice("e'4", name='MusicVoice'):
[]
Note("e'4"):
[LilyPondLiteral(argument='\\voiceTwo', site='opening', directed=False), Articulation(name='.')]
[VoiceNumber(n=2, leak=False), Articulation(name='.')]
Note("f'4"):
[LilyPondLiteral(argument='\\oneVoice', site='absolute_before', directed=False), Articulation(name='.')]
[VoiceNumber(n=None, leak=False), Articulation(name='.')]
AfterGraceContainer("fs'16"):
[]
Note("fs'16"):
Expand Down Expand Up @@ -2566,10 +2566,10 @@ def leaf(argument, n: int = 0) -> typing.Optional["_score.Leaf"]:
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -2750,9 +2750,9 @@ def lineage(argument) -> "Lineage":
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -2956,9 +2956,9 @@ def logical_tie(argument) -> "_select.LogicalTie":
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -3147,9 +3147,9 @@ def measure_number(argument) -> int:
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -3321,9 +3321,9 @@ def parentage(argument) -> "_parentage.Parentage":
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -3536,9 +3536,9 @@ def pitches(argument) -> set[_pitch.NamedPitch]:
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -3796,9 +3796,9 @@ def timespan(argument, in_seconds: bool = False) -> _timespan.Timespan:
<<
\context Voice = "On_Beat_Grace_Container"
{
\voiceOne
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -3983,10 +3983,10 @@ def wrapper(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down Expand Up @@ -4121,10 +4121,10 @@ def wrappers(
<<
\context Voice = "On_Beat_Grace_Container"
{
\set fontSize = #-3
\voiceOne
\clef "alto"
\set fontSize = #-3
\slash
\voiceOne
<
\tweak font-size 0
\tweak transparent ##t
Expand Down
Loading