Skip to content

Commit bdba6fc

Browse files
committed
Add a note about ControlBuffer size restrictions
It only works by chance. Signed-off-by: Petr Horacek <[email protected]>
1 parent 63dda1a commit bdba6fc

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

eurorack/src/system/control_buffer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ impl<const N: usize> ControlBuffer<N> {
2525
}
2626

2727
pub fn traveled(&self) -> f32 {
28+
// NOTE: This does not panic only thanks to the release mode
29+
// wrapping around instead of exploding on underflow.
30+
// XXX: This works only if N is power of 2.
2831
let newest = (self.pointer - 1).rem_euclid(N);
2932
let oldest = self.pointer;
3033
(self.buffer[newest] - self.buffer[oldest]).abs()

eurorack/src/system/pot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct Pot<A, P> {
1717
pin: P,
1818
input_range: (f32, f32),
1919
toleration: f32,
20+
// XXX: ControlBuffer sizes must be power of 2.
2021
position_filter: ControlBuffer<8>,
2122
movement_detector: ControlBuffer<124>,
2223
_adc: PhantomData<A>,

0 commit comments

Comments
 (0)