Skip to content

Commit

Permalink
nice
Browse files Browse the repository at this point in the history
  • Loading branch information
iacchus committed May 10, 2017
1 parent 43d3a15 commit 2af2c30
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 56 deletions.
3 changes: 3 additions & 0 deletions TODO.md
Expand Up @@ -34,3 +34,6 @@ with a dict/config file.
we should think in a better algo for melodic dictation; currently always begins
with tonic; maybe playing a cadence with I-V-IV-I triads then choosing random
intervals w/ or w/out tonic.

we should use some kind of config object to configure exercises, as they have an
extensive number of parameters and there are more to come.
3 changes: 2 additions & 1 deletion birdears/__main__.py
Expand Up @@ -138,7 +138,8 @@ def main():
input_keys = []
#question = HarmonicIntervalQuestion(mode='major')
#question = MelodicIntervalQuestion(mode='major',descending=True)
question = MelodicIntervalQuestion(mode='major')
#question = MelodicIntervalQuestion(mode='major',chromatic=True,n_octaves=2,descending=True)
question = HarmonicIntervalQuestion(mode='major',chromatic=True)

# debug
if DEBUG:
Expand Down
41 changes: 13 additions & 28 deletions birdears/questions/harmonicinterval.py
Expand Up @@ -26,7 +26,7 @@ def __init__(self, mode='major', tonic=None, octave=None, descending=None,
n_octaves=n_octaves, *args, **kwargs)

tonic = self.tonic

if not chromatic:
self.interval = DiatonicInterval(mode=mode, tonic=self.tonic,
octave=self.octave,
Expand Down Expand Up @@ -96,38 +96,22 @@ def make_resolution(self, chromatic, mode, tonic, interval,
descending=descending)
self.res_scale = scale_pitch

if not chromatic:

if interval['chromatic_offset'] <= MAX_SEMITONES_RESOLVE_BELOW:
resolution_pitch =\
scale_pitch.scale[:interval['diatonic_index'] + 1]
resolution_pitch.reverse()
else:
resolution_pitch =\
scale_pitch.scale[interval['diatonic_index']:]

if interval['chromatic_offset'] <= MAX_SEMITONES_RESOLVE_BELOW:
begin_to_diatonic = slice(None, interval['diatonic_index'] + 1)
resolution_pitch = scale_pitch.scale[begin_to_diatonic]
if interval['is_chromatic']:
resolution_pitch.append(interval['note_and_octave'])
resolution_pitch.reverse()
else:

if interval['chromatic_offset'] <= MAX_SEMITONES_RESOLVE_BELOW:
if interval['is_chromatic']:
resolution_pitch.extend(
scale_pitch.scale[: interval['diatonic_index'] + 1])
resolution_pitch.append(interval['note_and_octave'])
else:
resolution_pitch.extend(
scale_pitch.scale[: interval['diatonic_index'] + 1])
resolution_pitch.reverse()

else:
if interval['is_chromatic']:
resolution_pitch.append(interval['note_and_octave'])

resolution_pitch.extend(
scale_pitch.scale[interval['diatonic_index']:])
diatonic_to_end = slice(interval['diatonic_index'], None)
if interval['is_chromatic']:
resolution_pitch.append(interval['note_and_octave'])
resolution_pitch.extend(scale_pitch.scale[diatonic_to_end])

# unisson and octave
if interval['semitones'] == 0:
resolution_pitch.append(scale_pitch.scale[0])

elif interval['semitones'] % 12 == 0:
# FIXME: multipe octaves
resolution_pitch.append("{}{}".format(tonic,
Expand All @@ -137,4 +121,5 @@ def make_resolution(self, chromatic, mode, tonic, interval,
duration=self.resolution_duration,
delay=self.resolution_delay,
pos_delay=self.resolution_pos_delay)

return resolution
38 changes: 11 additions & 27 deletions birdears/questions/melodicinterval.py
Expand Up @@ -96,38 +96,22 @@ def make_resolution(self, chromatic, mode, tonic, interval,
descending=descending)
self.res_scale = scale_pitch

if not chromatic:

if interval['chromatic_offset'] <= MAX_SEMITONES_RESOLVE_BELOW:
resolution_pitch =\
scale_pitch.scale[:interval['diatonic_index'] + 1]
resolution_pitch.reverse()
else:
resolution_pitch =\
scale_pitch.scale[interval['diatonic_index']:]

if interval['chromatic_offset'] <= MAX_SEMITONES_RESOLVE_BELOW:
begin_to_diatonic = slice(None, interval['diatonic_index'] + 1)
resolution_pitch = scale_pitch.scale[begin_to_diatonic]
if interval['is_chromatic']:
resolution_pitch.append(interval['note_and_octave'])
resolution_pitch.reverse()
else:

if interval['chromatic_offset'] <= MAX_SEMITONES_RESOLVE_BELOW:
if interval['is_chromatic']:
resolution_pitch.extend(
scale_pitch.scale[: interval['diatonic_index'] + 1])
resolution_pitch.append(interval['note_and_octave'])
else:
resolution_pitch.extend(
scale_pitch.scale[: interval['diatonic_index'] + 1])
resolution_pitch.reverse()

else:
if interval['is_chromatic']:
resolution_pitch.append(interval['note_and_octave'])

resolution_pitch.extend(
scale_pitch.scale[interval['diatonic_index']:])
diatonic_to_end = slice(interval['diatonic_index'], None)
if interval['is_chromatic']:
resolution_pitch.append(interval['note_and_octave'])
resolution_pitch.extend(scale_pitch.scale[diatonic_to_end])

# unisson and octave
if interval['semitones'] == 0:
resolution_pitch.append(scale_pitch.scale[0])

elif interval['semitones'] % 12 == 0:
# FIXME: multipe octaves
resolution_pitch.append("{}{}".format(tonic,
Expand Down

0 comments on commit 2af2c30

Please sign in to comment.