com.softsynth.jsyn.util
Class HarmonicTable

java.lang.Object
  extended by java.util.Observable
      extended by com.softsynth.jsyn.SynthObject
          extended by com.softsynth.jsyn.SynthTable
              extended by com.softsynth.jsyn.util.HarmonicTable

public class HarmonicTable
extends SynthTable

A table containing harmonics of a fundamental sine wave. This can be used to generate periodic waveforms using additive synthesis.


Field Summary
 short[] data
          Generated waveform will be placed in this array.
 
Constructor Summary
HarmonicTable(int numSamples, int numPartials)
           
 
Method Summary
 void build()
          Generate a waveform by adding sinewaves partials.
 void clear()
          Zero the ampltudes and the waveform.
 int getNumPartials()
           
 double getPartial(int index)
           
 void sawtooth()
          Set amplitudes for sawtooth waveform.
 void setPartial(int index, double amplitude)
          Specify the relative amplitude for a harmonic partial.
 void square()
          Set amplitudes for square waveform.
 void triangle()
          Set amplitudes for triangle waveform.
 
Methods inherited from class com.softsynth.jsyn.SynthTable
allocate, length, write, write, write, write, write, write
 
Methods inherited from class com.softsynth.jsyn.SynthObject
delete, deleteAll, enableDeletionByGarbageCollector, enableTracking, getPeer, getSynthContext, isTrackingEnabled, toString, track
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

public short[] data
Generated waveform will be placed in this array.

Constructor Detail

HarmonicTable

public HarmonicTable(int numSamples,
                     int numPartials)
              throws SynthException
Throws:
SynthException
Method Detail

setPartial

public void setPartial(int index,
                       double amplitude)
Specify the relative amplitude for a harmonic partial. Using index=0 controls the fundamentals amplitude. The resulting waveform is normalized so only the relative amplitudes matter.


getPartial

public double getPartial(int index)

getNumPartials

public int getNumPartials()

build

public void build()
Generate a waveform by adding sinewaves partials.


square

public void square()
Set amplitudes for square waveform. Then build waveform.


triangle

public void triangle()
Set amplitudes for triangle waveform. Then build waveform.


sawtooth

public void sawtooth()
Set amplitudes for sawtooth waveform. Then build waveform.


clear

public void clear()
Zero the ampltudes and the waveform.