Lace
Reaction score
0

Profile posts Postings Media Albums About

  • In other news, I just now realized that it would be a lot easier, when making those block diagrams, to draw the lines BEFORE drawing the blocks, so I don't have to draw pixel perfect lines.
    If the signal input had been something other than 0, the output would have asymptotically approached that value instead.
    Then, the line "value+=ctrl*(input-value);" is executed.

    Since input is always 0, this can be simplified to "value-=ctrl*value;"

    This can be further simplified to "value*=1-ctrl;"

    Since ctrl is always .0001, this can be fully simplified to "value*=.9999;"

    So we can see that value will gradually exponentially decay down to zero.
    First, the number 1 is sent to the constructor, so value starts of as 1.

    During each sample frame, the Smoother's recalculate() method is called.
    In this diagram, the 0 is the signal and the .0001 is the controller.

    Notice the 1 in parenthesis on the Smoother block. This is the value that is sent to the Smoother's constructor.
    Q0qWk.png
    My original intent in making this device was to allow for easy calculation of exponential decay without the need for an expensive call to Math.pow().
    If the controller value is 1, no smoothing is done, and the output is exactly the signal input.

    If the controller value is 0, complete smoothing is done, which actually causes the output to be a constant value.

    As neither of these extremes are particularly useful, usually values between 0 and 1 are used.
    Let's look at what it does.

    It takes two inputs: a signal and a controller. The controller is a value from 0 to 1, which indicates how much "smoothing" to do to the signal.
    Code:
    class Smoother extends VolatileDevice{
    	private Device signal,controller;
    	private double value;
    	Smoother(double v){value=v;}
    	protected void prepareSources(){signal.prepare();controller.prepare();}
    	protected long recalculate(){
    		double ctrl=controller.getValue();
    		double input=signal.getValue();
    		value+=ctrl*(input-value);
    		return value;
    	}
    }
    Weird, I thought I asked you "Well, what's almost four, then?" but it seems I didn't.

    Anyway, postathon will continue soon.
    4.4.0 if memory serves; any of them should work though. 4.2 is missing a particular function I used for reading mouse position or whatever.

    Also I'm relegated to the 3ds for my internetting again temporarily.

    The desktop is available for programming on which is how I will probably spend the next few days.
  • Loading…
  • Loading…
  • Loading…
  • Loading…
Back
Top