コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
ファイル: test_pitch.py プロジェクト: cuthbertLab/music21
 def testLowNotes(self):
     dPitch = Pitch('D2')
     lowC = dPitch.transpose('M-23')
     self.assertEqual(lowC.name, 'C')
     self.assertEqual(lowC.octave, -1)