If something seems wrong or incomplete, please enter a comment at the bottom of this page.
- source - main - QA -
jsaudio module
Support 2D and 3D sound source and listener using OpenAL library.
class jsaudio::OalBuffer
- top - revision -
constructor( soundBlob )
arguments:1. <sub>Blob</sub> _soundBlob_:
Methods
valueOfinteger valueOf()
Properties
frequencysizeinteger frequency
is the frquency (in Hz) of the sound hold by the buffer.
bitsinteger size
is the size (in bytes) of the sound hold by the buffer.
channelsinteger bits
is the resolution (in bits) of the sound hold by the buffer.
integer channels
is the number of channels of the sound hold by the buffer.
class jsaudio::OalEffect
- top - revision -
constructor()
Creates a new effect object.
Methods
valueOfinteger valueOf()
Returns the internal OpenAL buffer id.
Properties
typeinteger type
set the type of effect represented by the Effect object. * undefined * Oal.EFFECT_EAXREVERB * Oal.EFFECT_REVERB * Oal.EFFECT_CHORUS * Oal.EFFECT_DISTORTION * Oal.EFFECT_ECHO * Oal.EFFECT_FLANGER * Oal.EFFECT_FREQUENCY_SHIFTER * Oal.EFFECT_VOCAL_MORPHER * Oal.EFFECT_PITCH_SHIFTER * Oal.EFFECT_RING_MODULATOR * Oal.EFFECT_AUTOWAH * Oal.EFFECT_COMPRESSOR * Oal.EFFECT_EQUALIZER
========(many) * real reverbDensity * real reverbDiffusion * real reverbGain * real reverbGainHF * real reverbDecayTime * real reverbDecayHFRatio * real reverbReflectionsGain * real reverbReflectionsDelay * real reverbLateReverbGain * real reverbLateReverbDelay * real reverbAirAbsorptionGainHF * real reverbRoomRolloffFactor * boolean reverbDecayHFLimit
- integer chorusWaveform
- integer chorusPhase
- real chorusRate
- real chorusDepth
- real chorusFeedback
real chorusDelay
real distortionEdge
- real distortionGain
- real distortionLowpassCutoff
- real distortionEqcenter
real distortionEqbandwidth
real echoDelay
- real echoLrdelay
- real echoDamping
- real echoFeedback
real echoSpread
integer flangerWaveform
- real flangerPhase
- real flangerRate
- real flangerDepth
- real flangerFeedback
real flangerDelay
real frequencyShifterFrequency
- integer frequencyShifterLeftDirection
integer frequencyShifterRightDirection
integer vocalMorpherPhonemea
- integer vocalMorpherPhonemeaCoarseTuning
- integer vocalMorpherPhonemeb
- integer vocalMorpherPhonemebCoarseTuning
- integer vocalMorpherWaveform
real vocalMorpherRate
integer pitchShifterCoarseTune
integer pitchShifterFineTune
real ringModulatorFrequency
- real ringModulatorHighpassCutoff
integer ringModulatorWaveform
real autowahAttackTime
- real autowahReleaseTime
- real autowahResonance
real autowahPeakGain
boolean compressorOnoff
real equalizerLowGain
- real equalizerLowCutoff
- real equalizerMid1Gain
- real equalizerMid1Center
- real equalizerMid1Width
- real equalizerMid2Gain
- real equalizerMid2Center
- real equalizerMid2Width
- real equalizerHighGain
- real equalizerHighCutoff
class jsaudio::OalFilter
- top - revision -
constructor()
Creates a new filter object.
Methods
valueOfinteger valueOf()
Returns the internal OpenAL filter id.
Properties
typeinteger type
set the type of filter represented by the Filter object. * undefined * Oal.FILTER_NULL * Oal.FILTER_LOWPASS * Oal.FILTER_HIGHPASS * Oal.FILTER_BANDPASS
========(many) * real lowpassGain * real lowpassGainHF
- real highpassGain
real highpassGainLF
real bandpassGain
- real bandpassGainLF
- real bandpassGainHF
class jsaudio::OalListener
- top - revision -
Properties
positionmetersPerUnitArray position
Gets or sets the position of the listener in the 3D environment.
Array metersPerUnit
Gets or sets the unit size of the 3D environment.
class jsaudio::Oal
- top - revision -
Static functions
OpenClosevoid Open( [.md deviceName ] )
Open an audio device.
arguments:1. <sub>string</sub> _deviceName_: "Generic Hardware", "Generic Software", "DirectSound3D" (for legacy), "DirectSound", "MMSYSTEM"
OpenAL API:If no device name is specified, we will attempt to use DS3D.
alcOpenDevice, alcCreateContext, alcMakeContextCurrent
hasEfxvoid Close()
Close the current audio device.
OpenAL API:alcGetCurrentContext, alcMakeContextCurrent, alcGetContextsDevice, alcDestroyContext, alcCloseDevice
maxAuxiliarySendsboolean hasEfx
is true if EFX extension is available.
DopplerFactorboolean maxAuxiliarySends
is the number of aux sends per source.
DopplerVelocityvoid DopplerFactor( value )
Selects the OpenAL Doppler factor value. The default Doppler factor value is 1.0 .
arguments:OpenAL API:1. <sub>number</sub> _value_
alDopplerFactor
SpeedOfSoundvoid DopplerVelocity( value )
Selects the OpenAL Doppler velocity value. The default Doppler velocity value is 343.3 .
arguments:OpenAL API:1. <sub>number</sub> _value_
alDopplerVelocity
DistanceModelvoid SpeedOfSound( value )
Selects the OpenAL Speed of Sound value.
arguments:OpenAL API:1. <sub>number</sub> _value_
alSpeedOfSound
Enablevoid DistanceModel( distanceModel )
arguments:OpenAL API:1. <sub>integer</sub> _value_
alDistanceModel
Disablevoid Enable( cap )
arguments:OpenAL API:1. <sub>GLenum</sub> _cap_
alEnable
IsEnabledvoid Disable( cap )
arguments:OpenAL API:1. <sub>GLenum</sub> _cap_
alDisable
GetStringvoid IsEnabled( cap )
arguments:OpenAL API:1. <sub>GLenum</sub> _cap_
alIsEnabled
GetBooleanboolean GetString( pname )
arguments:return value:1. <sub>GLenum</sub> _pname_
OpenAL API:value of a selected parameter.
alGetString
GetIntegerboolean GetBoolean( pname )
arguments:return value:1. <sub>ALenum</sub> _pname_
OpenAL API:value of a selected parameter.
alGetBooleanv
GetDoubleinteger | Array GetInteger( pname [.md, count] )
arguments:return value:1. <sub>ALenum</sub> _pname_ 1. <sub>integer</sub> _count_: is the number of expected values. If _count_ is defined, the function will returns an array of values, else it returns a single value.
OpenAL API:A single value or an array of values of a selected parameter.
alGetIntegerv
Listenerreal | Array GetDouble( pname [.md, count] )
arguments:return value:1. <sub>ALenum</sub> _pname_ 1. <sub>integer</sub> _count_: is the number of expected values. If _count_ is defined, the function will returns an array of values, else a single value.
OpenAL API:single value or Array of values of the selected parameter.
alGetDoublev
GetListenerRealvoid Listener( pname, params )
arguments:OpenAL API:1. <sub>ALenum</sub> _pname_: 1. <sub>Array</sub> _params_:
alListeneri, alListenerf, alListenerfv
GenSourcereal | Array GetListenerReal( source, pname [.md, count] )
arguments:return value:1. <sub>integer</sub> _source_: 1. <sub>ALenum</sub> _pname_: 1. <sub>integer</sub> _count_: is the number of expected values. If _count_ is defined, the function will returns an array of values, else a single value.
OpenAL API:single value or Array of values of the selected parameter.
alGetListenerfv
Sourceinteger GenSource()
OpenAL API:alSourcei, alSourcef, alSourcefv
GetSourceRealvoid Source( source, pname, params )
arguments:OpenAL API:1. <sub>integer</sub> _source_: 1. <sub>ALenum</sub> _pname_: 1. <sub>Array</sub> _params_:
alSourcei, alSourcef, alSourcefv
GetSourceIntegerreal | Array GetSourceReal( source, pname [.md, count] )
arguments:return value:1. <sub>integer</sub> _source_: 1. <sub>ALenum</sub> _pname_: 1. <sub>integer</sub> _count_: is the number of expected values. If _count_ is defined, the function will returns an array of values, else a single value.
OpenAL API:single value or Array of values of the selected parameter.
alGetSourcef
DeleteSourcereal | Array GetSourceInteger( source, pname [.md, count] )
SourceQueueBuffersvoid DeleteSource( source )
arguments:OpenAL API:1. <sub>integer</sub> _source_: the source id.
alDeleteBuffers
SourceUnqueueBuffersvoid SourceQueueBuffers( source, buffer | bufferArray )
arguments:OpenAL API:1. <sub>integer</sub> _source_: the source id. 1. <sub>integer</sub> _buffer_: the buffer id. 1. <sub>Array</sub> _bufferArray_: an Array of buffer id.
alDeleteBuffers
Buffervoid SourceUnqueueBuffers( source, buffer | bufferArray )
arguments:OpenAL API:1. <sub>integer</sub> _buffer_: the buffer id. 1. <sub>Array</sub> _bufferArray_: an Array of buffer id.
alDeleteBuffers
GetBufferRealinteger Buffer( soundObject )
Creates a new buffer and attach a sound data to it. The data comming from the soundObject is copied into the OpenAL system. undefined
arguments:Buffers containing audio data with more than one channel will be played without 3D spatialization features these formats are normally used for background music.
1. <sub>soundObject</sub> _sound_: a sound object that contains PCM audio data and the following properties: rate, channels and bits.
GetBufferIntegerreal | Array GetBufferReal( source, pname [.md, count] )
arguments:return value:1. <sub>integer</sub> _source_: 1. <sub>ALenum</sub> _pname_: 1. <sub>integer</sub> _count_: is the number of expected values. If _count_ is defined, the function will returns an array of values, else a single value.
OpenAL API:single value or Array of values of the selected parameter.
alGetBufferfv
DeleteBufferinteger | Array GetBufferInteger( source, pname [.md, count] )
arguments:return value:1. <sub>integer</sub> _source_: 1. <sub>ALenum</sub> _pname_: 1. <sub>integer</sub> _count_: is the number of expected values. If _count_ is defined, the function will returns an array of values, else a single value.
OpenAL API:single value or Array of values of the selected parameter.
alGetBufferiv
PlaySourcevoid DeleteBuffer( buffer )
arguments:note:1. <sub>integer</sub> _buffer_: the buffer id.
OpenAL API:Buffers that have been unqueued from all sources are UNUSED. Buffers that are UNUSED can be deleted, or changed by alBufferData commands.
alDeleteBuffers
StopSourcevoid PlaySource( source )
Plays the given source.
arguments:1. <sub>integer</sub> _source_: the ID of the source to play.
PauseSourcevoid StopSource( source )
Stop the given source.
arguments:1. <sub>integer</sub> _source_: the ID of the source to play.
RewindSourcevoid PauseSource( source )
Pause the given source.
arguments:1. <sub>integer</sub> _source_: the ID of the source to play.
GenEffectvoid RewindSource( source )
Rewind the given source. set playback postiton to beginning.
arguments:1. <sub>integer</sub> _source_: the ID of the source to play.
DeleteEffectvoid GenEffect()
OpenaL API:alGenEffects
PlaySoundvoid DeleteEffect()
OpenaL API:alGenEffects
void PlaySound( sound )
Plays a sound on the default playback device.
arguments:1. <sub>soundObject</sub> _sound_: sound object to play.
Examples
example 1:A simple ogg player ``` LoadModule('jsio'); LoadModule('jsstd'); LoadModule('jssound'); LoadModule('jsaudio');
Oal.Open(); var decoder = new OggVorbisDecoder(new File('41_30secOgg-q0.ogg').Open(File.RDONLY)); var sourceId = Oal.GenSource();
var pcm; while ( pcm = decoder.Read(10000) ) {
var bufferId = Oal.Buffer(pcm); Oal.SourceQueueBuffers(sourceId, bufferId); if ( Oal.GetSourceInteger(sourceId, Oal.SOURCE_STATE) == Oal.INITIAL ) Oal.PlaySource(sourceId); };
var totalTime = decoder.frames/decoder.rate; var currentTimeOffset = Oal.GetSourceReal(sourceId, Oal.SEC_OFFSET); Sleep( 1000 * (totalTime - currentTimeOffset) ); ```
class jsaudio::OalSource
- top - revision -
QueueBuffersconstructor()
Creates a new source object.
UnqueueBuffersvoid QueueBuffers( buffer )
arguments:OpenAL API:1. <sub>OalBuffer</sub> | BufferId: a Buffer Object or a buffer Id.
alDeleteBuffers
OalBuffer UnqueueBuffers()
OpenAL API:alDeleteBuffers
Properties
class jsaudio::OalError
- top -
textinteger code
OpenAL error number.
conststring text
OpenAL error literal.
toStringstring const
Const name of the OpenAL error.
string toString
see Text().
more information
OpenAL Specification and Reference OpenAL 1.1 Specification and Reference
- top - main -