Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class PannerNode
Positions a source in 3D space relative to the context’s AudioListener,
the Web Audio PannerNode. The output is stereo.
Azimuth and elevation, distance attenuation and the sound cone follow the
specification’s algorithms exactly. PanningModel.EQUALPOWER (the default)
pans by azimuth; PanningModel.HRTF renders binaurally for headphones.
OfflineAudioContext audio = new OfflineAudioContext(2, 44100, 44100);
OscillatorNode footsteps = audio.createOscillator();
PannerNode p = audio.createPanner();
p.setPanningModel(PanningModel.HRTF);
p.setDistanceModel(DistanceModelType.INVERSE);
p.setRefDistance(1);
p.setPosition(3, 0, -2); // ahead and to the right
footsteps.connect(p).connect(audio.getDestination());
audio.getListener().setPosition(0, 0, 0);Positions and orientation are audio rate AudioParams and can be
automated: p.getPositionX().linearRampToValueAtTime(-3, now + 4) moves the
source across the listener. Attributes such as the distance model are
applied from the next render quantum.
Methods
Inherited methods
Method details
setPosition
public void setPosition(float x, float y, float z)Moves the source now.
Parameters
xfloat- position on X
yfloat- position on Y
zfloat- position on Z
setOrientation
public void setOrientation(float x, float y, float z)Points the source now; only matters with a cone narrower than 360 degrees.
Parameters
xfloat- direction X
yfloat- direction Y
zfloat- direction Z
getPositionX
public AudioParam getPositionX()Position on X, 0 by default.
Returns
the parameter
getPositionY
public AudioParam getPositionY()Position on Y, 0 by default.
Returns
the parameter
getPositionZ
public AudioParam getPositionZ()Position on Z, 0 by default.
Returns
the parameter
getOrientationX
public AudioParam getOrientationX()X of the direction the source faces, 1 by default.
Returns
the parameter
getOrientationY
public AudioParam getOrientationY()Y of the direction the source faces, 0 by default.
Returns
the parameter
getOrientationZ
public AudioParam getOrientationZ()Z of the direction the source faces, 0 by default.
Returns
the parameter
getPanningModel
public PanningModel getPanningModel()The panning model.
Returns
the model
setPanningModel
public void setPanningModel(PanningModel model)Sets the panning model.
Parameters
modelPanningModel- the model
getDistanceModel
public DistanceModelType getDistanceModel()The distance model.
Returns
the model
setDistanceModel
public void setDistanceModel(DistanceModelType model)Sets the distance model.
Parameters
modelDistanceModelType- the model
getRefDistance
public double getRefDistance()The distance at which attenuation starts, 1 by default.
Returns
the distance
setRefDistance
public void setRefDistance(double refDistance)Sets the distance at which attenuation starts.
Parameters
refDistancedouble- 0 or more
getMaxDistance
public double getMaxDistance()The distance past which the linear model attenuates no further, 10000 by
default.
Returns
the distance
setMaxDistance
public void setMaxDistance(double maxDistance)Sets the distance past which the linear model attenuates no further.
Parameters
maxDistancedouble- more than 0
getRolloffFactor
public double getRolloffFactor()How fast the volume falls with distance, 1 by default.
Returns
the factor
setRolloffFactor
public void setRolloffFactor(double rolloffFactor)Sets how fast the volume falls with distance.
Parameters
rolloffFactordouble- 0 or more; the linear model clamps it to 1
getConeInnerAngle
public double getConeInnerAngle()The angle, in degrees, of the cone inside which there is no cone
attenuation; 360 by default.
Returns
degrees
setConeInnerAngle
public void setConeInnerAngle(double angle)Sets the inner cone angle.
Parameters
angledouble- degrees
getConeOuterAngle
public double getConeOuterAngle()The angle, in degrees, outside which the gain is
getConeOuterGain();
360 by default.Returns
degrees
setConeOuterAngle
public void setConeOuterAngle(double angle)Sets the outer cone angle.
Parameters
angledouble- degrees
getConeOuterGain
public double getConeOuterGain()The gain outside the outer cone, 0 by default.
Returns
the gain
setConeOuterGain
public void setConeOuterGain(double gain)Sets the gain outside the outer cone.
Parameters
gaindouble- 0 to 1