public Wave extractWaveByUnit(File sound, Integer wavePointsPerS) {
    if (null == sound || !sound.exists()) {
      throw new RuntimeException("File not found.");
    }

    wavePointsPerS = (null == wavePointsPerS) ? 15 : wavePointsPerS;
    AudioInputStream sourceStream = null;
    try {
      sourceStream = AudioSystem.getAudioInputStream(sound);
      int numChannels = sourceStream.getFormat().getChannels();
      int sampleInterval =
          (int) (sourceStream.getFormat().getSampleRate() / (wavePointsPerS * numChannels));
      int frameLength = (int) sourceStream.getFrameLength();
      int frameSize = (int) sourceStream.getFormat().getFrameSize();
      int sampleLength =
          (int) ((sourceStream.getFormat().getSampleRate() / sourceStream.getFormat()
              .getFrameRate()) * frameLength);

      byte[] eightBitByteArray = new byte[frameLength * frameSize];
      sourceStream.read(eightBitByteArray);

      float[][] waveData =
          extractWaveData(sampleLength / sampleInterval, sourceStream, numChannels, sampleLength,
              sampleInterval, eightBitByteArray);

      return new Wave(waveData);
    } catch (UnsupportedAudioFileException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }