sampled
Class Synthesizer

java.lang.Object
  extended by sampled.Synthesizer
All Implemented Interfaces:
AudioSource
Direct Known Subclasses:
ConstantGenerator, SineGenerator

public abstract class Synthesizer
extends java.lang.Object
implements AudioSource

Use the Synthesizer to generate synthetic audio data for test usage. Extending classes need to implement the synthesize method, utilizing the protected member samples indicating the number of samples passed since init.

Author:
sikoried

Field Summary
static int DEFAULT_SAMPLE_RATE
           
 
Constructor Summary
Synthesizer()
           
 
Method Summary
 boolean getPreEmphasis()
          Does the AudioSource perform pre-emphasis?
 int getSampleRate()
          Get the frame rate
 int getSleepTime()
           
 boolean isBlockingSource()
           
static void main(java.lang.String[] args)
           
 int read(double[] buf)
          This function handles the memory i/o and length of the stream (if applicable).
 void setBlocking(boolean blocking)
           
 void setPreEmphasis(boolean applyPreEmphasis, double a)
          Toggle the pre-emphasis of the audio signal
 void setSleepTime(int sleep)
           
abstract  java.lang.String toString()
          String representation of the actual synthesizer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sampled.AudioSource
tearDown
 

Field Detail

DEFAULT_SAMPLE_RATE

public static int DEFAULT_SAMPLE_RATE
Constructor Detail

Synthesizer

public Synthesizer()
Method Detail

getPreEmphasis

public boolean getPreEmphasis()
Description copied from interface: AudioSource
Does the AudioSource perform pre-emphasis?

Specified by:
getPreEmphasis in interface AudioSource

getSampleRate

public int getSampleRate()
Description copied from interface: AudioSource
Get the frame rate

Specified by:
getSampleRate in interface AudioSource
Returns:
number of samples per second

getSleepTime

public int getSleepTime()

isBlockingSource

public boolean isBlockingSource()

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException

read

public int read(double[] buf)
         throws java.io.IOException
This function handles the memory i/o and length of the stream (if applicable). Calls the virtual synthesize method.

Specified by:
read in interface AudioSource
Parameters:
buf - Previously allocated buffer to store the read audio samples.
Returns:
Number of actually read audio samples.
Throws:
java.io.IOException
See Also:
synthesize

setBlocking

public void setBlocking(boolean blocking)

setPreEmphasis

public void setPreEmphasis(boolean applyPreEmphasis,
                           double a)
Description copied from interface: AudioSource
Toggle the pre-emphasis of the audio signal

Specified by:
setPreEmphasis in interface AudioSource
Parameters:
applyPreEmphasis - apply pre-emphasis?
a - the pre-emphasis factor: x'(n) = x(n) - a*x(n-1)

setSleepTime

public void setSleepTime(int sleep)

toString

public abstract java.lang.String toString()
String representation of the actual synthesizer

Specified by:
toString in interface AudioSource
Overrides:
toString in class java.lang.Object