Welcome to %s forums

BrainModular Users Forum

Login Register

Converting pitch to time ratio.

I need help on a Patch
Post Reply
bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 07 Jun 2006, 11:16

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
Bjørn S

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 07 Jun 2006, 13:22

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.

laserbeak43
Member
Posts: 65
Contact:

Unread post by laserbeak43 » 07 Jun 2006, 18:54

so you want to patch to adapt to the samples tempo? or the sample to adapt to the patches tempo?

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 08 Jun 2006, 09:36

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...
Bjørn S

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 08 Jun 2006, 10:03

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...
Bjørn S

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 11 Jun 2006, 10:43

perfect,
it's the inverse of the first formula

niggles
Member
Posts: 32
Location: Melbourne Australia
Contact:

Unread post by niggles » 21 Mar 2014, 08:53

:-)
Digital Director & Programmer by Day | Musician By Night
iMac Core I7 | Usine | Logic | Leap Motion (loving it)
http://www.tribe404.com

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 85 guests