com.perisic.function
Class AnyFunction

java.lang.Object
  extended by com.perisic.function.AnyFunction
Direct Known Subclasses:
LinCombOfFunctions, LinearFunction, NiceFunction

public abstract class AnyFunction
extends java.lang.Object

A "nice" function that is used as a basis for defining the pitch, instrument selection or velocity of a voice.

Nice means here roughly mostly continuous (only a small number of jumps) where the pieces are either constants or defined by cubic polynomials.

Copyright:(c) Marc Conrad, Tim French 2006; Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument. DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

Author:
Marc

Constructor Summary
AnyFunction()
           
 
Method Summary
 java.awt.image.BufferedImage addToImage(java.awt.image.BufferedImage img, java.awt.Color myColor)
          Add a graph of this method to the image img.
 java.awt.image.BufferedImage addToImage(java.awt.image.BufferedImage img, int RGBColour)
          Add a graph of this method to the image img.
abstract  double eval(double x)
          Evaluation of the function for a value x.
 java.awt.image.BufferedImage getImage(java.awt.Color c)
          Returns a graph of this method of the fixed size 150x100.
 java.awt.image.BufferedImage getImage(java.awt.Color c, boolean haveText, int width, int height)
          Returns a graph of this method of the fixed size 150x100.
static void main(java.lang.String[] args)
          Used for testing purpose only.
 double normalizeResult(double result)
          Forces a values larger than 1 or smaller than 0 between 0 and 1 so that continuous functions stay continuous.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnyFunction

public AnyFunction()
Method Detail

eval

public abstract double eval(double x)
Evaluation of the function for a value x.

Parameters:
x - The value against which the function is evaluated.
Returns:
f(x) where f is this object.

normalizeResult

public double normalizeResult(double result)
Forces a values larger than 1 or smaller than 0 between 0 and 1 so that continuous functions stay continuous.

Parameters:
result - the normalised result.
Returns:
the normalized value

addToImage

public java.awt.image.BufferedImage addToImage(java.awt.image.BufferedImage img,
                                               java.awt.Color myColor)
Add a graph of this method to the image img.

Parameters:
img - the original image.
myColor - The colour which is used to paint the graph.
Returns:
the parameter img (which is changed by this method).

addToImage

public java.awt.image.BufferedImage addToImage(java.awt.image.BufferedImage img,
                                               int RGBColour)
Add a graph of this method to the image img.

Parameters:
img - the original image.
RGBColour - The colour which is used to paint the graph.
Returns:
the parameter img (which is changed by this method).

getImage

public java.awt.image.BufferedImage getImage(java.awt.Color c)
Returns a graph of this method of the fixed size 150x100. For variable size use the method addToImage(BufferedImage img, Color c);

Parameters:
c - The colour which is used to paint the graph.
Returns:
the parameter img (which is changed by this method).

getImage

public java.awt.image.BufferedImage getImage(java.awt.Color c,
                                             boolean haveText,
                                             int width,
                                             int height)
Returns a graph of this method of the fixed size 150x100. For variable size use the method addToImage(BufferedImage img, Color c);

Parameters:
c - The colour which is used to paint the graph.
Returns:
the parameter img (which is changed by this method).

main

public static void main(java.lang.String[] args)
Used for testing purpose only. Visualizes 30 nice functions.

Parameters:
args - no parameters.