public void tick() { soundBuffer.clear(); // targetAmplitude = (targetAmplitude - 1) * 0.9f + 1; // targetAmplitude = (targetAmplitude - 1) * 0.9f + 1; synchronized (listenerMixer) { float maxAmplitude = listenerMixer.read(leftBuf, rightBuf, rate); // if (maxAmplitude > targetAmplitude) targetAmplitude = maxAmplitude; } soundBuffer.clear(); float gain = 32000; for (int i = 0; i < bufferSize; i++) { // amplitude += (targetAmplitude - amplitude) / rate; // amplitude = 1; // float gain = 30000; int l = (int) (leftBuf[i] * gain); int r = (int) (rightBuf[i] * gain); if (l > 32767) l = 32767; if (r > 32767) r = 32767; if (l < -32767) l = -32767; if (r < -32767) r = -32767; soundBuffer.putShort((short) l); soundBuffer.putShort((short) r); } sdl.write(soundBuffer.array(), 0, bufferSize * 2 * 2); }
public void play( SonarSample sample, SoundSource soundSource, float volume, float priority, float rate) { synchronized (listenerMixer) { if (!dk.itu.mario.engine.Art.mute) listenerMixer.addSoundProducer( new SamplePlayer((SonarSample) sample, rate), soundSource, volume, priority); } }
public void clientTick(float alpha) { synchronized (listenerMixer) { listenerMixer.update(alpha); } }
public void setListener(SoundListener soundListener) { listenerMixer.setSoundListener(soundListener); }