Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class WaveShaperNode
Applies a transfer curve to every sample, for distortion and saturation:
the Web Audio WaveShaperNode.
An input of -1 maps to the first curve entry and +1 to the last, linearly interpolated between and held past both ends. With no curve the node passes its input through.
OfflineAudioContext audio = new OfflineAudioContext(2, 44100, 44100);
float[] curve = new float[1024];
for (int i = 0; i < curve.length; i++) {
double x = i * 2.0 / (curve.length - 1) - 1;
curve[i] = (float) (x * 3 / (1 + Math.abs(x * 3))); // soft clip
}
WaveShaperNode drive = audio.createWaveShaper();
drive.setCurve(curve);
drive.setOversample(OverSampleType.FOUR_X);Methods
public float[] getCurve() | The curve, or null when the node passes its input through. |
public void setCurve(float[] curve) | Sets the transfer curve. |
public OverSampleType getOversample() | The oversampling applied with the curve. |
public void setOversample(OverSampleType type) | Sets the oversampling applied with the curve. |
Inherited methods
Method details
getCurve
public float[] getCurve()The curve, or null when the node passes its input through.
Returns
a copy of the curve or null
setCurve
public void setCurve(float[] curve)Sets the transfer curve. It is copied, so later changes to the array do
not reach the node.
Parameters
curvefloat[]- at least 2 values, or null to pass the input through
getOversample
public OverSampleType getOversample()The oversampling applied with the curve.
Returns
the oversampling
setOversample
public void setOversample(OverSampleType type)Sets the oversampling applied with the curve.
Parameters
typeOverSampleType- the oversampling