Skip to content

Commit

Permalink
Use sieves (#8)
Browse files Browse the repository at this point in the history
* use sieves

* bump version

* use a mix of chords and single pitches

* good  for now
  • Loading branch information
nivlekp authored Sep 27, 2024
1 parent 27564e2 commit 024cb30
Show file tree
Hide file tree
Showing 12 changed files with 6,891 additions and 7,219 deletions.
2,251 changes: 1,090 additions & 1,161 deletions minamidera/builds/score/_sections/a.ily

Large diffs are not rendered by default.

2,238 changes: 1,076 additions & 1,162 deletions minamidera/builds/score/_sections/b.ily

Large diffs are not rendered by default.

2,519 changes: 1,240 additions & 1,279 deletions minamidera/builds/score/_sections/c.ily

Large diffs are not rendered by default.

40 changes: 35 additions & 5 deletions minamidera/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,43 @@
import abjad
import pang

PITCHES_SETS = [{-6, -5, -4, 0, (1, 2), 3}, {-32, -30, 24, 27}]
from . import pitches as pitches_

INTENSITY_SETS = [{-1, 0}, {-2, 2}]
PATTERN_0 = abjad.Pattern(indices=[0], period=2)
PATTERN_1 = abjad.Pattern(indices=[1], period=3)
PATTERN_2 = abjad.Pattern(indices=[2], period=5)
PATTERN_3 = abjad.Pattern(indices=[3], period=7)

DENSITY_SETS = [{0.7}, {3.0}]
PITCHES_SETS = (
pitches_.single_pitches_to_pitches_and_chords(
tuple(
pang.gen_pitches_from_sieve(
sieve=PATTERN_0 | PATTERN_1 | PATTERN_2 | PATTERN_3,
origin=0,
low=-24,
high=24,
)
),
(1,),
),
pitches_.single_pitches_to_pitches_and_chords(
tuple(
pang.gen_pitches_from_sieve(
sieve=(PATTERN_0 | PATTERN_1) & (PATTERN_2 | PATTERN_3),
origin=0,
low=-36,
high=48,
)
),
(1, 2),
),
)

DURATION_SETS = [{0.3}, {1.0}]
INTENSITY_SETS = ({-1, 0}, {-2, 2})

DENSITY_SETS = ({0.7}, {3.0})

DURATION_SETS = ({0.3}, {1.0})


PIANO_MUSIC_VOICE_0_NAME = "Piano.Music.0"
Expand Down Expand Up @@ -66,7 +96,7 @@ def can_serve(self, sound_point: pang.SoundPoint) -> bool:
pitch = sound_point.pitch
if isinstance(pitch, float) or isinstance(pitch, int):
return pitch >= -6
return all(p >= 6 for p in pitch)
return all(p >= -6 for p in pitch)


class BassNoteServer(pang.NoteServer):
Expand Down
34 changes: 34 additions & 0 deletions minamidera/pitches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import itertools
from collections.abc import Iterable

MAXIMUM_SPAN = 10


def single_pitches_to_pitches_and_chords(
pitches: tuple[float, ...], numbers_of_notes: tuple[int, ...]
) -> set:
chords = set(
filter(
_chords_filter_function,
[
chord
for number_of_notes in numbers_of_notes
for chord in itertools.combinations(pitches, number_of_notes)
if len(chord) > 1
],
)
)
if 1 in numbers_of_notes:
return chords | set(pitches)
return chords


def _chords_filter_function(pitches: Iterable[float]) -> bool:
return (
max(pitches) - min(pitches) < MAXIMUM_SPAN
and max(pitches) - min(pitches) > 4
and (
all(pitch >= -6 for pitch in pitches)
or all(pitch <= 6 for pitch in pitches)
)
)
8 changes: 4 additions & 4 deletions minamidera/segments/a/__metadata__.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"duration": 200.0,
"duration": 206.15384615384616,
"last_metronome_mark": {
"reference_duration": "1/4",
"units_per_minute": 78.0
},
"last_time_signature": "4/4",
"empty_beatspan": "3/8",
"empty_beatspan": "1/8",
"per_voice_metadata": {
"Piano.Music.0": {
"number_of_all_discarded_q_events": 3,
"number_of_all_discarded_q_events": 6,
"number_of_discarded_pitched_q_events": 0
},
"Piano.Music.1": {
"number_of_all_discarded_q_events": 6,
"number_of_all_discarded_q_events": 2,
"number_of_discarded_pitched_q_events": 0
}
}
Expand Down
Loading

0 comments on commit 024cb30

Please sign in to comment.