Skip to content

Commit

Permalink
Fix integer overflow on large wav files and issue #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
daw3rd committed Aug 17, 2022
1 parent 48a2283 commit ff3e0e5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static double[] pcm2Double(byte[] samples, int channels, int bitsPerSampl
throw new IllegalArgumentException("bits per sample must be 8, 16,24, or 32");
if (channels <= 0)
throw new IllegalArgumentException("channels must be larger than 0");
int sampleCount = samples.length * 8 / (bitsPerSample * channels);
int sampleCount = samples.length / bitsPerSample / channels * 8;
double result[] = new double[sampleCount];
ByteBuffer byteBuffer = ByteBuffer.wrap(samples);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
Expand Down

0 comments on commit ff3e0e5

Please sign in to comment.