Esempio n. 1
0
  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);
  }
Esempio n. 2
0
 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);
   }
 }
Esempio n. 3
0
 public void clientTick(float alpha) {
   synchronized (listenerMixer) {
     listenerMixer.update(alpha);
   }
 }
Esempio n. 4
0
 public void setListener(SoundListener soundListener) {
   listenerMixer.setSoundListener(soundListener);
 }