Skip to content

Commit 07136b0

Browse files
committed
Fix sample cutoff when offset is applied
1 parent 2524b86 commit 07136b0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

core/src/voice/sampler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<Sampler: BufferSampler> SampleReader for SampleReaderNoLoop<Sampler> {
119119

120120
fn is_past_end(&self, pos: usize) -> bool {
121121
if let Some(len) = self.length {
122-
pos - self.offset >= len
122+
pos - self.offset.min(pos) >= len
123123
} else {
124124
false
125125
}
@@ -198,20 +198,20 @@ impl<Sampler: BufferSampler> SampleReader for SampleReaderLoopSustain<Sampler> {
198198
let start = self.loop_start;
199199

200200
if !self.is_released {
201-
self.last = pos;
202201
if pos > end {
203202
pos = (pos - end - 1) % (end - start) + start;
203+
self.last = pos;
204204
}
205205
} else {
206-
pos = pos - self.last + self.loop_end;
206+
pos -= self.last;
207207
}
208208

209209
self.buffer.get(pos)
210210
}
211211

212212
fn is_past_end(&self, pos: usize) -> bool {
213213
if let Some(len) = self.length {
214-
pos - self.last - self.offset >= len
214+
pos - (self.last - self.offset).min(pos) >= len
215215
} else {
216216
false
217217
}

0 commit comments

Comments
 (0)