示例#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
示例#2
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")
示例#3
0
文件: scales.py 项目: gabelev/tonal
 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)
示例#4
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)
示例#5
0
 def get_scale(self):
     init_note = np.random.randint(0,12)
     scale = np.random.randint(1,12)
     note = notes.int_to_note(init_note)
     if(scale == 1):
         print("## Ionian Scale Selected!")
         return scales.Ionian(note)
     if(scale == 2):
         print("## Dorian Scale Selected!")
         return scales.Dorian(note)
     if(scale == 3):
         print("## Phrygian Scale Selected!")
         return scales.Phrygian(note)
     if(scale == 4):
         print("## Lydian Scale Selected!")
         return scales.Lydian(note)
     if(scale == 5):
         print("## Mixolydian Scale Selected!")
         return scales.Mixolydian(note)
     if(scale == 6):
         print("## Aeolian Scale Selected!")
         return scales.Aeolian(note)
     if(scale == 7):
         print("## Locrian Scale Selected!")
         return scales.Locrian(note)
     if(scale == 8):
         print("## NaturalMinor Scale Selected!")
         return scales.NaturalMinor(note)
     if(scale == 9):
         print("## HarmonicMinor Scale Selected!")
         return scales.HarmonicMinor(note)
     if(scale == 10):
         print("## MelodicMinor Scale Selected!")
         return scales.MelodicMinor(note)
     if(scale == 11):
         print("## WholeTone Scale Selected!")
         return scales.WholeTone(note)