Page 1 of 1

Posted: 07 Jun 2006, 11:16
by bsork
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

Posted: 07 Jun 2006, 13:22
by senso
schoolday knowledge has gone a long time ago....
Me too!

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.

Posted: 07 Jun 2006, 18:54
by laserbeak43
so you want to patch to adapt to the samples tempo? or the sample to adapt to the patches tempo?

Posted: 08 Jun 2006, 09:36
by bsork
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...

Posted: 08 Jun 2006, 10:03
by bsork
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...

Posted: 11 Jun 2006, 10:43
by senso
perfect,
it's the inverse of the first formula

Posted: 21 Mar 2014, 08:53
by niggles
:-)