Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Well Tempered tuning #1

Open
lacojunior opened this issue May 15, 2013 · 0 comments
Open

enhancement: Well Tempered tuning #1

lacojunior opened this issue May 15, 2013 · 0 comments

Comments

@lacojunior
Copy link

function noteToFreq(stepsFromMiddleC) {
        //Thomas Young 1799 Well Temperament frequency table taken from http://www.math.uwaterloo.ca/~mrubinst/tuning/tuning.html
        thomasYoungWellTemperament = { table : {
            0:1, 
            1:1.055730636,
            2:1.119771437,
            3:1.187696971,
            4:1.253888072,
            5:1.334745462,
            6:1.407640848,
            7:1.496510232,
            8:1.583595961,
            9:1.675749414,
            10:1.781545449,
            11:1.878842233},
            positionInTable : function(stepsFromMiddleC) {
                return stepsFromMiddleC < 0 ? 12 - (-stepsFromMiddleC % 12) : stepsFromMiddleC % 12;
            },
            octaveFromMiddleC : function(stepsFromMiddleC) {
                return Math.floor(stepsFromMiddleC / 12);
            }
        };
        var stepsFromA440 = stepsFromMiddleC + 4;
        var freq = 440 * Math.pow(2, thomasYoungWellTemperament.octaveFromMiddleC(stepsFromA440) - 1 
            + thomasYoungWellTemperament.table[thomasYoungWellTemperament.positionInTable(stepsFromA440)]);
        return freq;
    } 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant