public class Wavetable extends java.lang.Object implements Waveform
Constructor and Description |
---|
Wavetable(float[] waveform)
Construct a Wavetable that will use
waveform as the float array to sample from. |
Wavetable(int size)
Construct a Wavetable that contains
size entries. |
Wavetable(Wavetable wavetable)
Make a new Wavetable that has the same waveform values as
wavetable . |
Modifier and Type | Method and Description |
---|---|
void |
addNoise(float sigma)
Adds gaussian noise to the waveform scaled by
sigma . |
void |
flip(float in)
Flip the values in the table around a particular value.
|
float |
get(int i)
Returns the value of the ith entry in this Wavetable's waveform.
|
float[] |
getWaveform()
Returns the underlying waveform, not a copy of it.
|
void |
invert()
Flips the table around 0.
|
void |
normalize()
Normalizes the Wavetable by finding the largest amplitude in the table and scaling
the table by the inverse of that amount.
|
void |
offset(float amount)
Apply a DC offset to this Wavetable.
|
void |
rectify()
Inverts all values in the table that are less than zero.
|
void |
scale(float scale)
Multiplies each value of the underlying waveform by
scale . |
void |
set(int i,
float value)
Sets the ith entry of the underlying waveform to
value . |
void |
setWaveform(float[] waveform)
Sets this Wavetable's waveform to the one provided.
|
int |
size()
Returns the length of the underlying waveform.
|
void |
smooth(int windowLength)
Smooths out the values in the table by using a moving average window.
|
float |
value(float at)
at is expected to be in the range [0,1]. |
public Wavetable(int size)
size
entries.size
- public Wavetable(float[] waveform)
waveform
as the float array to sample from.
This will not copy waveform
, it will use it directly.waveform
- public Wavetable(Wavetable wavetable)
wavetable
. This will
copy the values from the provided Wavetable into this Wavetable's waveform.wavetable
- public void setWaveform(float[] waveform)
waveform
- public float get(int i)
public float value(float at)
at
is expected to be in the range [0,1]. This will sample the waveform
using this value and interpolate between actual sample values as needed.public float[] getWaveform()
public void set(int i, float value)
value
.
This is equivalent to:
getWaveform()[i] = value;
public int size()
getWaveform().length
public void scale(float scale)
scale
.public void offset(float amount)
amount
to every
sample.amount
- the amount to add to every sample in the tablepublic void normalize()
public void invert()
flip(0)
.public void flip(float in)
in
- public void addNoise(float sigma)
sigma
.sigma
- public void rectify()
public void smooth(int windowLength)
windowLength
- how many samples large the window should be