def diminished7_tones(self): if "major" in self.name: diminished7_letters = [ self.root, tones.flatten(self.III), tones.flatten(self.V), tones.flatten(tones.flatten(self.VII)) ] elif "harmonic" in self.name: diminished7_letters = [ self.root, self.iii, tones.flatten(self.V), tones.flatten(self.vii) ] elif "minor" in self.name: diminished7_letters = [ self.root, self.iii, tones.flatten(self.V), tones.flatten(self.vii) ] else: raise ValueError( "Cannot provide diminished 7 tones for key {}".format( self.name)) return [t for t in tones.all_tones if letter(t) in diminished7_letters]
def bridge_chords(tone): self.set_key(letter(tone) + ' major') tones = self.arpeggio(tone, -8) return { 'treble': chords([subset(tones, 1, 4)], bridge_rhythm), 'bass': chords([subset(tones, 5, 8)], bridge_rhythm) }
def write_score(self): # The looped section programmatically builds a series of scales # Note that the bass clef is just a tansposition of the treble clef looped = {"treble": []} for start in self.scale('c`', 'c``'): looped["treble"] += self.scale(start, 8, 8) looped["bass"] = self.transpose(looped["treble"], -1, 'octave') # The smart section programmatically builds a series of scales in different keys # Note how we use list comprehension to avoid a for loop, and use step = 2 to play every other note in the treble clef start_notes = self.scale('c```', 'c``') smart = { "treble": [scale(start, -8, key=letter(start) + " major", dur=8, step=2) for start in start_notes], "bass": [scale(self.transpose(start, -1, 'octave'), -8, key=letter(start) + " major", dur=8) for start in start_notes] } self.score = join(looped, smart)
def create_chords(self): self.aI = self.arpeggio(self.key.root, 6) self.aiii = [ self.transpose(t, -1) if letter(t) == self.key.root else t for t in self.aI ] self.aiii7 = [ self.transpose(t, 1) if letter(t) == self.key.root else t for t in self.aI ] self.aii = self.transpose(self.aI, 1) self.aii7 = self.transpose(select(self.aii, 1), -1) + subset( self.aii, 2, 6) self.bI7 = self.arpeggio(self.transpose(self.key.root, -1, 'octave'), 4) + self.arpeggio7( self.transpose(self.key.root, 9), 4) self.biii = arpeggio(self.transpose(self.key.root, -8), 4, key=self.IIIt) self.biii += arpeggio(self.transpose(self.key.root, 9), 4, key=self.IIIt) self.biii7 = [ self.transpose(t, i) for t, i in zip(self.bI7, [1, 0, 0, 1, -1, 0, 0, 0]) ] self.bii7 = self.transpose(subset(self.bI7, 1, 4), 1) + self.transpose( subset(self.bI7, 5, 7), -1) + select(self.bI7, 8) self.bii7d5 = [ self.transpose(t, i, 'semitone') for t, i in zip(self.bii7, [0, 0, -1, 0, 0, 0, -1, 0]) ] self.diii = self.transpose( self.transpose(self.arpeggio(self.key.root, 3), 2), 1, 'octave') self.dI = [self.transpose(self.key.root, 2, 'octave')] self.dii = self.transpose( [self.key.root, self.transpose(self.IIt.v, -1, "semitone")], 2, 'octave') + [self.transpose(self.key.v, 2, 'octave')]
def tremble(tone): bass_tone = self.transpose(tone, -2, 'octave') start_grace = grace(notes([self.transpose(bass_tone, -1, 'semitone'), bass_tone, self.transpose(bass_tone, 2, 'semitone')], 32)) stop_grace = notes([self.transpose(bass_tone, -1, 'semitone'), bass_tone], 32) treble_chord = chord(arpeggio(tone, -4, key=letter(tone) + ' major'), 2) if tone == 'b`': add(treble_chord, 'a') return { 'treble': treble_chord, 'bass': start_grace + after_grace(note(bass_tone, 2, ornamentation='trill'), stop_grace) }
def dominant7_tones(self): if "major" in self.name: dominant7_letters = self.arpeggio_letters + [ tones.flatten(self.VII) ] elif "harmonic" in self.name: dominant7_letters = [ self.root, tones.sharpen(self.iii), self.V, tones.flatten(self.VII) ] elif "minor" in self.name: dominant7_letters = [ self.root, tones.sharpen(self.iii), self.V, self.VII ] else: raise ValueError( "Cannot provide dominant 7 tones for key {}".format(self.name)) return [t for t in tones.all_tones if letter(t) in dominant7_letters]
def scale_subset(self, positions): index_of_root = self.letters.index(self.root) custom_letters = [(self.letters * 2)[index_of_root + p - 1] for p in positions] return [t for t in self.all_tones if letter(t) in custom_letters]
def arpeggio_tones(self): return [ t for t in self.all_tones if letter(t) in self.arpeggio_letters ]
def tones(self): return [t for t in self.all_tones if letter(t) in self.letters]
def ascending_chromatic_tones(self): return [ t for t in tones.all_tones if letter(t) in self.ascending_chromatic_letters ]