Connexion rapide:  

Forum: VirtualDJ Plugins

Sujet Any one good at maths?

Ce topic est ancien et peut contenir des informations obselètes ou incorrectes.

locodogPRO InfinityModeratorMember since 2013
I've flummoxed myself. I'm trying out stuff with tones [1/32 loops] and riding the pitch but I want to cheat the bpm so no matter the pitch the bpm stays constant
This is kind of weird it works when using dirty tricks but doesn't playing it straight
So I have a button I press once on track load
set 'base' `get_bpm`

and I have a dial
pitch & set 'test' `get_pitch_value & param_1_x & param_multiply 100` & set 'change' `param_multiply "get_var 'test'" "get_var 'base'"`

and also a button [pad 4] I press after tweaking the dial
get_var 'change' & param_cast & set_bpm

Like that it works, like this it also works [dirty trick]
pitch & set 'test' `get_pitch_value & param_1_x & param_multiply 100` & set 'change' `param_multiply "get_var 'test'" "get_var 'base'"` & pad 4

But add then together properly, no es bueno.
pitch & set 'test' `get_pitch_value & param_1_x & param_multiply 100` & set 'change' `param_multiply "get_var 'test'" "get_var 'base'"` & get_var 'change' & param_cast & set_bpm
 

Posté Mon 13 May 19 @ 9:58 am
NicotuxHome userMember since 2014
You are right, one affect the dial when the other affects directly the file which need to scan for bpm again
one sets the pitch to 'change' the other one sets the bpm for the pitch of the file to match 'base' at this pitch
 

Posté Mon 13 May 19 @ 9:26 pm
locodogPRO InfinityModeratorMember since 2013
Another one,
I've a var that cycles up and I want to translate that to count up like binary [0,1,2,4,8 etc]

if ( baseVar > 1 )
{ resultVar = 2^( baseVar - 1 ) }
else
{ resultVar = baseVar }

This works but I think I should be able to write this without the if : else
 

Posté Tue 28 May 19 @ 7:40 pm
locodogPRO InfinityModeratorMember since 2013
Nevermind I think I got it. Sometime I miss the obvious.

resultVar = 2^ (baseVar ) * 0.5,

edit nope, 2^0 == 1, might have to live with if :else for zero
 

Posté Tue 28 May 19 @ 11:43 pm
NicotuxHome userMember since 2014
with 0 you'll get resultVar = 0.5
if you are using integer it may be ok you can get 0 if result is truncated or may be wrong if result is rounded you'll get 1

resultVar = 2^ (baseVar ) * 0.5
resultVar = 2^ (baseVar ) / 2
the fastest equivalent is resultVar = 2^(baseVar -1) with the same possible issue depending on trunc or rounded result

because x*0.5 is the same as x/2
and x^-1 is 1/x
then (x^y)/x is x^(y-1 )
and thus (2^y)/2 is 2^(y-1 )

You may use logical shift on integer: resultVar = (1 shl baseVar) shr 1
which gives the true integer result you are looking for THIS IS RIGHT THE RESULT

because x*2 in binary is x*10b which is a shl : x << 1
and x/2 in binary is x 10b which is a shr : x >> 1
then 2^x is 1 << x

but not 1 shl (baseVar -1) because shift count have to be positive or null
 

Posté Wed 29 May 19 @ 12:51 am
locodogPRO InfinityModeratorMember since 2013
Thanks, I forgot I could param_cast 'int_trunc'
 

Posté Wed 29 May 19 @ 1:10 am


(Les anciens sujets et forums sont automatiquement fermés)