Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit 5b9673e

Browse files
authored
Merge pull request #8 from carmocca/overflow-fix
Overflow fix
2 parents 9e35f03 + 2e4cd3e commit 5b9673e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ Set raw byte array asynchronously
7575
setRawData(byte[] data, OnSamplingListener callback);
7676
```
7777

78-
In case you have scaled byte array you want to draw
78+
In case you have an scaled byte array you want to draw, as in, an array whose size is the amount of chunks to draw
79+
7980

8081
```java
8182

audiowave/src/main/kotlin/rm/com/audiowave/Sampler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ object Sampler {
3737
}
3838

3939
for (index in 0..data.size step chunkStep) {
40-
val currentDataIndex = targetSize * index / data.size
40+
val currentDataIndex = (targetSize * index.toLong() / data.size).toInt()
4141

4242
if (prevDataIndex == currentDataIndex) {
4343
sampledPerChunk += 1
@@ -70,4 +70,4 @@ internal fun ByteArray.paste(other: ByteArray): ByteArray {
7070
this[i] = other.getOrElse(i, { this[i].abs })
7171
}
7272
}
73-
}
73+
}

0 commit comments

Comments
 (0)