Restructured project for separate plugins

This commit is contained in:
Ebu
2025-12-04 09:34:55 +01:00
parent 3cf22b7189
commit 28f14ba713
29 changed files with 364 additions and 248 deletions

38
dsp/src/ring_buffer.rs Normal file
View File

@@ -0,0 +1,38 @@
use std::ops::{Index, IndexMut};
pub struct RingBuffer<T, const N: usize> {
buffer: [T; N],
index: usize,
}
impl<T, const N: usize> RingBuffer<T, N>
where
T: Copy,
{
pub const fn new(value: T) -> Self {
Self {
buffer: [value; N],
index: 0,
}
}
pub const fn len(&self) -> usize {
N
}
pub fn shift(&mut self) {
self.index = (self.index + 1) % N;
}
}
impl<T, const N: usize> Index<usize> for RingBuffer<T, N> {
type Output = T;
fn index(&self, index: usize) -> &Self::Output {
&self.buffer[(self.index + index) % N]
}
}
impl<T, const N: usize> IndexMut<usize> for RingBuffer<T, N> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
&mut self.buffer[(self.index + index) % N]
}
}