code: private static float calculateDuration(int layer, int sampleRate) {
          int sampleCount = (layer == AudioFrame.LAYER_1) ? SAMPLE_COUNT_L1 : SAMPLE_COUNT_L2;
          return (1000.0f / sampleRate) * sampleCount;
      }
docs: Calculates the duration of a MPEG frame based on the given parameters.
  
  @param layer
  the layer
  @param sampleRate
  the sample rate
  @return the duration of this frame in milliseconds