Codota Logo
AudioSource
Code IndexAdd Codota to your IDE (free)

How to use
AudioSource
in
com.jme3.audio

Best Java code snippets using com.jme3.audio.AudioSource (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: jMonkeyEngine/jmonkeyengine

public void stopSource(AudioSource src) {
  synchronized (threadLock) {
    if (audioDisabled) {
      return;
    }
    if (src.getStatus() != Status.Stopped) {
      int chan = src.getChannel();
      assert chan != -1; // if it's not stopped, must have id
      src.setStatus(Status.Stopped);
      src.setChannel(-1);
      clearChannel(chan);
      freeChannel(chan);
      
      if (src.getAudioData() instanceof AudioStream) {
        // If the stream is seekable, then rewind it.
        // Otherwise, close it, as it is no longer valid.
        AudioStream stream = (AudioStream)src.getAudioData();
        if (stream.isSeekable()) {
          stream.setTime(0);
        } else {
          stream.close();
        }
      }
    }
  }
}
origin: jMonkeyEngine/jmonkeyengine

private void setSourceParams(int id, AudioSource src, boolean forceNonLoop) {
  if (src.isPositional()) {
    Vector3f pos = src.getPosition();
    Vector3f vel = src.getVelocity();
    al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z);
    al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z);
    al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance());
    al.alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance());
    al.alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE);
    if (src.isReverbEnabled() && supportEfx) {
      int filter = EFX.AL_FILTER_NULL;
      if (src.getReverbFilter() != null) {
        Filter f = src.getReverbFilter();
        if (f.isUpdateNeeded()) {
          updateFilter(f);
  if (src.getDryFilter() != null && supportEfx) {
    Filter f = src.getDryFilter();
    if (f.isUpdateNeeded()) {
      updateFilter(f);
  if (forceNonLoop || src.getAudioData() instanceof AudioStream) {
    al.alSourcei(id, AL_LOOPING, AL_FALSE);
  } else {
    al.alSourcei(id, AL_LOOPING, src.isLooping() ? AL_TRUE : AL_FALSE);
  al.alSourcef(id, AL_GAIN, src.getVolume());
  al.alSourcef(id, AL_PITCH, src.getPitch());
  al.alSourcef(id, AL_SEC_OFFSET, src.getTimeOffset());
origin: jMonkeyEngine/jmonkeyengine

public void pauseSource(AudioSource src) {
  checkDead();
  synchronized (threadLock) {
    if (audioDisabled) {
      return;
    }
    if (src.getStatus() == Status.Playing) {
      assert src.getChannel() != -1;
      al.alSourcePause(channels[src.getChannel()]);
      src.setStatus(Status.Paused);
    }
  }
}
origin: jMonkeyEngine/jmonkeyengine

private void clearChannel(int index) {
  // make room at this channel
  if (chanSrcs[index] != null) {
    AudioSource src = chanSrcs[index];
    int sourceId = channels[index];
    al.alSourceStop(sourceId);
    
    // For streaming sources, this will clear all queued buffers.
    al.alSourcei(sourceId, AL_BUFFER, 0);
    if (src.getDryFilter() != null && supportEfx) {
      // detach filter
      al.alSourcei(sourceId, EFX.AL_DIRECT_FILTER, EFX.AL_FILTER_NULL);
    }
    if (src.isPositional()) {
      AudioSource pas = (AudioSource) src;
      if (pas.isReverbEnabled() && supportEfx) {
        al.alSource3i(sourceId, EFX.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX.AL_FILTER_NULL);
      }
    }
    chanSrcs[index] = null;
  }
}
 
origin: jMonkeyEngine/jmonkeyengine

AudioSource src = chanSrcs[i];
if (src == null || !(src.getAudioData() instanceof AudioStream)) {
  continue;
AudioStream stream = (AudioStream) src.getAudioData();
Status jmeStatus = src.getStatus();
boolean buffersWereFilled = fillStreamingSource(sourceId, stream, src.isLooping());
origin: jMonkeyEngine/jmonkeyengine

if (src.getChannel() < 0) {
  return 0;
int id = channels[src.getChannel()];
AudioData data = src.getAudioData();
int playbackOffsetBytes = 0;
origin: net.sf.phat/phat-audio

private boolean hasChanged(AudioSource as) {
  if(audioStatus == null) {
    audioStatus = as.getStatus();
    return false;
  } else if(audioStatus != as.getStatus()) {
    audioStatus = as.getStatus();
    return true;
  }
  return false;
}
origin: jMonkeyEngine/jmonkeyengine

public void playSourceInstance(AudioSource src) {
  checkDead();
  synchronized (threadLock) {
    if (audioDisabled) {
      return;
    }
    if (src.getAudioData() instanceof AudioStream) {
      throw new UnsupportedOperationException(
          "Cannot play instances "
          + "of audio streams. Use play() instead.");
    }
    if (src.getAudioData().isUpdateNeeded()) {
      updateAudioData(src.getAudioData());
    }
    // create a new index for an audio-channel
    int index = newChannel();
    if (index == -1) {
      return;
    }
    int sourceId = channels[index];
    clearChannel(index);
    // set parameters, like position and max distance
    setSourceParams(sourceId, src, true);
    attachAudioToSource(sourceId, src.getAudioData(), false);
    chanSrcs[index] = src;
    // play the channel
    al.alSourcePlay(sourceId);
  }
}
origin: org.jmonkeyengine/jme3-core

public void pauseSource(AudioSource src) {
  checkDead();
  synchronized (threadLock) {
    if (audioDisabled) {
      return;
    }
    if (src.getStatus() == Status.Playing) {
      assert src.getChannel() != -1;
      al.alSourcePause(channels[src.getChannel()]);
      src.setStatus(Status.Paused);
    }
  }
}
origin: org.jmonkeyengine/jme3-core

AudioSource src = chanSrcs[i];
if (src == null || !(src.getAudioData() instanceof AudioStream)) {
  continue;
AudioStream stream = (AudioStream) src.getAudioData();
Status jmeStatus = src.getStatus();
boolean buffersWereFilled = fillStreamingSource(sourceId, stream, src.isLooping());
origin: org.jmonkeyengine/jme3-core

private void clearChannel(int index) {
  // make room at this channel
  if (chanSrcs[index] != null) {
    AudioSource src = chanSrcs[index];
    int sourceId = channels[index];
    al.alSourceStop(sourceId);
    
    // For streaming sources, this will clear all queued buffers.
    al.alSourcei(sourceId, AL_BUFFER, 0);
    if (src.getDryFilter() != null && supportEfx) {
      // detach filter
      al.alSourcei(sourceId, EFX.AL_DIRECT_FILTER, EFX.AL_FILTER_NULL);
    }
    if (src.isPositional()) {
      AudioSource pas = (AudioSource) src;
      if (pas.isReverbEnabled() && supportEfx) {
        al.alSource3i(sourceId, EFX.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX.AL_FILTER_NULL);
      }
    }
    chanSrcs[index] = null;
  }
}
 
origin: org.jmonkeyengine/jme3-core

if (src.getChannel() < 0) {
  return 0;
int id = channels[src.getChannel()];
AudioData data = src.getAudioData();
int playbackOffsetBytes = 0;
origin: org.jmonkeyengine/jme3-core

public void playSourceInstance(AudioSource src) {
  checkDead();
  synchronized (threadLock) {
    if (audioDisabled) {
      return;
    }
    if (src.getAudioData() instanceof AudioStream) {
      throw new UnsupportedOperationException(
          "Cannot play instances "
          + "of audio streams. Use play() instead.");
    }
    if (src.getAudioData().isUpdateNeeded()) {
      updateAudioData(src.getAudioData());
    }
    // create a new index for an audio-channel
    int index = newChannel();
    if (index == -1) {
      return;
    }
    int sourceId = channels[index];
    clearChannel(index);
    // set parameters, like position and max distance
    setSourceParams(sourceId, src, true);
    attachAudioToSource(sourceId, src.getAudioData(), false);
    chanSrcs[index] = src;
    // play the channel
    al.alSourcePlay(sourceId);
  }
}
origin: jMonkeyEngine/jmonkeyengine

if (src.getChannel() < 0) {
  return;
assert src.getChannel() >= 0;
int id = channels[src.getChannel()];
switch (param) {
  case Position:
    if (!src.isPositional()) {
      return;
    Vector3f pos = src.getPosition();
    al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z);
    break;
  case Velocity:
    if (!src.isPositional()) {
      return;
    Vector3f vel = src.getVelocity();
    al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z);
    break;
  case MaxDistance:
    if (!src.isPositional()) {
      return;
    al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance());
    break;
  case RefDistance:
    if (!src.isPositional()) {
origin: jMonkeyEngine/jmonkeyengine

if (src.getStatus() == Status.Playing) {
  return;
} else if (src.getStatus() == Status.Stopped) {
  src.setChannel(index);
  AudioData data = src.getAudioData();
  if (data.isUpdateNeeded()) {
    updateAudioData(data);
  attachAudioToSource(channels[index], data, src.isLooping());
al.alSourcePlay(channels[src.getChannel()]);
src.setStatus(Status.Playing);
origin: org.jmonkeyengine/jme3-core

private void setSourceParams(int id, AudioSource src, boolean forceNonLoop) {
  if (src.isPositional()) {
    Vector3f pos = src.getPosition();
    Vector3f vel = src.getVelocity();
    al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z);
    al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z);
    al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance());
    al.alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance());
    al.alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE);
    if (src.isReverbEnabled() && supportEfx) {
      int filter = EFX.AL_FILTER_NULL;
      if (src.getReverbFilter() != null) {
        Filter f = src.getReverbFilter();
        if (f.isUpdateNeeded()) {
          updateFilter(f);
  if (src.getDryFilter() != null && supportEfx) {
    Filter f = src.getDryFilter();
    if (f.isUpdateNeeded()) {
      updateFilter(f);
  if (forceNonLoop || src.getAudioData() instanceof AudioStream) {
    al.alSourcei(id, AL_LOOPING, AL_FALSE);
  } else {
    al.alSourcei(id, AL_LOOPING, src.isLooping() ? AL_TRUE : AL_FALSE);
  al.alSourcef(id, AL_GAIN, src.getVolume());
  al.alSourcef(id, AL_PITCH, src.getPitch());
  al.alSourcef(id, AL_SEC_OFFSET, src.getTimeOffset());
origin: jMonkeyEngine/jmonkeyengine

boolean boundSource = i == src.getChannel();
boolean reclaimChannel = false;
Status jmeStatus = src.getStatus();
  if (oalStatus == Status.Stopped && jmeStatus == Status.Playing) {
    if (src.getAudioData() instanceof AudioStream) {
      AudioStream stream = (AudioStream) src.getAudioData();
      if (stream.isEOF() && !src.isLooping()) {
      if (src.isLooping()) {
      src.setStatus(Status.Stopped);
      src.setChannel(-1);
      clearChannel(i);
      freeChannel(i);
origin: org.jmonkeyengine/jme3-core

if (src.getChannel() < 0) {
  return;
assert src.getChannel() >= 0;
int id = channels[src.getChannel()];
switch (param) {
  case Position:
    if (!src.isPositional()) {
      return;
    Vector3f pos = src.getPosition();
    al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z);
    break;
  case Velocity:
    if (!src.isPositional()) {
      return;
    Vector3f vel = src.getVelocity();
    al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z);
    break;
  case MaxDistance:
    if (!src.isPositional()) {
      return;
    al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance());
    break;
  case RefDistance:
    if (!src.isPositional()) {
origin: org.jmonkeyengine/jme3-core

public void stopSource(AudioSource src) {
  synchronized (threadLock) {
    if (audioDisabled) {
      return;
    }
    if (src.getStatus() != Status.Stopped) {
      int chan = src.getChannel();
      assert chan != -1; // if it's not stopped, must have id
      src.setStatus(Status.Stopped);
      src.setChannel(-1);
      clearChannel(chan);
      freeChannel(chan);
      
      if (src.getAudioData() instanceof AudioStream) {
        // If the stream is seekable, then rewind it.
        // Otherwise, close it, as it is no longer valid.
        AudioStream stream = (AudioStream)src.getAudioData();
        if (stream.isSeekable()) {
          stream.setTime(0);
        } else {
          stream.close();
        }
      }
    }
  }
}
origin: org.jmonkeyengine/jme3-core

if (src.getStatus() == Status.Playing) {
  return;
} else if (src.getStatus() == Status.Stopped) {
  src.setChannel(index);
  AudioData data = src.getAudioData();
  if (data.isUpdateNeeded()) {
    updateAudioData(data);
  attachAudioToSource(channels[index], data, src.isLooping());
al.alSourcePlay(channels[src.getChannel()]);
src.setStatus(Status.Playing);
com.jme3.audioAudioSource

Most used methods

  • getStatus
  • getAudioData
  • getChannel
    Do not use.
  • getDirection
  • getDryFilter
  • getInnerAngle
  • getMaxDistance
  • getOuterAngle
  • getPitch
  • getPosition
  • getRefDistance
  • getReverbFilter
  • getRefDistance,
  • getReverbFilter,
  • getTimeOffset,
  • getVelocity,
  • getVolume,
  • isDirectional,
  • isLooping,
  • isPositional,
  • isReverbEnabled,
  • setChannel

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • ImageIO (javax.imageio)
  • JPanel (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now