def CreateFromToneAndMode(self, tone, modeName): #If needed parse string to tone if type(tone) == str: toneObj = t.Tone() toneObj.CreateFromNumberInTonemap(t.toneMap.index(tone)) tone = toneObj self.baseTone = tone self.tones.append(tone) self.modeName = modeName self.mode = m.Modes[modeName] count = 0 for permutation in self.mode: count = count + permutation newTone = self.baseTone.GetToneAbove(count) if not u.Contains(self.tones, newTone.name): self.tones.append(newTone) #CREATE CHORDS from Harmonity import Chord for tone in self.tones: chord = Chord.Chord() chord.CreateTriadFromToneAndScale(tone, self) self.chords.append(chord)
def CreateTriadFromToneAndScale(self, tone, scale): self.baseTone = tone self.tones.append(tone) indexOfSecond = u.ClipToLength(u, scale.tones.index(self.baseTone) + 2, scale.tones.__len__()) self.tones.append(scale.tones[indexOfSecond]) indexOfThird = u.ClipToLength(u, scale.tones.index(self.baseTone) + 4, scale.tones.__len__()) self.tones.append(scale.tones[indexOfThird]) chordConfig1 = t.toneMap.index(self.tones[1].name) - t.toneMap.index(self.tones[0].name) if chordConfig1 < 0: chordConfig1 = t.toneMap.__len__()+chordConfig1 chordConfig2 = t.toneMap.index(self.tones[2].name) - t.toneMap.index(self.tones[0].name) if chordConfig2 < 0: chordConfig2 = t.toneMap.__len__()+chordConfig2 self.configuration = [chordConfig1, chordConfig2]
def GetScalesFittingChords(self, chords): scales = GetAllScales() possibleScales = ScaleList() for scale in scales: append = True for chord in chords: for tone in chord.tones: if not u.Contains(scale.tones, tone.GetName()): append = False if append == True: possibleScales.scales.append(scale) return possibleScales
def GetPretty(self): return self.baseTone.GetName( ) + " " + self.modeName + "\n" + "Tones: " + str(u.GetNames( self.tones)) + "\n" + "Chords: " + str(u.GetNames(self.chords))
def GetPretty(self): return self.GetName() + "\n Configuration: " + str(self.configuration) + "\n Tones: " + str(u.GetNames(self.tones))
def GetName(self): return self.baseTone.name + " " + u.GetKeyByValue(c.chordConfigurations, self.configuration)
def GetToneAbove(self, steps): tone = Tone() nr = self.nrInToneMap + steps nr = u.ClipToLength(u, nr, toneMap.__len__()) tone.CreateFromNumberInTonemap(nr) return tone