marf.Storage.Loaders
Class SineLoader

java.lang.Object
  extended by marf.Storage.SampleLoader
      extended by marf.Storage.Loaders.SineLoader
All Implemented Interfaces:
ISampleLoader

public class SineLoader
extends SampleLoader

Loads (by computing) a simple sine wave into the sample. Used for simple and quick testing of fake waves.

$Id: SineLoader.java,v 1.13 2007/02/04 07:51:30 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.13 $
Author:
Serguei Mokhov

Field Summary
static double DEFAULT_SINE_DEVIATION
          Default sine frequency deviation of 0.1 kHz, in Hz.
static double DEFAULT_SINE_FREQUENCY
          Default sine frequency at 3 kHz, in Hz.
 
Fields inherited from class marf.Storage.SampleLoader
fRequiredFrequency, iRequiredBitSize, iRequiredChannels, oByteArrayOutputStream, oSample
 
Fields inherited from interface marf.Storage.ISampleLoader
DEFAULT_CHANNELS, DEFAULT_FREQUENCY, DEFAULT_SAMPLE_BIT_SIZE, MARF_INTERFACE_CODE_REVISION
 
Constructor Summary
SineLoader()
          Constructs default Sine Loader.
 
Method Summary
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 long getSampleSize()
          Retrieves the length of the sample (# of audio data in the audio stream).
 Sample loadSample(java.io.File poInFile)
          Fills in the contained sample's data array with a sine wave.
 Sample loadSample(java.lang.String pstrFilename)
          Merely calls readAudioData().
 int readSampleData(double[] padSampleData)
          Generates sine wave at 3 kHz +- 0.0 kHz with 8 kHz sampling rate.
 void saveSample(java.io.File poOutFile)
          Does nothing.
 void saveSample(java.lang.String pstrFilename)
          Does nothing.
 void updateSample()
          Overridden to reset sample's array mark only.
 int writeSampleData(double[] padSample, int piLength)
          Does nothing.
 
Methods inherited from class marf.Storage.SampleLoader
getRequiredBitSize, getRequiredChannels, getRequiredFrequency, getSample, loadSample, loadSample, reset, saveSample, saveSample, setRequiredBitSize, setRequiredChannels, setRequiredFrequency, setSample
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SINE_FREQUENCY

public static final double DEFAULT_SINE_FREQUENCY
Default sine frequency at 3 kHz, in Hz.

See Also:
Constant Field Values

DEFAULT_SINE_DEVIATION

public static final double DEFAULT_SINE_DEVIATION
Default sine frequency deviation of 0.1 kHz, in Hz.

See Also:
Constant Field Values
Constructor Detail

SineLoader

public SineLoader()
           throws InvalidSampleFormatException
Constructs default Sine Loader.

Throws:
InvalidSampleFormatException
Method Detail

readSampleData

public final int readSampleData(double[] padSampleData)
                         throws StorageException
Generates sine wave at 3 kHz +- 0.0 kHz with 8 kHz sampling rate.

Parameters:
padSampleData - to fill in with sample data
Returns:
the length of padSampleData
Throws:
StorageException
See Also:
AudioSampleLoader.readAudioData(double[])

writeSampleData

public final int writeSampleData(double[] padSample,
                                 int piLength)
                          throws StorageException
Does nothing.

Parameters:
padSample - used to verify the length
piLength - used to verify the length
Returns:
the smallest of padSample.length or piLength
Throws:
StorageException - if piLength is less than zero
See Also:
AudioSampleLoader.writeAudioData(double[], int)

loadSample

public Sample loadSample(java.io.File poInFile)
                  throws StorageException
Fills in the contained sample's data array with a sine wave. Internally calls readAudioData().

Specified by:
loadSample in interface ISampleLoader
Overrides:
loadSample in class SampleLoader
Parameters:
poInFile - unused, can be null
Returns:
generated sample reference
Throws:
StorageException
See Also:
readSampleData(double[])

saveSample

public void saveSample(java.io.File poOutFile)
                throws StorageException
Does nothing.

Specified by:
saveSample in interface ISampleLoader
Overrides:
saveSample in class SampleLoader
Parameters:
poOutFile - unused, can be null
Throws:
StorageException, - never thrown
StorageException - if there was an error saving the sample
See Also:
ISampleLoader.saveSample(java.io.File)

loadSample

public Sample loadSample(java.lang.String pstrFilename)
                  throws StorageException
Merely calls readAudioData().

Specified by:
loadSample in interface ISampleLoader
Overrides:
loadSample in class SampleLoader
Parameters:
pstrFilename - unused, can be null
Returns:
Sample object reference
Throws:
StorageException - if readAudioData fails
See Also:
readSampleData(double[])

saveSample

public void saveSample(java.lang.String pstrFilename)
                throws StorageException
Does nothing.

Specified by:
saveSample in interface ISampleLoader
Overrides:
saveSample in class SampleLoader
Parameters:
pstrFilename - unused, can be null
Throws:
StorageException, - never thrown
StorageException - if there was an error saving the sample

updateSample

public void updateSample()
                  throws StorageException
Overridden to reset sample's array mark only.

Specified by:
updateSample in interface ISampleLoader
Overrides:
updateSample in class SampleLoader
Throws:
StorageException, - never thrown
StorageException - if there was an error updating the sample data array

getSampleSize

public long getSampleSize()
                   throws StorageException
Retrieves the length of the sample (# of audio data in the audio stream).

Specified by:
getSampleSize in interface ISampleLoader
Overrides:
getSampleSize in class SampleLoader
Returns:
sample size, long
Throws:
StorageException - if there was an error getting sample size

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Returns source code revision information.

Returns:
revision string


SourceForge Logo