Skip to content

Commit

Permalink
Do dynamics (#11)
Browse files Browse the repository at this point in the history
* bump version

* tell spg to generate some intensities

* bump pang's commit

* use abjad.Dynamic as attachment instead

* generate music

* find dynamic instead of assuming the first position

* add a unit test for dynamics

* reformat
  • Loading branch information
nivlekp authored Oct 4, 2024
1 parent f338e98 commit eb5f66c
Show file tree
Hide file tree
Showing 14 changed files with 519 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
LILYPOND_VERSION: 2.25.16
PANG_COMMIT: d7e9d9e7dc13a9ee5bd3e0dbc5bc30eada8f44bd
PANG_COMMIT: 1c9e6b8ac68ced96a8e20d4e2238f9ab1cc2094e
PANG_PATH: /tmp/pang

jobs:
Expand Down
21 changes: 21 additions & 0 deletions minamidera/dynamics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import abjad


def do_dynamics(voice: abjad.Component) -> None:
current_dynamic: abjad.Dynamic | None = None
for logical_tie in abjad.iterate.logical_ties(voice, pitched=True):
current_dynamic = _do_dynamics(logical_tie, current_dynamic)


def _do_dynamics(
logical_tie: abjad.LogicalTie, previous_dynamic: abjad.Dynamic | None
) -> abjad.Dynamic:
leaf = abjad.get.leaf(logical_tie, 0)
current_dynamic = next(
attachment
for attachment in abjad.get.annotation(leaf, "q_event_attachments")
if isinstance(attachment, abjad.Dynamic)
)
if current_dynamic != previous_dynamic:
abjad.attach(current_dynamic, leaf)
return current_dynamic
2 changes: 1 addition & 1 deletion minamidera/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
),
)

INTENSITY_SETS = ({-1, 0}, {-2, 2})
INTENSITY_SETS = ({-1, 1}, {-2, 2})

DENSITY_SETS = ({0.5}, {2.5})

Expand Down
Loading

0 comments on commit eb5f66c

Please sign in to comment.