From 866e904260a0e68516d4707d1ac0fd95516198e8 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 25 May 2017 08:13:54 -0800 Subject: [PATCH] Added the to_major and to_minor methods that the Tutorial calls for. --- mingus/core/notes.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/mingus/core/notes.py b/mingus/core/notes.py index ab76326b..11d6087c 100644 --- a/mingus/core/notes.py +++ b/mingus/core/notes.py @@ -142,6 +142,39 @@ def remove_redundant_accidentals(note): val += 1 return result +def to_major(note): + """ convert note to relative major. + + Examples: + >>> to_major('C') + 'D#' + >>> to_major('D') + 'F' + """ + note_int = note_to_int() + note_int += 3 + if note_int > 11: + note_int -= 12 + result = int_to_note(note_int) + return result + +def to_minor(note): + """ convert note to relative minor. + + Examples: + >>> to_major('C') + 'D#' + >>> to_major('D') + 'F' + """ + note_int = note_to_int() + note_int -= 3 + if note_int < 0: + note_int += 12 + result = int_to_note(note_int) + return result + + def augment(note): """Augment a given note.