-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use sieves * bump version * use a mix of chords and single pitches * good for now
- Loading branch information
Showing
12 changed files
with
6,891 additions
and
7,219 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.