com.frinika.contrib.boblang
Class WaveSupport

java.lang.Object
  extended by com.frinika.contrib.boblang.WaveSupport

public class WaveSupport
extends java.lang.Object

Support methods for creating PCM wave forms


Field Summary
static double MAX_AMPLITUDE
           
static int MAX_GRAPH_HANDLE
           
static int PROP_COPY
           
static int PROP_GLIDE
           
static int PROP_ROTATE
           
 
Constructor Summary
WaveSupport()
           
 
Method Summary
static void addGraph(int handle, java.awt.Color inColour, int[] inArray, int inElements)
          Method to add a further plot to an existing graph.
static void addGraph(int handle, java.awt.Color inColour, int[] inArray, int inFirst, int inLast)
          Method to add an array subset as a further plot to an existing graph.
static int[] changeWaveLength(int[] inWave, int newWaveLength)
          Method to change the wavelength waveform using linear interpolation.
static int[] filter(int[] halfWave, int filterWidth, int option)
          Method to apply a rectangular filter to a half wave and return the resulting filtered output.
static int[] increasingFilter(int[] halfWave, int filterWidth, int filterIncr, int desiredSize, int option)
          Method to apply an increasing filter across a waveform.
static double localCosine(double degrees)
          Local version of cosine method (with parameter in degrees)
static double localSine(double degrees)
          Local version of sine method (with parameter in degrees)
static void plotFourier(int handle, double[] inArray, int fourierSamples, int sampleRate, int inElements)
          Method to plot the data in as a FFT.
static void plotGraph(int handle, java.lang.String inTitle, java.lang.String inSubTitle, java.lang.String inXTitle, java.lang.String inYTitle, int[] inArray, int inElements)
          Method to plot an array as a graph.
static void plotGraph(int handle, java.lang.String inTitle, java.lang.String inSubTitle, java.lang.String inXTitle, java.lang.String inYTitle, int[] inArray, int inFirst, int inLast)
          Method to plot a section of an array as a graph.
static int[] propagate(int[] halfWave, int desiredSize, int option)
          Method to propagate a waveform to fill a complete array.
static int[] rescale(int[] waveform)
          Rescale the wave form so it uses (most of) the full dynamic range.
static int[] rescale(int[] waveform, double amplitude)
          Rescale the wave form so it uses the dynamic range specified by the given amplitude.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_COPY

public static final int PROP_COPY
See Also:
Constant Field Values

PROP_GLIDE

public static final int PROP_GLIDE
See Also:
Constant Field Values

PROP_ROTATE

public static final int PROP_ROTATE
See Also:
Constant Field Values

MAX_AMPLITUDE

public static final double MAX_AMPLITUDE
See Also:
Constant Field Values

MAX_GRAPH_HANDLE

public static final int MAX_GRAPH_HANDLE
See Also:
Constant Field Values
Constructor Detail

WaveSupport

public WaveSupport()
Method Detail

rescale

public static int[] rescale(int[] waveform,
                            double amplitude)
Rescale the wave form so it uses the dynamic range specified by the given amplitude.

Parameters:
waveform - - array containing the waveform to be rescaled
amplitude - - amplitude of the rescaled waveform

rescale

public static int[] rescale(int[] waveform)
Rescale the wave form so it uses (most of) the full dynamic range.

Parameters:
waveform - - array containing the waveform to be rescaled

propagate

public static int[] propagate(int[] halfWave,
                              int desiredSize,
                              int option)
Method to propagate a waveform to fill a complete array. It uses the possible propagation options.

Parameters:
halfWave - - an array containing a half wave
desiredSize - - the number of samples in the output array
option - - the propagation option

filter

public static int[] filter(int[] halfWave,
                           int filterWidth,
                           int option)
Method to apply a rectangular filter to a half wave and return the resulting filtered output. The method needs to know how the half wave will be propagated, hence the option parameter


increasingFilter

public static int[] increasingFilter(int[] halfWave,
                                     int filterWidth,
                                     int filterIncr,
                                     int desiredSize,
                                     int option)
Method to apply an increasing filter across a waveform.

Parameters:
halfWave - - an array containing a half wave
filterWidth - - the initial filterWidth
filterIncr - - number of samples at which filter increments
desiredSize - - the number of samples in the output array
option - - the propagation option

changeWaveLength

public static int[] changeWaveLength(int[] inWave,
                                     int newWaveLength)
Method to change the wavelength waveform using linear interpolation. The input wave is assumed to be a single cycle.


plotGraph

public static void plotGraph(int handle,
                             java.lang.String inTitle,
                             java.lang.String inSubTitle,
                             java.lang.String inXTitle,
                             java.lang.String inYTitle,
                             int[] inArray,
                             int inElements)
Method to plot an array as a graph.

Parameters:
handle - - graph window to create or re-use
inTitle - - The overall graph title
inXTitle - - X axis title
inYTitle - - Y axis title
inArray - - array to be plotted
inElements - - number of elements to plot

plotGraph

public static void plotGraph(int handle,
                             java.lang.String inTitle,
                             java.lang.String inSubTitle,
                             java.lang.String inXTitle,
                             java.lang.String inYTitle,
                             int[] inArray,
                             int inFirst,
                             int inLast)
Method to plot a section of an array as a graph.

Parameters:
handle - - graph window to create or re-use
inTitle - - The overall graph title
inXTitle - - X axis title
inYTitle - - Y axis title
inArray - - array to be plotted
inFirst - - first element to plot
inLast - - last element to plot

addGraph

public static void addGraph(int handle,
                            java.awt.Color inColour,
                            int[] inArray,
                            int inElements)
Method to add a further plot to an existing graph.

Parameters:
handle - - graph window to create or re-use
inArray - - array to be plotted
inElements - - number of elements to plot

addGraph

public static void addGraph(int handle,
                            java.awt.Color inColour,
                            int[] inArray,
                            int inFirst,
                            int inLast)
Method to add an array subset as a further plot to an existing graph.

Parameters:
handle - - graph window to create or re-use
inArray - - array to be plotted
inElements - - number of elements to plot

plotFourier

public static void plotFourier(int handle,
                               double[] inArray,
                               int fourierSamples,
                               int sampleRate,
                               int inElements)
Method to plot the data in as a FFT. The x co-ordinates are frequency bins which are converted to the appropriate frequencies before being plotted

Parameters:
handle - - graph window to create or re-use
inArray - - output from FFT
fourierSamples - - number of samples in FFT
sampleRate - - sample rate in samples/sec
inElements - - number of elements to plot

localSine

public static final double localSine(double degrees)
Local version of sine method (with parameter in degrees)


localCosine

public static final double localCosine(double degrees)
Local version of cosine method (with parameter in degrees)