/** Move the listener with the a camera - for 3D audio. */ @Override public void simpleUpdate(float tpf) { listener.setLocation(cam.getLocation()); listener.setRotation(cam.getRotation()); }
private void initAudio(){ if (settings.getAudioRenderer() != null && context.getType() != JmeContext.Type.Headless){ audioRenderer = JmeSystem.newAudioRenderer(settings); audioRenderer.initialize(); AudioContext.setAudioRenderer(audioRenderer); listener = new Listener(); audioRenderer.setListener(listener); } }
private void setListenerParams(Listener listener) { Vector3f pos = listener.getLocation(); Vector3f vel = listener.getVelocity(); Vector3f dir = listener.getDirection(); Vector3f up = listener.getUp(); al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z); al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); fb.rewind(); fb.put(dir.x).put(dir.y).put(dir.z); fb.put(up.x).put(up.y).put(up.z); fb.flip(); al.alListener(AL_ORIENTATION, fb); al.alListenerf(AL_GAIN, listener.getVolume()); }
@Override public void render(RenderManager rm) { if (!isEnabled() || listener == null) { return; } Vector3f lastLocation = listener.getLocation(); Vector3f currentLocation = camera.getLocation(); Vector3f velocity = listener.getVelocity(); if (!lastLocation.equals(currentLocation)) { velocity.set(currentLocation).subtractLocal(lastLocation); velocity.multLocal(1f / lastTpf); listener.setLocation(currentLocation); listener.setVelocity(velocity); } else if (!velocity.equals(Vector3f.ZERO)) { listener.setVelocity(Vector3f.ZERO); } Quaternion lastRotation = listener.getRotation(); Quaternion currentRotation = camera.getRotation(); if (!lastRotation.equals(currentRotation)) { listener.setRotation(currentRotation); } }
private void prepareEar(Geometry ear, int n){ if (this.audioRenderer instanceof MultiListener){ MultiListener rf = (MultiListener)this.audioRenderer; Listener auxListener = new Listener(); auxListener.setLocation(ear.getLocalTranslation()); rf.addListener(auxListener); WaveFileWriter aux = null; try { aux = new WaveFileWriter (new File("advanced-audio-" + n + ".wav"));} catch (IOException e) {e.printStackTrace();} rf.registerSoundProcessor (auxListener, new CompositeSoundProcessor(new Dancer(ear), aux)); } }
@Override public void render(RenderManager rm) { if (!isEnabled() || listener == null) { return; } Vector3f lastLocation = listener.getLocation(); Vector3f currentLocation = camera.getLocation(); Vector3f velocity = listener.getVelocity(); if (!lastLocation.equals(currentLocation)) { velocity.set(currentLocation).subtractLocal(lastLocation); velocity.multLocal(1f / lastTpf); listener.setLocation(currentLocation); listener.setVelocity(velocity); } else if (!velocity.equals(Vector3f.ZERO)) { listener.setVelocity(Vector3f.ZERO); } Quaternion lastRotation = listener.getRotation(); Quaternion currentRotation = camera.getRotation(); if (!lastRotation.equals(currentRotation)) { listener.setRotation(currentRotation); } }
@Override protected void controlUpdate(float tpf) { if (listener != null) { listener.setLocation(spatial.getWorldTranslation()); listener.setRotation(spatial.getWorldRotation()); } }
public void updateListenerParam(Listener listener, ListenerParam param) { checkDead(); synchronized (threadLock) { if (audioDisabled) { return; } switch (param) { case Position: Vector3f pos = listener.getLocation(); al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z); break; case Rotation: Vector3f dir = listener.getDirection(); Vector3f up = listener.getUp(); fb.rewind(); fb.put(dir.x).put(dir.y).put(dir.z); fb.put(up.x).put(up.y).put(up.z); fb.flip(); al.alListener(AL_ORIENTATION, fb); break; case Velocity: Vector3f vel = listener.getVelocity(); al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); break; case Volume: al.alListenerf(AL_GAIN, listener.getVolume()); break; } } }
private void initAudio(){ if (settings.getAudioRenderer() != null && context.getType() != Type.Headless){ audioRenderer = JmeSystem.newAudioRenderer(settings); audioRenderer.initialize(); AudioContext.setAudioRenderer(audioRenderer); listener = new Listener(); audioRenderer.setListener(listener); } }
public void simpleUpdateAbstract(float tpf) { // Update the SoundListener to the CamLocation and Rotation listener.setLocation(cam.getLocation()); listener.setRotation(cam.getRotation()); }
private void setListenerParams(Listener listener) { Vector3f pos = listener.getLocation(); Vector3f vel = listener.getVelocity(); Vector3f dir = listener.getDirection(); Vector3f up = listener.getUp(); al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z); al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); fb.rewind(); fb.put(dir.x).put(dir.y).put(dir.z); fb.put(up.x).put(up.y).put(up.z); fb.flip(); al.alListener(AL_ORIENTATION, fb); al.alListenerf(AL_GAIN, listener.getVolume()); }
private void initAudio(){ if (settings.getAudioRenderer() != null && context.getType() != Type.Headless){ audioRenderer = JmeSystem.newAudioRenderer(settings); audioRenderer.initialize(); AudioContext.setAudioRenderer(audioRenderer); listener = new Listener(); audioRenderer.setListener(listener); } }
@Override protected void controlUpdate(float tpf) { if (!init) { init(); } if (listener != null) { listener.setLocation(spatial.getWorldTranslation()); listener.setRotation(spatial.getWorldRotation()); } }
public void updateListenerParam(Listener listener, ListenerParam param) { checkDead(); synchronized (threadLock) { if (audioDisabled) { return; } switch (param) { case Position: Vector3f pos = listener.getLocation(); al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z); break; case Rotation: Vector3f dir = listener.getDirection(); Vector3f up = listener.getUp(); fb.rewind(); fb.put(dir.x).put(dir.y).put(dir.z); fb.put(up.x).put(up.y).put(up.z); fb.flip(); al.alListener(AL_ORIENTATION, fb); break; case Velocity: Vector3f vel = listener.getVelocity(); al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); break; case Volume: al.alListenerf(AL_GAIN, listener.getVolume()); break; } } }
private void initAudio(){ if (settings.getAudioRenderer() != null && context.getType() != Type.Headless){ audioRenderer = JmeSystem.newAudioRenderer(settings); audioRenderer.initialize(); AudioContext.setAudioRenderer(audioRenderer); listener = new Listener(); audioRenderer.setListener(listener); } }
@Override public void update(float tpf) { // Update audio listener position app.getListener().setLocation(app.getCamera().getLocation()); app.getListener().setRotation(app.getCamera().getRotation()); }
@Override public void update(float tpf) { super.update(tpf); // Update audio listener position app.getListener().setLocation(app.getCamera().getLocation()); app.getListener().setRotation(app.getCamera().getRotation()); }
@Override public void simpleUpdate(float tpf) { motionTimer.update(); if (music.getStatus() != AudioSource.Status.Playing) { music.play(); } Vector3f loc = cam.getLocation(); Quaternion rot = cam.getRotation(); listener.setLocation(loc); listener.setRotation(rot); music.setLocalTranslation(bell.getLocalTranslation()); }
public void simpleUpdate(float tpf) { motionTimer.update(); if (music.getStatus() != AudioSource.Status.Playing){ music.play(); } Vector3f loc = cam.getLocation(); Quaternion rot = cam.getRotation(); listener.setLocation(loc); listener.setRotation(rot); music.setLocalTranslation(bell.getLocalTranslation()); } }
@Override public void simpleUpdate(float tpf) { super.simpleUpdate(tpf); motionTimer.update(); if (music.getStatus() != AudioSource.Status.Playing) { music.play(); } Vector3f loc = cam.getLocation(); Quaternion rot = cam.getRotation(); listener.setLocation(loc); listener.setRotation(rot); music.setLocalTranslation(bell.getLocalTranslation()); }