title: Android pulse an icon when .wav volume changes
body: <p>I'm building an android app that pulses an icon - simple pulse, 2x size at loudest volume and 1x at no volume - based on audio. Worth noting my min api is 15.</p>
  
  <p>The user selects the mode (file)to play and I use AudioTrack to play it back on an infinite loop.  Each wav sample ranges from &lt; second to 2 or 3 seconds. Audiotrack lets me set the volume and pitch in real-time based on user input (SoundPool wasn't correctly changing pitch in Kitkat).
  As the volume changes within each audiotrack, I'm trying to shrink and grow the icon.  So far I've tried visualizer to get the waveform and fft data as the track is playing, but I'm not sure that's correct.</p>
  
  <p>Is there a way to get the (nearest possible) real-time db changes from an audiotrack? The wave form function seems to always be between 108 and 112, so I don't think I'm using it correctly. The easiest pulse.wav example is <a href="https://www.dropbox.com/s/gwt1ru3vzcb9p8j/pulse.wav?dl=0" rel="nofollow">here</a></p>
  
  <p>My audiotrack init using a byte[] from pcm data</p>
  
  <pre><code>AudioTrack mAudioTrack = new AudioTrack(AudioAudioManager.STREAM_MUSIC, sampleRate, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT, getMinBuffer(sound), AudioTrack.MODE_STATIC);
  mAudioTrack.write(mSound, 0, mSound.length);
  mAudioTrack.setLoopPoints(0, (int)(mSound.length / 4), -1);
  </code></pre>
  
  <p>My Visualizer </p>
  
  <pre><code>Visualizer mVisualizer = new Visualizer(mAudioTrack.getAudioSessionId());
  mVisualizer.setEnabled(false);
  mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
  mVisualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener {
      @Override
      public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
          double sum = 0;
  
          for (int i = 0; i &lt; bytes.length; i++) {
              sum += Math.abs(bytes[i]) * Math.abs(bytes[i]);
          }
  
          double volume = (double) Math.sqrt(1.0d * sum / bytes.length);
          //THIS IS THE RESIZE FUNCTION//
          //resizeHeart((double) volume);
          System.out.println("Volume: " + volume); //always prints out between 108 and 112.
      }
      @Override
      public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
          //not sure what to do here.
      }
  }, Visualizer.getMaxCaptureRate() / 2, true, true);
  mVisualizer.setEnabled(true);
  </code></pre>