Exemplo n.º 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
Exemplo n.º 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")
Exemplo n.º 3
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 6
0
 def test_not_equal(self):
     self.assertNotEqual(scales.NaturalMinor("C"), scales.NaturalMinor("A"))
     self.assertNotEqual(scales.NaturalMinor("A"), scales.MelodicMinor("A"))
     self.assertNotEqual(scales.Major("F"), scales.Major("D"))
     self.assertNotEqual(scales.Ionian("E"), scales.Dorian("E"))
Exemplo n.º 7
0
 def test_equal(self):
     self.assertEqual(scales.NaturalMinor("C"), scales.NaturalMinor("C"))
     self.assertEqual(scales.Major("F"), scales.Major("F"))
     self.assertEqual(scales.Major("Bb"), scales.Ionian("Bb"))
     self.assertEqual(scales.NaturalMinor("E"), scales.Aeolian("E"))
Exemplo n.º 8
0
#notes.to_major('A') # C

#无模块
#import mingus.core.diatonic as diatonic
#十二音
#diatonic.basic_keys
#E调七音
#diatonic.get_notes('E')

import mingus.core.intervals as interval
#间隔半音数
interval.measure('C', 'D')  #2

import mingus.core.scales as scales
#爱奥尼音阶对象
scales.Ionian('C')

#音对象
from mingus.containers import Note
#C4音对象
n = Note('C')
#变为C5
n.set_note('C', 5)
#音对象属性
n.name  #十二音名
n.octave  #第几八度
n.dynamics  #其它属性
#音对象方法
int(n)  #音对象的数值
c = Note()
c.from_int(12)  #使用数值创建音对象
Exemplo n.º 9
0
 def test_not_equal(self):
     self.assertNotEqual(scales.NaturalMinor('C'), scales.NaturalMinor('A'))
     self.assertNotEqual(scales.NaturalMinor('A'), scales.MelodicMinor('A'))
     self.assertNotEqual(scales.Major('F'), scales.Major('D'))
     self.assertNotEqual(scales.Ionian('E'), scales.Dorian('E'))
Exemplo n.º 10
0
 def test_equal(self):
     self.assertEqual(scales.NaturalMinor('C'), scales.NaturalMinor('C'))
     self.assertEqual(scales.Major('F'), scales.Major('F'))
     self.assertEqual(scales.Major('Bb'), scales.Ionian('Bb'))
     self.assertEqual(scales.NaturalMinor('E'), scales.Aeolian('E'))