com.softsynth.jsyn
Class SynthSampleWAV

java.lang.Object
  extended by java.util.Observable
      extended by com.softsynth.jsyn.SynthObject
          extended by com.softsynth.jsyn.SynthChannelData
              extended by com.softsynth.jsyn.SynthSample
                  extended by com.softsynth.jsyn.SynthSampleWAV
All Implemented Interfaces:
ChunkHandler

public class SynthSampleWAV
extends SynthSample
implements ChunkHandler

Sample that can load itself from a standard WAV format file.

Author:
(C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved
See Also:
ParseRIFF, SynthSampleAIFF

Field Summary
 
Fields inherited from class com.softsynth.jsyn.SynthSample
AIFF, byteData, UNRECOGNIZED, WAV
 
Fields inherited from class com.softsynth.jsyn.SynthChannelData
cuePoints
 
Constructor Summary
SynthSampleWAV()
           
SynthSampleWAV(java.io.InputStream stream)
           
SynthSampleWAV(SynthContext synthContext)
           
SynthSampleWAV(SynthContext synthContext, java.io.InputStream stream)
          Create a WAV parser.
 
Method Summary
 void handleChunk(ParseIFF parser, int ckID, int ckSize)
          Called by parse() method to handle chunks in a WAV specific manner.
 void handleForm(ParseIFF parser, int ckID, int ckSize, int type)
          The parser will call this when it encounters a FORM or LIST chunk that contains other chunks.
 short[] loadShorts(java.io.InputStream stream, boolean ifLoadData)
          Load the sample data from the given stream and return it in an array of shorts.
 
Methods inherited from class com.softsynth.jsyn.SynthSample
allocate, clear, clear, dump, getBaseFrequency, getChannelsPerFrame, getFileSize, getFileType, getNumBytesRead, getOffset, getSampleRate, load, load, read, read, setBaseFrequency, setHighAmplitude, setHighFrequency, setLowAmplitude, setLowFrequency, setSampleRate, write, write
 
Methods inherited from class com.softsynth.jsyn.SynthChannelData
findCuePoint, findCuePosition, getMaxFrames, getNumFrames, getReleaseBegin, getReleaseEnd, getReleaseSize, getSustainBegin, getSustainEnd, getSustainSize, insertSortedCue, setNumFrames, setReleaseLoop, setSustainLoop
 
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

SynthSampleWAV

public SynthSampleWAV(SynthContext synthContext,
                      java.io.InputStream stream)
               throws SynthException,
                      java.io.IOException
Create a WAV parser.

Parameters:
stream - A stream that may come from a file or in memory byte array.
Throws:
SynthException - If parsing fails, or insufficient memory.
java.io.IOException - If parsing fails, or IO error occurs.

SynthSampleWAV

public SynthSampleWAV(SynthContext synthContext)

SynthSampleWAV

public SynthSampleWAV(java.io.InputStream stream)
               throws SynthException,
                      java.io.IOException
Throws:
SynthException
java.io.IOException

SynthSampleWAV

public SynthSampleWAV()
Method Detail

loadShorts

public short[] loadShorts(java.io.InputStream stream,
                          boolean ifLoadData)
                   throws SynthException,
                          java.io.IOException
Load the sample data from the given stream and return it in an array of shorts.

Overrides:
loadShorts in class SynthSample
Parameters:
stream - May be any stream from a file, a URL, a byte array, etc.
ifLoadData - If true, sample data will be loaded into memory.
Throws:
SynthException - If parsing fails, or there is insufficient memory.
java.io.IOException - If parsing fails, or IO error occurs.

handleForm

public void handleForm(ParseIFF parser,
                       int ckID,
                       int ckSize,
                       int type)
                throws java.io.IOException
Description copied from interface: ChunkHandler
The parser will call this when it encounters a FORM or LIST chunk that contains other chunks. This handler can either read the form's chunks, or let the parser find them and call handleChunk().

Specified by:
handleForm in interface ChunkHandler
ckID - a 4 byte identifier such as FORM_ID that identifies the IFF chunk type.
ckSize - number of bytes contained in the FORM, not counting the FORM type.
type - a 4 byte identifier such as AIFF_ID that identifies the FORM type.
Throws:
java.io.IOException

handleChunk

public void handleChunk(ParseIFF parser,
                        int ckID,
                        int ckSize)
                 throws java.io.IOException
Called by parse() method to handle chunks in a WAV specific manner.

Specified by:
handleChunk in interface ChunkHandler
Parameters:
ckID - four byte chunk ID such as 'data'
ckSize - size of chunk in bytes
Throws:
java.io.IOException