Archive: Code trouble


7th October 2002 01:24 UTC

Code trouble
I've made a sort of animation where 9 points move around the screen by waiting for their current movement to finish, then waiting for a beat then commencing their next movement. I've attached the preset because it is kind of hard to explain. Anyway, my problem is that I want the points not to wait for the next beat but to wait 4 beats before they shuffle around again, I've tried coding this in varying ways but each time I have completely failed. The nearest I got is also attached, it seems to work fine for a while then seemingly at random the points suddenly jump to their next positions rather than smoothly moving to them. Once again it is sort of hard to describe so please look at the preset.

This problem has been bugging me all day now so I thought that maybe one of you could spot what I've done wrong. The code is all fairly simple so I've most likely made a tiny error somewhere and I just can't spot it. I can't see why the random jumping occurs at all.

In the presets I've used the convolution filter to make the points more visible, if you don't have it don't worry, it's not vitally important to it in anyway.

Thanks in advance.


7th October 2002 12:44 UTC

Ummh I am confused as why if you want it to move every 4 beats you also want the code to finished processing. I can understand for every beat but why for 4 beats? Surly this wil just slow things down and the veiwer will not notice any difference.

Or am I missunderstanding totally here?

I presume that every 4 beat you want all the dots to move?

I think that the 'waiting for the code to finsh' bit is confusing is processing then you do the counting. Maybe dunno..

MAke it simple first. Use 1 dot instead of 9. I picked dot 2.

ANd make the number of steps 2 instead of 8 and add them slowly.

I will see if I can get any more for you.


7th October 2002 13:45 UTC

OK looked into the beat stuff and getting the counter is easy.

I made a very simple counter by

init
bc=0; (that's Beat Counter)
mo=0; (that's MOvement)

per_frame
bc=if(b,bc+1,bc);
bc=if(equal(bc,8),0,bc);
mo=if(equal(bc,1),1,0);

per_pixel
x=0.2*mo;
y=0.2*mo;

(I know it can be made better with the 2 lines for bc but for the basis of this it is as soimple as possible)


Now this works fine.

But I don't know if I misunderstand the way AVS works or something but if you double up these scopes using the same variable the preset goes made but using new variables for bc and mo it works fine.

Anyone care to explain?

Anyway here are the presets one works I would expect (2 sets of different variables) the other does not (thw same variables).

There are 3 points 1 just is the beat (as I do not know of a monitor function/APE in AVS I cannot see what is going off)

The other 2 points move every 8th (i think) beat. In the 'broken' one it 'robs' the beat from the other scope it seems.

So it seems you have to use a seperate variable for each scope or am I missing something.


7th October 2002 15:38 UTC

It turns out that I has made an idiot simple mistake. The on beat code that reads bc=if(rate,bc,bc+1); should have been bc=if(rate,0,bc+1); .

D'oh! :igor:

Feel free to slap me for my stupidity.

I've attached the working version in case any one wants to steal the code and alter it to make their own moving points/objects 'animations'.

EDIT: The code can be cleaned up a bit, there is at least one redundant statement in there.

EDIT 2: Rovastar, I wanted to make them move every four beats because these points are going to be base points for reactive 3d objects, I just thought that it would be mega cool if they changed formation every now and again.


7th October 2002 16:12 UTC

*slap*


15th October 2002 08:15 UTC

*slaps Jheriko* :mad:
Even I have managed to do a counter (i used it on the multimovement dynamoves on generation x)

And i don't even know how to code :igor:



But im glad the problem is solved already :blah: :D :blah:


15th October 2002 10:06 UTC

jheriko, i used that fixed version of that preset and made it more disco, i did it just for fun, hop you like it


15th October 2002 10:18 UTC

Hehe.. cool mix Montana. That beaming light effect is really disco :)

You'll have to wait a few days to see what I ended up using the points for ;)


15th October 2002 11:55 UTC

oh, can i put my mix of the temp preset in my forthcoming pack, you will get full credit for the scopes


15th October 2002 12:01 UTC

Yeah, go for it. I'm glad to know that someone else found a good use for them. :)


17th October 2002 04:43 UTC

*slap*
damn you and your math/logic skills


:p


17th October 2002 07:56 UTC

If anyone is interested these points were used as the basis for my bluespectrum remix for the el-vis tribute pack.

http://www.deviantart.com/deviation/796550


21st October 2002 07:27 UTC

what about
misc -> Custom BPM?

If you don't want it to change the rest of your visualization, put it and the scopes in their own effect list.


21st October 2002 13:59 UTC

That wouldn't have worked because i needed to make the scopes finish their movements *then* wait for those beats. Using 'Custom BPM' would not wait 4 beats after the scopes have moved, but rather only give them one beat in the time that there would normally be 4, so if the scope took 4 beats to move they would constantly move, or if the took 2 then they would only wait 2.. etc, resulting in varying results for every track.


21st October 2002 15:43 UTC

Alternatively, you use something like this:
(tx/y = target point, px/y = current point)

onbeat:
foo=below(sqrt(sqr(tx-px)+sqr(ty-py)),.05);
tx=if(foo,new-point,tx);
ty=if(foo,new-point,ty);

This would make a point shift around onbeat as soon as they have nearly completed their movement.

Oh by the way, a shorter counter is:
bc = (bc+1)%8

:)


21st October 2002 15:50 UTC

Ignore my stupidity on the % issue, I realised that after I submitted that preset. :mad:

I like my current method of making them move around though, mainly because its easier for me to visualise in my head how it works.