Skip to content

Commit

Permalink
Add midi_note_to_frequency_just_intonation
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed May 28, 2023
1 parent a0e19a2 commit d75b901
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions isobar/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ def midi_note_to_frequency(note):
return None
return 440.0 * pow(2, (note - 69.0) / 12)

def midi_note_to_frequency_just_intonation(note):
note_ratios = [1/1, 256/243, 9/8, 32/27, 81/64, 4/3, 729/512, 3/2, 128/81, 27/16, 16/9, 243/128]
octave = note // 12
octave_note = note % 12
octave_base_frequency = midi_note_to_frequency(octave * 12)
octave_note_frequency = octave_base_frequency * note_ratios[octave_note]
return octave_note_frequency

def midi_semitones_to_frequency_ratio(semitones):
return pow(2, semitones / 12.0)

Expand Down

0 comments on commit d75b901

Please sign in to comment.