Skip to content

Commit

Permalink
IntervalSubmission: Avoid double-augmented or double-diminshed intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Mar 12, 2023
1 parent f961176 commit 227fda3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions notecheck/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,11 @@ def get_pitch_pairs(self) -> []:
pitch1.accs = rnd.randrange(-ex.max_flats, ex.max_sharps+1)
pitch2.accs = rnd.randrange(-ex.max_flats, ex.max_sharps+1)

# Check other exercise constrains.
# Check other exercise constraints.
interval_candidate = Interval.from_diatonic_pitches((pitch1, pitch2), False)
if (ex.max_quantity == 0 or abs(interval_candidate.quantity) <= ex.max_quantity) and (ex.direction == 0 or interval_candidate.quantity / abs(interval_candidate.quantity) == ex.direction):
if (ex.max_quantity == 0 or abs(interval_candidate.quantity) <= ex.max_quantity) and \
(ex.direction == 0 or interval_candidate.quantity / abs(interval_candidate.quantity) == ex.direction) and \
interval_candidate.quality >= -2 and interval_candidate.quality <= 2:
pitch_pair = (pitch1, pitch2)

pitch_pairs.append( pitch_pair )
Expand Down

0 comments on commit 227fda3

Please sign in to comment.