transpose formula

Started by Zenon, May 01, 2010, 20:38:57

Previous topic - Next topic

Zenon

I have noticed that transpose value of a sample changes basing on samplerate;

What's the exact formula to find out the relative note having a certain samplerate (11025, 22100 etc. ) ?
Xrns2XMod converter
http://xrns2xmod.codeplex.com

Saga Musix

This should work in theory...

int f2t = (int) (1536.0 * (log((double)$Frequency/ 8363.0) / log(2.0)));
int transp = f2t >> 7;
int ftune = f2t & 0x7F; //0x7F == 111 1111
if (ftune > 80)
{
transp++;
ftune -= 128;
}
if (transp > 127) transp = 127;
if (transp < -127) transp = -127;
$RelativeTone = transp;
$FineTune = ftune;

Replace the "$" variables with your own names.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Zenon

Awesome! Works great!

Thanks a lot  :wink:
Xrns2XMod converter
http://xrns2xmod.codeplex.com