Old 16th April 2011, 16:41   #1
LlamaLlamaLamp
Junior Member
 
Join Date: Feb 2011
Location: Australia
Posts: 40
Dampening/limiting bass_att, bass, etc.

Hey guys,

I suppose this is kind of related to presets....

So I run a lot of sprites that use the bass_att variable. In most cases it works great but in some cases it can be too erratic. The code usually resembles:
code:
new_size=image1 * bass_att;
sx=new_size;
sy=new_size;



I'm looking for two things if its possible:

1. An equation or code to dampen the response of bass or bass_att. I know bass_att is supposed to be an average, but it'd be great if I could take it further. I was possibly thinking creating three variables, every frame one of the variables would get the bass_att value. Then the three would be averaged and use that value instead? Is that even possible in MilkDrop? Or more importantly, is that even a valid solution?

2. An equation or code to limit the max an min sizes that the sprite can reach when using the bass_att or bass variables. So at the moment the sprites can go really, really small or really, really big sometimes. Itd be great to give them a limit of some sort....an IF statement each frame testing the current size or output from bass_att? Ignore if value is too low or high?

Thanks heaps!
LlamaLlamaLamp is offline   Reply With Quote
Old 16th April 2011, 17:23   #2
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 859
That's easy

1. To dampen the bass response, use

dec = pow(0.5,30/fps); //fps independant decay rate
mybass = dec*mybass + (1-dec)*bass_att; //mybass is the dampened bass

The factor 0.5 determines the rate: 0 is no damping, 0.9 is very strongly dampened. Keep it below 1.

2. To limit a variable, use either
mybass = min(1, mybass); // min returns the smaller one of the arguments

Or
mybass = pow(mybass, k); //where k is below 1; not a limiter but similar to soft clipping

or also
mybass = log(mybass+1);
Nitorami is offline   Reply With Quote
Old 18th April 2011, 07:22   #3
LlamaLlamaLamp
Junior Member
 
Join Date: Feb 2011
Location: Australia
Posts: 40
Oh my god!!!

I'm talking about you, you are incredible! Those solutions were exactly what I was looking for. I'll do some reading about what those mathematical functions actually do because I'm sure it will help me in the future.

While I've got your attention: well done on every single preset you've made. Seriously. All of them are incredible and they never cease to amaze me or anyone else that sees them. They are incredibly impressive especially when I realise that it's all maths. You are a freaking genius. It boggles my mind that you can come up with equations that can make such complicated shapes. Even better is that you don't stop there! You've pushed MilkDrop to the limit (well actually I hope you haven't because I will shit my pants if you release even better stuff) graphically. The graphics in your presets always look amazing. I particularly love how some of them interact with sprites really well, push ax and no religion come to mind straight away.

Thank you for the answers and thank you for all of your presets! Keep up the good work

edit: lol, I seem to have forgotten about pow from my Java days. So now I just have to understand logarithms

Last edited by LlamaLlamaLamp; 18th April 2011 at 09:27.
LlamaLlamaLamp is offline   Reply With Quote
Old 18th April 2011, 19:12   #4
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 859
Well thank you. Here's a preview... my problem is that it uses an aerial of a city as background. For develompent purposes I took a low quality preview image from gettyimages with their logo on, but I don't think I can put it on the forum for public use, they still seem to put a ban even on their previews. I would make a drawing if I were an artist, and painting would not bore me to death.
Attached Thumbnails
Click image for larger version

Name:	preview.jpg
Views:	306
Size:	122.5 KB
ID:	48726  
Nitorami is offline   Reply With Quote
Old 19th April 2011, 23:27   #5
Amandio C
Senior Member
 
Join Date: Dec 2008
Posts: 400
You can also wrap x,y to the [0,1] interval with
x-=int(x); y-=int(y);
This eliminates the integer part, which is useful when the graph travels to distant places.
Amandio C is offline   Reply With Quote
Old 23rd April 2011, 09:35   #6
LlamaLlamaLamp
Junior Member
 
Join Date: Feb 2011
Location: Australia
Posts: 40
@nitorami - Is it possible to contact the author to get permission to use it? Or am I misunderstanding the problem? It looks freaking incredible though!

@amandio - ??? So x is equal to the integer of itself then subtract 1? Does '-=' subtract 1 or itself? Does the subtraction occur before x is used in the equation or after? So this equation basically stops anything from moving past the edges of the screen (between 0 and 1)?
LlamaLlamaLamp is offline   Reply With Quote
Old 23rd April 2011, 10:27   #7
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 859
They charge licence fees for commercial use of their photographs and also restrict the use of the preview; I just don't want to instigate any legal crap about royalties. Will find another way.
Once I'm here I'll answer the question for Amandio C:
x -= a; is standard C++ code (I think) and it means the same as x = x-a; you can similarly use +=, *=, and /=.
Yes, Amandios proposal is to subtract the integer part of x. For instance, say x = 2.77, then x - int(x) = 2.77 - 2 = 0.77. Be aware that when x goes from 0.99 to 1.01, your sprite will jump from 0.99 to 0.01.

Another "wrap around" function would be the sine or cosine, e.g. x = 0.5 + 0.5*sin(a*x).
Nitorami is offline   Reply With Quote
Old 25th April 2011, 02:41   #8
dasraiser
Junior Member
 
Join Date: Oct 2009
Posts: 13
also for wrap you could use
x=frac(x)
i use sin(frac(a*x)*M_PI*0.5) as i dont need to 0.5+0.5*..., also comes in handy for colour cycling like rgb=sin(frac(rgb*a+b)*M_PI*0.5) or soft colour ramp rgb=sin(rgb*M_PI*0.5)
dasraiser is offline   Reply With Quote
Old 25th April 2011, 20:29   #9
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 859
The compiler, except for the shader sections, does not know frac(x), you need to write it as x - int(x).
Nitorami is offline   Reply With Quote
Old 26th April 2011, 00:32   #10
dasraiser
Junior Member
 
Join Date: Oct 2009
Posts: 13
doh true lol

so outside the shaders its sin( ((x-int(x))*freq+phase) *M_PI*0.5)

do you know if the compiler takes M_PI*0.5 and optimizes it to a single constant?
dasraiser is offline   Reply With Quote
Old 30th April 2011, 10:10   #11
LlamaLlamaLamp
Junior Member
 
Join Date: Feb 2011
Location: Australia
Posts: 40
Ahhh I didn't realise wrap was a MD variable, however the way I'm interpreting what you guys are saying is to not use that variable (as the MD docs indicate its essentially boolean) but to use your equations in the x and y code? Won't that move the sprite location instead of wraping it?
LlamaLlamaLamp is offline   Reply With Quote
Old 4th May 2011, 22:47   #12
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 859
@dasraiser: The HLSL shader compiler is extremely efficient and will quite probably optimize M_PI*0.5 to a single constant. Outside the shaders, i.e. in the per frame, wave and shapes code, there is no optimisation.

@LlamaLlamaLamp: wrap ?
Nitorami is offline   Reply With Quote
Old 5th May 2011, 10:59   #13
LlamaLlamaLamp
Junior Member
 
Join Date: Feb 2011
Location: Australia
Posts: 40
Quote:
Originally Posted by Nitorami View Post
@LlamaLlamaLamp: wrap ?
Quote:
Originally Posted by dasraiser View Post
also for wrap you could use .....
Quote:
Originally Posted by Amandio C View Post
You can also wrap x,y to the ......
Quote:
Originally Posted by Nitorami View Post
Another "wrap around" function .....
Quote:
Originally Posted by MilkDrop 2 Docs (MilkDrop_preset_authoring.html)
wrap yes 0/1 sets whether or not screen elements can drift off of one side and onto the other
...lol, ok I have no idea to be honest. You lost me in this thread before I even created the thread. Now I'm just quoting smart people to distract and confuse you.

By the way, which one of you was responsible for this!?!
Attached Thumbnails
Click image for larger version

Name:	753d16ebb48b81c03f51e9a55429bf5c.jpg
Views:	174
Size:	58.7 KB
ID:	48806  
LlamaLlamaLamp is offline   Reply With Quote
Old 7th May 2011, 15:52   #14
Flexi
wellspring of milk
Major Dude
 
Flexi's Avatar
 
Join Date: Apr 2007
Location: 54.089866,12.11168,18.75
Posts: 2,058
Send a message via ICQ to Flexi
in school that would have been 1 point short of the correct answer
whoever was responsible for this has forgotten to add a constant "+ c "
Flexi is offline   Reply With Quote
Old 7th May 2011, 21:16   #15
Amandio C
Senior Member
 
Join Date: Dec 2008
Posts: 400
Another way of "wrapping" is by reflection on the borders. We can use these expressions, where x1 and y1 must be positive. To respect the condition we add a constant to x1 and y1.

x= (int(x1)-x1+x1%2)*pow(-1,1+int(x1));
y= (int(y1)-y1+y1%2)*pow(-1,1+int(y1));
Attached Files
File Type: zip amandio c - tendrils reflected.zip (3.9 KB, 150 views)
Amandio C is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > MilkDrop > MilkDrop Presets

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