Converting pitch to time ratio.
Forgive me for being ignorant (and maybe the heading is misleading as well?)...
I've been messing around with the Kaos Player, and trying to find different ways of adding functionality to that concept. Yesterday I patched up modules so that the length of the loop would set the synchro tempo, with a list to choose whether the loop length should represent a cycle, a bar, 1/4, 1/8 or 1/16. I also managed to take into account octave shifts, so that if the sampler is playing at eg +12 semitones the time is halfed.
What I would like help with, is the patching (and math) required to use semitones instead of whole octaves when recalculating the length in milliseconds of the loop.
I know I have to use logarithms in one way or another, but must admit that most of that schoolday knowledge has gone a long time ago....
Bj?rn S
I've been messing around with the Kaos Player, and trying to find different ways of adding functionality to that concept. Yesterday I patched up modules so that the length of the loop would set the synchro tempo, with a list to choose whether the loop length should represent a cycle, a bar, 1/4, 1/8 or 1/16. I also managed to take into account octave shifts, so that if the sampler is playing at eg +12 semitones the time is halfed.
What I would like help with, is the patching (and math) required to use semitones instead of whole octaves when recalculating the length in milliseconds of the loop.
I know I have to use logarithms in one way or another, but must admit that most of that schoolday knowledge has gone a long time ago....
Bj?rn S
Bjørn S
Me too!schoolday knowledge has gone a long time ago....
I think that the question could be asked like:
I have a sample with a length (let's say length_ini);
What pitch should I play this sample to fit to another length, for example the cycle length (let's say length_final).
The pitch can be calculated with:
Pitch = 12*LN(Length_ini/length_final)/LN(2)
LN=Logarithm
You can use the Math/Trunc module to get a rounded pitch if you need it.
In the User Library you can find a patch called "Sampler Adapt Pitch" witch does this kind of stuff.
Olivier Sens
www.brainmodular.com
www.brainmodular.com
-
laserbeak43
- Member
- Posts: 65
- Contact:
so you want to patch to adapt to the samples tempo? or the sample to adapt to the patches tempo?
I obviously haven't explained this very good - let me try again:
I'm mapping loop length (in ms) to tempo - that in itself is quite simple. If I want the loop to be for instance a quarter note that would be:
60000 / loop_length = tempo
60000 / 500 = 120
But when the sampler is not playing at original pitch, I need to calculate the new loop length. At whole octaves up or down, the equation can be made quite simple:
original_length / 2^octave_shift = shifted_length
2 octaves down: 500 / 2^-2 = 2000
2 octaves up: 500 / 2^+2 = 125
But for other pitch values I don't understand how to calculate the new loop length...
I'm mapping loop length (in ms) to tempo - that in itself is quite simple. If I want the loop to be for instance a quarter note that would be:
60000 / loop_length = tempo
60000 / 500 = 120
But when the sampler is not playing at original pitch, I need to calculate the new loop length. At whole octaves up or down, the equation can be made quite simple:
original_length / 2^octave_shift = shifted_length
2 octaves down: 500 / 2^-2 = 2000
2 octaves up: 500 / 2^+2 = 125
But for other pitch values I don't understand how to calculate the new loop length...
Bjørn S
Hello again, I think I just found it out:
original_length / 2^(pitch/12) = shifted_length
A fifth up:
300 / 2^(7/12) = 200.225978126....
A perfect fifth up (I used Olivier's example):
300 / 2^(7.01955000865387/12) = 200
Please correct me if I'm wrong...
original_length / 2^(pitch/12) = shifted_length
A fifth up:
300 / 2^(7/12) = 200.225978126....
A perfect fifth up (I used Olivier's example):
300 / 2^(7.01955000865387/12) = 200
Please correct me if I'm wrong...
Bjørn S
perfect,
it's the inverse of the first formula
it's the inverse of the first formula
Olivier Sens
www.brainmodular.com
www.brainmodular.com
Digital Director & Programmer by Day | Musician By Night
iMac Core I7 | Usine | Logic | Leap Motion (loving it)
http://www.tribe404.com
iMac Core I7 | Usine | Logic | Leap Motion (loving it)
http://www.tribe404.com
Who is online
Users browsing this forum: Bing [Bot] and 85 guests
