-
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.
Merge pull request #2 from nivlekp/stateMapping
Some state mapping logic
- Loading branch information
Showing
10 changed files
with
80 additions
and
21 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -66,6 +66,7 @@ check: | |
make black-check | ||
make flake8 | ||
make isort-check | ||
make mypy | ||
|
||
test: | ||
make black-check | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from . import library, states | ||
from . import library, soundpointsgenerators, statemapper, statetransition | ||
|
||
__all__ = ["library", "states"] | ||
__all__ = ["library", "soundpointsgenerators", "statemapper", "statetransition"] |
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 |
---|---|---|
@@ -1,14 +1,7 @@ | ||
import dataclasses | ||
import enum | ||
PITCHES_SETS = [{-6, -5, -4, 0, (1, 2), 3}, {-32, -30, 24, 27}] | ||
|
||
AXIS = enum.Enum("AXIS", ["FREQUENCY", "INTENSITY", "DENSITY"]) | ||
FREQUENCY_REGIONS = enum.Enum("FREQUENCY_REGIONS", ["F0", "F1"]) | ||
INTENSITY_REGIONS = enum.Enum("INTENSITY_REGIONS", ["G0", "G1"]) | ||
DENSITY_REGIONS = enum.Enum("DENSITY_REGIONS", ["D0", "D1"]) | ||
INTENSITY_SETS = [{-1, 0}, {-2, 2}] | ||
|
||
DENSITY_SETS = [{0.7}, {3.0}] | ||
|
||
@dataclasses.dataclass | ||
class State: | ||
frequency_region: FREQUENCY_REGIONS | ||
intensity_region: INTENSITY_REGIONS | ||
density_region: DENSITY_REGIONS | ||
DURATION_SETS = [{0.3}, {1.0}] |
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,9 @@ | ||
import pang | ||
|
||
|
||
class AtaxicSoundPointsGenerator(pang.SoundPointsGenerator): | ||
def __init__(self, pitches_set, intensity_set, density_set, duration_set): | ||
self.pitches_set = pitches_set | ||
self.intensity_set = intensity_set | ||
self.density_set = density_set | ||
self.duration_set = duration_set |
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
File renamed without changes.
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,33 @@ | ||
import numpy as np | ||
import pang | ||
import pytest | ||
|
||
from minamidera import library, statemapper | ||
|
||
|
||
def test_mapping_empty_sequence(): | ||
assert statemapper.map_state_sequence([]) == pang.Sequence.empty_sequence() | ||
|
||
|
||
def test_mapping_sound_point_generator_from_invalid_state_vector_length(): | ||
with pytest.raises(ValueError) as exception_info: | ||
statemapper.map_state_vector_to_sound_points_generator( | ||
np.array([0, 0, 1, 0, 0]) | ||
) | ||
assert "does not match" in str(exception_info) | ||
|
||
|
||
def test_mapping_sound_point_generator_from_invalid_state_vector_value(): | ||
with pytest.raises(ValueError) as exception_info: | ||
statemapper.map_state_vector_to_sound_points_generator(np.array([0, 1, 0, 2])) | ||
assert "contains value other than 0 and 1" in str(exception_info) | ||
|
||
|
||
def test_mapping_state_vector_to_sound_point_generator(): | ||
sound_points_generator = statemapper.map_state_vector_to_sound_points_generator( | ||
np.array([0, 1, 0, 1]) | ||
) | ||
assert sound_points_generator.pitches_set == library.PITCHES_SETS[0] | ||
assert sound_points_generator.intensity_set == library.INTENSITY_SETS[1] | ||
assert sound_points_generator.density_set == library.DENSITY_SETS[0] | ||
assert sound_points_generator.duration_set == library.DURATION_SETS[1] |
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