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

Pitch Factor ? #25

Open
roxteddy opened this issue May 8, 2023 · 4 comments
Open

Pitch Factor ? #25

roxteddy opened this issue May 8, 2023 · 4 comments

Comments

@roxteddy
Copy link

roxteddy commented May 8, 2023

Hello there !

Your lib looks like what I need but I can't see any documentation.
Reading your sources, I can pretty much get how to use it but I'm wondering :

what is the relation between pitch factor and tones/octaves ?
I think climbing an octave multiplies frequency by 2... does that mean I have to set the pitch factor to 2 ? or 0.5 to go down an octave..

Thanks for your help ^^

@olvb
Copy link
Owner

olvb commented May 10, 2023

Hi! You are correct, going up an octave means multiply the frequency by 2 and going down an octave by 0.5

@roxteddy
Copy link
Author

Many thanks for your answer @olvb ^^

@jeff-shell
Copy link

Just got into this, it's great! yeah if you're working with music and trying to transpose, it's a bit difficult because the relationship is nonlinear. here's what i believe is the relationship after a quick regression. semitones correspond to the related pitch factor.

const toneFactors = { "-12": 0.5, "-11": 0.5226, "-10": 0.5486, "-9": 0.5781, "-8": 0.6111, "-7": 0.6476, "-6": 0.6875, "-5": 0.7309, "-4": 0.7778, "-3": 0.8281, "-2": 0.8819, "-1": 0.9392, "0": 1.0, "1": 1.0642, "2": 1.1319, "3": 1.2031, "4": 1.2778, "5": 1.3559, "6": 1.4375, "7": 1.5226, "8": 1.6111, "9": 1.7031, "10": 1.7986, "11": 1.8976, "12": 2.0 };

@marcelblum
Copy link

It can be computed, a mathematician figured it out centuries ago I forget who, has to do with Pythagorean commas etc etc:

function semitonesToSpeed(semitones) {
	return Math.pow(2, (semitones/12));
}

function speedToSemitones(playbackRate) {
	return Math.log(playbackRate/1)/0.05776227;
}

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

4 participants