@Override
    public void onAudioSamples(IAudioSamplesEvent event) {
            IAudioSamples samples = event.getAudioSamples();
            for (int i = 0; i < samples.getNumSamples(); ++i) {
                int index = (int) (event.getTimeStamp(TimeUnit.SECONDS) / granularity);
                int amplitude = samples.getSample(i, 0, IAudioSamples.Format.FMT_S16);
                if (maxes.get(index) < amplitude) {
                        maxes.set(index, amplitude);
                }
            }

            super.onAudioSamples(event);
    }