DixShtix

com.dixshtix.soundlab
Class SimpleSynth

java.lang.Object
  |
  +--com.dixshtix.soundlab.Generator
        |
        +--com.dixshtix.soundlab.SimpleSynth
All Implemented Interfaces:
java.io.Serializable

public class SimpleSynth
extends Generator
implements java.io.Serializable

Square-envelope tone generator with periodic waveform for Interactive Multitimbral Sound Lab.

Description: An extensible framework for the synthesis and playback of polyphonic, multitimbral sound clips.

Copyright: Copyright (c) Richard C. Penner II

Company: DixShtix

Version:
$Revision: 1.3 $
Author:
Richard C. Penner II
See Also:
Serialized Form

Field Summary
protected  double amplitude
          Relative amplitude.
protected  double duration_in_seconds
          Actual duration may be longer for non-square envelopes.
protected  double frequency_in_hertz
          Note value.
private static int TABLE_LENGTH
          Default sampling rate for creation of a lookup table.
protected  byte waveform_bits
          Interpreted as a bitmask.
(package private) static byte WAVEFORM_PERIODIC_NOISE
          Encoded bitmask for periodic, uniformly distributed noise waveform.
(package private) static byte WAVEFORM_REVERSE_SAWTOOTH
          Encoded bitmask for reverse sawtooth waveform.
(package private) static byte WAVEFORM_REVERSE_SQUARE
          Encoded bitmask for reverse square waveform.
(package private) static byte WAVEFORM_REVERSE_TRIANGLE
          Encoded bitmask for reverse triangle waveform.
(package private) static byte WAVEFORM_SAWTOOTH
          Encoded bitmask for sawtooth (based on sines) waveform.
(package private) static byte WAVEFORM_SINE
          Encoded bitmask for pure sine waveform.
(package private) static byte WAVEFORM_SQUARE
          Encoded bitmask for square (based on sines) waveform.
(package private) static byte WAVEFORM_TRIANGLE
          Encoded bitmask for triangle (based on sines) waveform.
 
Constructor Summary
SimpleSynth()
          Constructor with Bean semantics.
 
Method Summary
 double[] generate(double sampleRate)
          Create a lookup table.
 double getAmplitude()
          Amplitude is normalized to 1.0 = 0 dB.
 double getDuration()
          Duration is the time between Note on and Note off events.
 double getFrequency()
          Hertz (cycles per second) is between 16 and 32,000.
 double[] getLookupTable(int samplesPerPeriod)
          Create a lookup table.
 byte getWaveform()
          Waveform is an encoded byte of information.
 void setAmplitude(double scale)
          Amplitude is normalized to 1.0 = 0 dB.
 void setDuration(double seconds)
          Duration is the time between Note on and Note off events.
 void setFrequency(double hertz)
          Hertz (cycles per second) is between 16 and 32,000.
 void setWaveform(byte type)
          Waveform is an encoded byte of information.
 java.lang.String toString()
          Convert object to printable representation.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

frequency_in_hertz

protected double frequency_in_hertz
Note value.

duration_in_seconds

protected double duration_in_seconds
Actual duration may be longer for non-square envelopes.

amplitude

protected double amplitude
Relative amplitude. 1.0 = 0 dB.

waveform_bits

protected byte waveform_bits
Interpreted as a bitmask.

TABLE_LENGTH

private static final int TABLE_LENGTH
Default sampling rate for creation of a lookup table.

WAVEFORM_SINE

static final byte WAVEFORM_SINE
Encoded bitmask for pure sine waveform.

WAVEFORM_SQUARE

static final byte WAVEFORM_SQUARE
Encoded bitmask for square (based on sines) waveform.

WAVEFORM_TRIANGLE

static final byte WAVEFORM_TRIANGLE
Encoded bitmask for triangle (based on sines) waveform.

WAVEFORM_SAWTOOTH

static final byte WAVEFORM_SAWTOOTH
Encoded bitmask for sawtooth (based on sines) waveform.

WAVEFORM_PERIODIC_NOISE

static final byte WAVEFORM_PERIODIC_NOISE
Encoded bitmask for periodic, uniformly distributed noise waveform.

WAVEFORM_REVERSE_SQUARE

static final byte WAVEFORM_REVERSE_SQUARE
Encoded bitmask for reverse square waveform.

WAVEFORM_REVERSE_TRIANGLE

static final byte WAVEFORM_REVERSE_TRIANGLE
Encoded bitmask for reverse triangle waveform.

WAVEFORM_REVERSE_SAWTOOTH

static final byte WAVEFORM_REVERSE_SAWTOOTH
Encoded bitmask for reverse sawtooth waveform.
Constructor Detail

SimpleSynth

public SimpleSynth()
Constructor with Bean semantics.
Method Detail

toString

public java.lang.String toString()
Convert object to printable representation.
Overrides:
toString in class Generator

getLookupTable

public double[] getLookupTable(int samplesPerPeriod)
Create a lookup table. Sample rate is between 2048 and 65536.
Overrides:
getLookupTable in class Generator

generate

public double[] generate(double sampleRate)
Create a lookup table. Sample rate is between 2048 and 65536.
Overrides:
generate in class Generator

setFrequency

public void setFrequency(double hertz)
Hertz (cycles per second) is between 16 and 32,000.

getFrequency

public double getFrequency()
Hertz (cycles per second) is between 16 and 32,000.

setWaveform

public void setWaveform(byte type)
Waveform is an encoded byte of information.

getWaveform

public byte getWaveform()
Waveform is an encoded byte of information.

setDuration

public void setDuration(double seconds)
Duration is the time between Note on and Note off events.

getDuration

public double getDuration()
Duration is the time between Note on and Note off events.

setAmplitude

public void setAmplitude(double scale)
Amplitude is normalized to 1.0 = 0 dB.

getAmplitude

public double getAmplitude()
Amplitude is normalized to 1.0 = 0 dB.

DixShtix