def spell(self): major_root = self._notes[0].num() - scale_numbers[self._mode_num-1] if major_root < 1: major_root += 12 d = Note('F').distance(Note(major_root)) if d in range(3,6): self._notes = [i.to_sharp() for i in self._notes] elif d in range(9,12): self._notes = [i.to_flat() for i in self._notes] elif d in range(6,9): if self._notes[0].acc() == 'f': self._notes = [i.to_flat() for i in self._notes] else: self._notes = [i.to_sharp() for i in self._notes] elif d in range(0,3): for i in self._notes: if i.num() == 1: # C i.to_flat() elif i.num() == 5: # E i.to_sharp() elif i.num() == 12: # B i.to_sharp() else: raise ValueError('Unexpected transposition error in Scale.spell') return self
def spell(self): self.trspell() if self._sev_type[0]: base = sev_types[self._sev_type[0]][0] d = Note(base).distance(self.root()) if d in range(1, 6): respell = self._triad_type != self._sev_type[0] and self.root( ).acc() == 'f' if d in range(3, 6) and respell: self.root().to_sharp() self.spell() else: self.seventh().to_sharp() elif d in range(9, 12): self.seventh().to_flat() elif d in range(6, 9): if self.root().acc() == 'f': self.seventh().to_flat() else: self.seventh().to_sharp() elif d == 0: if base == 'F': self.seventh().to_sharp() else: self.seventh().to_flat() else: raise ValueError( f'Unexpected transposition error with d = {d}') return
def __init__(self, root_name, mode=1): self._mode_num = mode self._mode = modes[self._mode_num-1] root = Note(root_name) self._root_name = root.name() t = np.array(scale_numbers[self._mode_num-1:self._mode_num+6]) - scale_numbers[self._mode_num-1] self._notes = [root.transpose(i.item()) for i in t] self.spell() return
def trspell(self): base = triad_types[self._triad_type][0] ignore_fifths = False if base == 'd': ignore_fifths = True base = 'A' d = Note(base).distance(self.root()) if d in range(1,5): self.root().to_sharp() self.third().to_sharp() if not ignore_fifths: self.fifth().to_sharp() elif d in range(8,12): self.root().to_flat() self.third().to_flat() if not ignore_fifths: self.fifth().to_flat() elif d in range(5,8): if self.root().acc() == 'f': self.root().to_flat() self.third().to_flat() if not ignore_fifths: self.fifth().to_flat() else: self.root().to_sharp() self.third().to_sharp() if not ignore_fifths: self.fifth().to_sharp() elif d == 0: if base == 'C': self.root().to_flat() self.third().to_sharp() else: self.third().to_flat() if not ignore_fifths: self.fifth().to_sharp() else: raise ValueError(f'Unexpected transposition error with d = {d}') if ignore_fifths: if d in range(5,8): self.root().to_flat() self.third().to_flat() self.fifth().to_flat() else: self.fifth().to_flat() return
def seventh(self, seventh=None): if seventh: self._seventh = Note(seventh) return self._seventh
def fifth(self, fifth = None): if fifth: self._fifth = Note(fifth) return self._fifth
def third(self, third = None): if third: self._third = Note(third) return self._third
def root(self, root = None): if root: self._root = Note(root) return self._root