Beispiel #1
0
def getScale(index, keySig, numberOfOctaves):
    switcher = {
        0: scales.Aeolian(keySig),
        1: scales.Bachian(keySig),
        2: scales.Chromatic(keySig),
        3: scales.Diatonic(keySig, (3,7)),
        4: scales.Dorian(keySig),
        5: scales.HarmonicMajor(keySig),
        6: scales.HarmonicMinor(keySig),
        7: scales.Ionian(keySig),
        8: scales.Locrian(keySig),
        9: scales.Major(keySig),
        10: scales.MelodicMinor(keySig),
        11: scales.MinorNeapolitan(keySig),
        12: scales.Mixolydian(keySig),
        13: scales.NaturalMinor(keySig),
        14: scales.Octatonic(keySig),
        15: scales.Phrygian(keySig),
        16: scales.WholeTone(keySig)
    }
    scale = switcher.get(index, None)

    if scale is  None:
        return None
    else:
        converted_scale = []
        for i in range(numberOfOctaves):
            for note in scale.ascending():
                #print note
                converted_scale.append(str(Note(note,4+i)).replace('-','').replace("'",""))
        return converted_scale
Beispiel #2
0
def shorthand_list_to_numerals_list(
        progression=['Cmaj7', 'G-7', 'C7', 'Fmaj7', 'Bb7'], key='C'):
    '''
    progression is a shorthand list or a raw shorthand string (either work since we use parse_progression() to be safe)
    returns chords as a list of numerals
    '''
    progression = parse_progression(progression)

    def get_note(symbol):
        if symbol[1] == '#' or symbol[1] == 'b':
            return symbol[0:2]
        else:
            return symbol[0]

    proc_progression = [[get_note(chord), chord[len(get_note(chord)):]]
                        for chord in progression
                        ]  # splits a shorthand (e.g. 'C#M7' -> ['C#','M7'])

    # the numeral is the note's index in the chromatic scale of this key
    scale = scales.Chromatic(key)
    scale_list = []
    for i in range(0, len(scale) - 1):
        x = scale.degree(i + 1)
        if '##' in x:
            x = chr(ord(x[0]) + 1)
        scale_list.append(x)

    chromatic_numerals = [
        'I', 'bII', 'II', 'bIII', 'III', 'IV', 'bV', 'V', 'bVI', 'VI', 'bVII',
        'VII'
    ]
    numerals_progression = []
    for i, chord in enumerate(proc_progression):
        stem = chord[1]
        try:
            numeral = chromatic_numerals[scale_list.index(chord[0])]
        except ValueError:
            try:
                numeral = chromatic_numerals[scale_list.index(
                    synonyms[chord[0]])]
            except KeyError:
                print(f'No synonym for {chord[0]}')
        numerals_progression.append(numeral + stem)

    return numerals_progression
Beispiel #3
0
 def __buildScale(self):
     octa = int(math.ceil((self.numSteps / 7.0)))
     return {
         "diatonic":
         scales.Diatonic(self.start_key, (3, 7), octa),
         "ionian":
         scales.Ionian(self.start_key, octa),
         "dorian":
         scales.Dorian(self.start_key, octa),
         "phrygian":
         scales.Phrygian(self.start_key, octa),
         "lydian":
         scales.Lydian(self.start_key, octa),
         "mixolydian":
         scales.Mixolydian(self.start_key, octa),
         "aeolian":
         scales.Aeolian(self.start_key, octa),
         "locrian":
         scales.Locrian(self.start_key, octa),
         "major":
         scales.Major(self.start_key, octa),
         "harmonicmajor":
         scales.HarmonicMajor(self.start_key, octa),
         "naturalminor":
         scales.NaturalMinor(self.start_key, octa),
         "harmonicminor":
         scales.HarmonicMinor(self.start_key, octa),
         "melodicminor":
         scales.MelodicMinor(self.start_key, octa),
         "bachian":
         scales.Bachian(self.start_key, octa),
         "minorneapolitan":
         scales.MinorNeapolitan(self.start_key, octa),
         "chromatic":
         scales.Chromatic(self.start_key,
                          int(math.ceil((self.numSteps / 12.0)))),
         "wholetone":
         scales.WholeTone(self.start_key,
                          int(math.ceil((self.numSteps / 6.0)))),
         "octatonic":
         scales.Octatonic(self.start_key,
                          int(math.ceil((self.numSteps / 8.0))))
     }.get(self.scaleName.lower(), "custom")
Beispiel #4
0
 def select_scale(self, name, base_note):
     """Let me tell you what I am."""
     # TODO: Fix the diatonic arguments
     if not isinstance(base_note, str):
         return TypeError
     if name == "Diatonic":
         return self.scales.Diatonic(base_note, (0, 7))
     if name == "Ionian":
         return scales.Ionian(base_note)
     if name == "Dorian":
         return scales.Dorian(base_note)
     if name == "Phrygian":
         return scales.Phrygian(base_note)
     if name == "Lydian":
         return scales.Lydian(base_note)
     if name == "Mixolydian":
         return scales.Mixolydian(base_note)
     if name == "Aeolian":
         return scales.Aeolian(base_note)
     if name == "Locrian":
         return scales.Locrian(base_note)
     if name == "Major":
         return scales.Major(base_note)
     if name == "HarmonicMajor":
         return scales.HarmonicMajor(base_note)
     if name == "NaturalMinor":
         return scales.NaturalMinor(base_note)
     if name == "HarmonicMinor":
         return scales.HarmonicMinor(base_note)
     if name == "MelodicMinor":
         return scales.MelodicMinor(base_note)
     if name == "Bachian":
         return scales.Bachian(base_note)
     if name == "MinorNeapolitan":
         return scales.MinorNeapolitan(base_note)
     if name == "Chromatic":
         return scales.Chromatic(base_note)
     if name == "WholeTone":
         return scales.WholeTone(base_note)
     if name == "Octatonic":
         return scales.Octatonic(base_note)
Beispiel #5
0
 def select_scale(self, name, base_note):
     if not isinstance(base_note, str):
         return TypeError("Scale Name incorrect.")
     if name == "Diatonic":
         return self.scales.Diatonic(base_note, (0, 7))
     if name == "Ionian":
         return scales.Ionian(base_note)
     if name == "Dorian":
         return scales.Dorian(base_note)
     if name == "Phrygian":
         return scales.Phrygian(base_note)
     if name == "Lydian":
         return scales.Lydian(base_note)
     if name == "Mixolydian":
         return scales.Mixolydian(base_note)
     if name == "Aeolian":
         return scales.Aeolian(base_note)
     if name == "Locrian":
         return scales.Locrian(base_note)
     if name == "Major":
         return scales.Major(base_note)
     if name == "HarmonicMajor":
         return scales.HarmonicMajor(base_note)
     if name == "NaturalMinor":
         return scales.NaturalMinor(base_note)
     if name == "HarmonicMinor":
         return scales.HarmonicMinor(base_note)
     if name == "MelodicMinor":
         return scales.MelodicMinor(base_note)
     if name == "Bachian":
         return scales.Bachian(base_note)
     if name == "MinorNeapolitan":
         return scales.MinorNeapolitan(base_note)
     if name == "Chromatic":
         return scales.Chromatic(base_note)
     if name == "WholeTone":
         return scales.WholeTone(base_note)
     if name == "Octatonic":
         return scales.Octatonic(base_note)