com.softsynth.jsyn
Class SynthTable

java.lang.Object
  extended by java.util.Observable
      extended by com.softsynth.jsyn.SynthObject
          extended by com.softsynth.jsyn.SynthTable
Direct Known Subclasses:
HarmonicTable

public class SynthTable
extends SynthObject

The SynthTable class is a container for digital audio data. The actual data may need to reside in memory that is accessible to DMA or to a DSP so we cannot assume that it is in main memory. We also need to maintain cache coherence if the data is going to be read or written by hardware other than the CPU. For this reason, SynthTable cannot use memory allocated by, or accessable to, the application. SynthTables differ from Samples in that SynthTables can be read via random access, while Samples can only be read sequentially. Thus tables can be used to implement function lookup and wave shaping, and also can be used with oscillators that have negative or very high frequencies. Samples are read by SynthUnits that are controlled by "Rate" ports. SynthTables are read by SynthUnits that are controlled by "Frequency" ports When using a hardware accelerator, SynthSample and SynthTable data may reside in different memories.

Version:
JSyn Version 005
Author:
(C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved
See Also:
SynthSample

Constructor Summary
SynthTable()
           
SynthTable(double[] data)
           
SynthTable(int numFrames)
           
SynthTable(SynthContext synthContext)
          Create an empty table.
SynthTable(SynthContext synthContext, double[] data)
          Create a monophonic SynthTable containing this double array.
SynthTable(SynthContext synthContext, int numFrames)
          Create a monophonic SynthTable with the specified number of frames.
 
Method Summary
 void allocate(int numFrames)
           
 int length()
           
 void write(double[] data)
           
 void write(int startFrame, double[] data, int startIndex, int numDoubles)
           
 void write(int startFrame, int partNum, double[] data, int startIndex, int numDoubles)
          Write data from an array of doubles to the Tables internal storage area.
 void write(int startFrame, int partNum, short[] data, int startIndex, int numShorts)
          Write data from an array of shorts to the Tables internal storage area.
 void write(int startFrame, short[] data, int startIndex, int numShorts)
           
 void write(short[] data)
           
 
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
 

Constructor Detail

SynthTable

public SynthTable(SynthContext synthContext)
Create an empty table. You must call allocate() before using the table.


SynthTable

public SynthTable()

SynthTable

public SynthTable(SynthContext synthContext,
                  int numFrames)
           throws SynthException
Create a monophonic SynthTable with the specified number of frames.

Parameters:
numFrames - Number of sample frames to allocate.
Throws:
SynthException - If there is insufficient memory.

SynthTable

public SynthTable(int numFrames)
           throws SynthException
Throws:
SynthException

SynthTable

public SynthTable(SynthContext synthContext,
                  double[] data)
           throws SynthException
Create a monophonic SynthTable containing this double array.

Parameters:
data - data to fill table.
Throws:
SynthException - If there is insufficient memory.

SynthTable

public SynthTable(double[] data)
           throws SynthException
Throws:
SynthException
Method Detail

allocate

public void allocate(int numFrames)
              throws SynthException
Throws:
SynthException - If the memory allocation fails.

write

public void write(int startFrame,
                  int partNum,
                  short[] data,
                  int startIndex,
                  int numShorts)
           throws SynthException

Write data from an array of shorts to the Tables internal storage area. The internal storage may be in main memory or it could be located on a sound card and only accessable by DMA. The 16 bit data will be scaled to -1.0 to +1.0 internally using N/32768.

Throws:
SynthException - If the data will not fit in the table.

write

public void write(int startFrame,
                  short[] data,
                  int startIndex,
                  int numShorts)
           throws SynthException
Throws:
SynthException

write

public void write(short[] data)
           throws SynthException
Throws:
SynthException

write

public void write(int startFrame,
                  int partNum,
                  double[] data,
                  int startIndex,
                  int numDoubles)
           throws SynthException

Write data from an array of doubles to the Tables internal storage area.

Throws:
SynthException - If the data will not fit in the table.

write

public void write(int startFrame,
                  double[] data,
                  int startIndex,
                  int numDoubles)
           throws SynthException
Throws:
SynthException

write

public void write(double[] data)
           throws SynthException
Throws:
SynthException

length

public int length()