def move_pitch(note: Pitch, pitch: Pitch) -> Note: while abs(note.midi - pitch.midi) > 6: dist = note.midi - pitch.midi if dist < 0: note = note.transpose(12) else: note = note.transpose(-12) return note
def freq_to_midi(freq): base_pitch = Pitch() current_interval = Interval( integer_interval_from(freq, base_pitch.frequency)) return base_pitch.transpose(current_interval).midi
def testLowNotes(self): dPitch = Pitch('D2') lowC = dPitch.transpose('M-23') self.assertEqual(lowC.name, 'C') self.assertEqual(lowC.octave, -1)