This package aims to serve as a base that can be used in music theory applications which rely on interval building and finding.
By using this module, you can build an interval starting from any note, in any direction (ascending, descending). You can also find the interval between two arbitrary notes in any direction (ascending and descending).
- Python 3.7+
from src.engine import IntervalCalculator
from src.enums import Note, Interval
calc = IntervalCalculator()
calc.add_interval_above(Note.G, Interval.MINOR_6TH)
<Note.E_FLAT: 4>
from src.engine import IntervalCalculator
from src.enums import Note, Interval
calc = IntervalCalculator()
calc.subtract_interval_below(Note.A_FLAT, Interval.TRITONE)
<Note.D: 3>
from src.engine import IntervalCalculator
from src.enums import Note, Interval
calc = IntervalCalculator()
calc.find_interval_ascending(Note.E, Note.B_FLAT)
<Interval.TRITONE: (6, 'TT', 'tritone')>
from src.engine import IntervalCalculator
from src.enums import Note, Interval
calc = IntervalCalculator()
calc.find_interval_descending(Note.A, Note.D_FLAT)
<Interval.MINOR_6TH: (8, 'm6', 'minor 6th')>
If you want to practice building intervals, start the CLI trainer:
python -m src.trainer
Run in auto-answer mode:
python -m src.trainer -a
Execute the unit tests:
python -m unittest src.tests