Old 12th October 2005, 06:06   #1
Sonic Ether
Junior Member
 
Join Date: Jul 2005
Location: Mesa, Arizona
Posts: 10
Help with minor code issue

Ok, I'm getting the whole DM thing down. Now, I can create decent DMs. But I do have one question. What would be a basic way to smooth movement? Because I've got alot of jerky presets and I would like to know if there is a way to smooth the movement. Can anyone help me?
Sonic Ether is offline   Reply With Quote
Old 12th October 2005, 11:44   #2
^..^
Major Dude
 
^..^'s Avatar
 
Join Date: Sep 2004
Location: There
Posts: 1,002
Send a message via ICQ to ^..^
There are many ways to make movements smoother. Let me suggest you two quite simple ways. Just try which one fits best to the kind of movement you use. (The beat code is just 'random' code i used in these examples and you can replace it with any kind of music-reaction you want).

code:
frame:
t=t*0.95+tb;
---------------------
beat:
tb=(rand(100)+1)*0.005


or this one:
code:
frame:
t=t+tb;
tb=tb*0.95;
---------------------
beat:
tb=(rand(100)+1)*0.005



Also it might be interesting for you to have a look into some AVS-tutorials and help-documents listed in this thread.

btw: Please post such questions in the AVS Troublshooting subforum to help keeping the forum tidy.

^..^ is offline   Reply With Quote
Old 12th October 2005, 16:40   #3
hboy
Senior Member
 
hboy's Avatar
 
Join Date: Dec 2003
Location: Hungary
Posts: 217
Send a message via AIM to hboy
you say that you can do decent DMs and then ask about smooth movements? wow.
hboy is offline   Reply With Quote
Old 12th October 2005, 16:50   #4
^..^
Major Dude
 
^..^'s Avatar
 
Join Date: Sep 2004
Location: There
Posts: 1,002
Send a message via ICQ to ^..^
Maybe to him "decent dm" means something else than to us! Perhaps every dm that is more complicated than the example ones are decent to him? But im just guessing...

^..^ is offline   Reply With Quote
Old 12th October 2005, 20:57   #5
StevenRoy
Senior Member
 
StevenRoy's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 129
Send a message via ICQ to StevenRoy Send a message via AIM to StevenRoy
Smooooth motion, the StevenRoy way

Here's the way I do it:

Suppose I had a variable "dx", which I want to set to a random value between -1 and 1 on each beat. The simplest way to do that, of course, is to put this in the Beat code:
code:
dx=(rand(201)-100)*.01
Now that's all well and good, but it does have that jerkiness problem. My favourite way to smooth out the motion is quite similar to what ^..^ described:
code:
Frame:
dx=dx*.9 + tdx*.1

Beat:
tdx=(rand(201)-100)*.01

This causes dx to slide towards tdx (I use the extra t to mean "target"), at a rate proportional to their difference. In other words, it starts out quickly and slows down as it nears its target. To adjust the speed of this transition, you can change the .9 and .1 coefficients to other values, such as .95 and .05, or even .99 and .01 to make it nice and slow. (These coefficient pairs should add up to 1; it's not necessary, but it makes it easier to know what you're getting.)

In most cases, this is pretty good... but every time tdx changes, dx starts homing towards it, and it's a sudden, jerky start. Surprisingly, the way to fix this start is simply to repeat the process; add another target variable and make that the target of our first target variable.

It ends up looking something like this:
code:
Frame:
dx=dx*.9 + tdx*.1;
tdx=tdx*.95 + ttdx*.05;

Beat:
ttdx=(rand(201)-100)*.01

Voila. Smooth motion. (Notice that I gave the tdx->ttdx motion different values to slow it down a little.)

Now, if you're really anal about code optimization, you may notice that ttdx is being multiplied my the same value once per frame, even though it doesn't change. This multiplication can be moved to the onbeat code for a very, very slight performance boost. (Most of the time, I don't bother.) The same goes for the tdx multiplication, for a similar reason. You can end up with code that looks like this:
code:
Frame:
dx=dx*.9 + tdx;
tdx=tdx*.95 + ttdx;

Beat:
ttdx=(rand(201)-100)*.00005

It's not uncommon for me to use code like this several times in a single Dynamic Movement.

Of course, it usually takes more than smooth motion to make a good AVS preset, but it usually helps.
StevenRoy is offline   Reply With Quote
Old 12th October 2005, 22:15   #6
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,082
Sonic Ether: Perhaps you could give us an example preset of what you exactly mean by decent DM's, and perhaps a better explanation of 'smooth movement', before everybody is getting all exited over perhaps the wrong thing.

Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 13th October 2005, 19:04   #7
hboy
Senior Member
 
hboy's Avatar
 
Join Date: Dec 2003
Location: Hungary
Posts: 217
Send a message via AIM to hboy
yup. by the way, my first dm was a smooth little x=x+0.05. yeah.
hboy is offline   Reply With Quote
Old 3rd November 2005, 05:52   #8
Sonic Ether
Junior Member
 
Join Date: Jul 2005
Location: Mesa, Arizona
Posts: 10
Haha, sorry for the late reply, I've been buisy lately. Ok, I'll send you an example, but I want it to be smooth... so check it out. I KNOW IT'S MESSY, I'M NOT PERFECT! Haha, I'm not so anal about clean code
Attached Files
File Type: zip flow-3.zip (628 Bytes, 531 views)
Sonic Ether is offline   Reply With Quote
Old 5th November 2005, 11:06   #9
Mr_Nudge
Major Dude
 
Mr_Nudge's Avatar
 
Join Date: Apr 2004
Location: melbourne, australia
Posts: 655
i haven't seen the preset..basically because my laptop can't run avs. but smooth movement can be made the way everyone so far has told you..so i might as well give you my version

frame-----
a=a*0.9+a1*1.1
beat------
a1=rand(100)*0.0001

that way 'a' will change values between 1 & -1 smoothly and won't stop instantly..it'll kind of 'slide' for a while and then stop slowly

Life's a game, break the rules
Click here
Mr_Nudge is offline   Reply With Quote
Old 9th November 2005, 20:59   #10
DummyDDD
Junior Member
 
Join Date: Dec 2004
Posts: 33
I think that the movement looks pretty smooth (and the preset look pretty nice too ), what you may think of as jerky movement may be caused by a low fps (or worse yet changeing fps), or by the "dark edges".

What i mean by dark edges is just the 4 spectrums at each side of the screen, which are transformed across the screen.
To prevent thoose edges you should reduce the edges by reducing the zooming of the movement. You also could add a virtual effect\AddBorders outside of the effect list (I know it's a crappy solution, but it's used quite often).

If you want to boost the fps of the preset you can set the first convolution filters scaling to 32 (because n^2 scalings are faster, 1, 2, 4, 8, 16...), this will affect the luminance some. You can also integrate the movement into the first dynamic movement, this will affect the luminance even more.

I've attached an altered version of the preset which should have less jerky movement.
Attached Files
File Type: zip flow-4.zip (614 Bytes, 453 views)
DummyDDD is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > AVS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump