diff --git a/src/nodes/note_buffer.rs b/src/nodes/note_buffer.rs new file mode 100644 index 0000000..9c3e98f --- /dev/null +++ b/src/nodes/note_buffer.rs @@ -0,0 +1,40 @@ +// Copyright (c) 2022 Weird Constructor +// This file is a part of HexoDSP. Released under GPL-3.0-or-later. +// See README.md and COPYING for details. + +use crate::dsp::MAX_BLOCK_SIZE; +use crate::util::Smoother; + +#[derive(Debug, Clone, Copy)] +pub struct ChannelState { + vel: f32, + pitch: u8, + gate: u8, +} + +pub struct NoteBuffer { + interleaved_chans: Vec, + buf_idx: usize, +} + +impl NoteBuffer { + pub fn new() -> Self { + Self { + interleaved_chans: vec![ChannelState::new(); 16 * MAX_BLOCK_SIZE], + buf_idx: 15, + } + } + + #[inline] + pub fn step(&mut self) { + let cur = self.buf_idx; + let next = (self.buf_idx + 1) % 16; + self.interleaved_chans.copy_within((cur * 16)..((cur + 1) * 16), next * 16); + } + +// pub fn play_velocity(&mut self, channel: u8, vel: f32) { +// let mut vel = &mut self.velocity[channel % 16]; +// vel.set(vel.current(), vel); +// } +} +