Class OALContext

java.lang.Object
com.blackrook.gloop.openal.OALHandle
com.blackrook.gloop.openal.OALContext

public class OALContext extends OALHandle
A context handle in OpenAL. Represents the rendering context.
Author:
Matthew Tropiano
  • Method Details

    • getHandle

      public long getHandle()
      Specified by:
      getHandle in class OALHandle
      Returns:
      this handle's OpenAL address handle.
    • isCreated

      public boolean isCreated()
      Specified by:
      isCreated in class OALHandle
      Returns:
      true if this handle was allocated, false if not.
    • allocate

      protected long allocate()
    • destroy

      public void destroy()
      Description copied from class: OALHandle
      Destroys this handle. Does nothing if already destroyed.
      Specified by:
      destroy in class OALHandle
    • getAttributeValue

      public Integer getAttributeValue(OALContext.ContextAttribute attribute)
      Returns the corresponding value of a context attribute used to create this context.
      Parameters:
      attribute - the attribute.
      Returns:
      the value used, or null if the default was used.
    • getVendorName

      public String getVendorName()
      Returns:
      the vendor name for this OpenAL implementation.
    • getVersionName

      public String getVersionName()
      Returns:
      the version name for this OpenAL implementation.
    • getRendererName

      public String getRendererName()
      Returns:
      the renderer name for this OpenAL implementation.
    • getExtensions

      public Set<String> getExtensions()
      Returns:
      the set of extensions.
    • extensionIsPresent

      public boolean extensionIsPresent(String extensionName)
      Checks if an extension is present for this context. Case-insensitive.
      Parameters:
      extensionName - the name of the extension.
      Returns:
      true if so, false if not.
    • getMaxEffectSlots

      public int getMaxEffectSlots()
      Returns:
      the max effect slots allowed per source.
    • setCurrentDistanceModel

      public void setCurrentDistanceModel(OALContext.DistanceModel currentDistanceModel)
    • getCurrentDistanceModel

      public OALContext.DistanceModel getCurrentDistanceModel()
      Returns:
      this device's current distance model.
    • getListener

      public OALListener getListener()
      Returns:
      this context's listener.
    • getCapabilities

      public ALCapabilities getCapabilities()
      Returns:
      the capabilities that this context was created with.
    • getError

      public void getError()
      Convenience method for checking for an OpenAL error and throwing a SoundException if an error is raised.
    • suspend

      public void suspend()
      Suspends processing of this context.
    • process

      public void process()
      Resumes processing of this context.
    • createSource

      public OALSource createSource()
      Allocates a new source and assigns it internally to the current context.
      Returns:
      the newly allocated source.
      Throws:
      SoundException - if the source can't be created.
    • createSource

      public OALSource createSource(boolean autoVelocity)
      Allocates a new source and assigns it internally to the current context.
      Parameters:
      autoVelocity - if true, set auto velocity to on for this Source.
      Returns:
      the newly allocated source.
      Throws:
      SoundException - if the source can't be created.
    • createBuffer

      public OALBuffer createBuffer()
      Allocates a new buffer for loading data into. Buffers are independent of device context.
      Returns:
      a newly allocated buffer.
      Throws:
      SoundException - if the Buffer can't be allocated somehow.
    • createBuffers

      public OALBuffer[] createBuffers(int amount)
      Allocates a new buffer for loading data into. Buffers are independent of device context.
      Parameters:
      amount - the amount of buffers to create.
      Returns:
      a set of newly allocated buffers.
      Throws:
      SoundException - if the Buffer can't be allocated somehow.
    • createBuffer

      public OALBuffer createBuffer(JSPISoundHandle handle) throws IOException
      Allocates a new buffer with data loaded into it. All of the sound data readable by the SoundData instance is read into the buffer. If you know that the data being loaded is very long or large, you should consider using a Streaming Source to conserve memory. Buffers are independant of device context.
      Parameters:
      handle - the handle to the sound data to load into this buffer.
      Returns:
      a newly allocated buffer.
      Throws:
      IOException - if the data can't be read.
      SoundException - if the Buffer can't be allocated somehow.
    • createBuffer

      public OALBuffer createBuffer(JSPISoundHandle.Decoder dataDecoder) throws IOException
      Allocates a new buffer with data loaded into it. All of the sound data readable by the SoundDataDecoder instance is read into the buffer. If you know that the data being loaded is very long or large, you should consider using a Streaming Source to conserve memory. Buffers are independent of device context.
      Parameters:
      dataDecoder - the decoder of the sound data to load into this buffer.
      Returns:
      a newly allocated buffer.
      Throws:
      IOException - if the data can't be read.
      SoundException - if the Buffer can't be allocated somehow.
    • createEffectSlot

      public OALEffectSlot createEffectSlot()
      Creates a new Auxiliary Effect Slot for adding a filter and effects to Sources. These slots can be added to sources. If you have more than one source that uses the same sets of filters and effects, it might be better to bind one slot to more than one source to save memory, especially if you need to alter an effect of filter for more than one sound that is playing.
      Returns:
      a new AuxEffectSlot object.
      Throws:
      SoundException - if the slot can't be allocated somehow.
    • createAutowahEffect

      public AutowahEffect createAutowahEffect()
      Creates a new Autowah effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createChorusEffect

      public ChorusEffect createChorusEffect()
      Creates a new Chorus effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createCompressorEffect

      public CompressorEffect createCompressorEffect()
      Creates a new Compressor effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createDistortionEffect

      public DistortionEffect createDistortionEffect()
      Creates a new Distortion effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createEchoEffect

      public EchoEffect createEchoEffect()
      Creates a new Echo effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createEqualizerEffect

      public EqualizerEffect createEqualizerEffect()
      Creates a new Equalizer effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createFlangerEffect

      public FlangerEffect createFlangerEffect()
      Creates a new Flanger effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createFrequencyShiftEffect

      public FrequencyShiftEffect createFrequencyShiftEffect()
      Creates a new Frequency Shift effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createPitchShiftEffect

      public PitchShiftEffect createPitchShiftEffect()
      Creates a new Pitch Shift effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createReverbEffect

      public ReverbEffect createReverbEffect()
      Creates a new Reverb effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createRingModulatorEffect

      public RingModulatorEffect createRingModulatorEffect()
      Creates a new Ring Modulator effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createVocalMorpherEffect

      public VocalMorpherEffect createVocalMorpherEffect()
      Creates a new Vocal Morpher effect.
      Returns:
      a new effect of this type with default values set.
      Throws:
      SoundException - if the effect can't be created.
    • createHighPassFilter

      public HighPassFilter createHighPassFilter()
      Creates a new High Pass filter.
      Returns:
      a new filter of this type with default values set.
      Throws:
      SoundException - if the filter can't be created.
    • createLowPassFilter

      public LowPassFilter createLowPassFilter()
      Creates a new Low Pass filter.
      Returns:
      a new filter of this type with default values set.
      Throws:
      SoundException - if the filter can't be created.
    • createBandPassFilter

      public BandPassFilter createBandPassFilter()
      Creates a new Band Pass filter.
      Returns:
      a new filter of this type with default values set.
      Throws:
      SoundException - if the filter can't be created.
    • setDopplerFactor

      public void setDopplerFactor(float f)
      Sets the sound environment's Doppler Factor. 0 = disabled.
      Parameters:
      f - the Doppler factor.
    • getDopplerFactor

      public float getDopplerFactor()
      Returns:
      the sound environment's Doppler Factor.
    • setSpeedOfSound

      public void setSpeedOfSound(float s)
      Sets the sound environment's speed of sound factor.
      Parameters:
      s - the speed of sound.
    • getSpeedOfSound

      public float getSpeedOfSound()
      Returns:
      the sound environment's speed of sound factor.
    • setDistanceModel

      public void setDistanceModel(OALContext.DistanceModel model)
      Sets the current context's distance model. By default, this is DistanceModel.INVERSE_DISTANCE_CLAMPED.
      Parameters:
      model - the distance model to use.
    • getDistanceModel

      public OALContext.DistanceModel getDistanceModel()
      Returns:
      the current context's distance model.