def flatten(n): note_iterator = iterate_notes(octave=0) prev = next(note_iterator) for curr in note_iterator: if curr.name == n.name and curr.octave == n.octave: return prev prev = curr
def add_interval(n, i): note_iterator = iterate_notes(start=n.name, octave=n.octave) accum = [next(note_iterator) for _ in range(i.halfsteps)] if not any(accum): return n return accum[-1]
def __init__(self, chord, root='C', octave=4, role=None, symbol=None): self.chord = chord self.root = root self.inversion = 0 self.role = role self.symbol = symbol notes = iterate_notes(start=root, octave=octave) self.notes = [] # root is always there self.notes.append(get_note(root, octave=octave)) for interval in self.chord.intervals: note_iterator = iterate_notes(start=root, octave=octave) # advance iterator accum = [ next(note_iterator) for _ in range(interval.halfsteps) ] if not any(accum): continue self.notes.append(accum[-1])
def __init__(self, mode, root='C', octave=4): self.mode = mode self.notes = [] # root is always there self.notes.append(get_note(root, octave=octave)) for interval_name in self.mode.interval_pattern: note_iterator = iterate_notes(start=root, octave=4) interval = get_interval(interval_name) # advance iterator accum = [ next(note_iterator) for _ in range(interval.halfsteps) ] if not any(accum): continue self.notes.append(accum[-1])
def sharpen(n): return next(iterate_notes(start=n.name, octave=n.octave))