Last active
September 10, 2021 07:30
-
-
Save joshstovall/3f74a34a57b94f10a128b28cb13741da to your computer and use it in GitHub Desktop.
pythagorean.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pythagorean(e){ | |
var frequency = e; | |
var cents; | |
// multiply/divide frequency until between 440 & 880 | |
for (let step = 0; step < 100; step++) { | |
if (frequency < tuningHz) { frequency = frequency * 2; } | |
else if (frequency > tuningHz * 2) { frequency = frequency / 2; } | |
else { break; } | |
} | |
midPoints.some(function(v, i) { | |
if (frequency < v) { | |
// calulate cents | |
cents = 1200 * Math.log2(frequency/targetFrequencies[i]); | |
return frequency < v; | |
} | |
}); | |
return cents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment