pub struct SampleBuffer {
pub sample_rate: u16,
pub channel_count: usize,
/* private fields */
}Expand description
A buffer of EEG samples for batch processing
Fields§
§sample_rate: u16Sample rate in Hz
channel_count: usizeNumber of channels
Implementations§
Source§impl SampleBuffer
impl SampleBuffer
pub fn new(sample_rate: u16, channel_count: usize) -> Self
Sourcepub fn with_capacity(
sample_rate: u16,
channel_count: usize,
sample_capacity: usize,
) -> Self
pub fn with_capacity( sample_rate: u16, channel_count: usize, sample_capacity: usize, ) -> Self
Create a buffer with pre-allocated capacity
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Number of samples in the buffer
Sourcepub fn duration_secs(&self) -> f32
pub fn duration_secs(&self) -> f32
Duration of data in the buffer (in seconds)
Sourcepub fn push_interleaved(
&mut self,
data: &[f32],
timestamp_start: u64,
sample_rate: u16,
)
pub fn push_interleaved( &mut self, data: &[f32], timestamp_start: u64, sample_rate: u16, )
Add samples from interleaved data (sample-major order) Data format: [s0_ch0, s0_ch1, …, s1_ch0, s1_ch1, …]
Sourcepub fn channel_data(&self, channel: usize) -> &[f32]
pub fn channel_data(&self, channel: usize) -> &[f32]
Get all samples for a specific channel
Sourcepub fn channel_data_mut(&mut self, channel: usize) -> &mut [f32]
pub fn channel_data_mut(&mut self, channel: usize) -> &mut [f32]
Get a mutable reference to channel data
Sourcepub fn recent_channel_data(&self, channel: usize, n: usize) -> &[f32]
pub fn recent_channel_data(&self, channel: usize, n: usize) -> &[f32]
Get the most recent N samples for a channel
Sourcepub fn retain_recent(&mut self, n: usize)
pub fn retain_recent(&mut self, n: usize)
Keep only the most recent N samples
Trait Implementations§
Source§impl Clone for SampleBuffer
impl Clone for SampleBuffer
Source§fn clone(&self) -> SampleBuffer
fn clone(&self) -> SampleBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SampleBuffer
impl RefUnwindSafe for SampleBuffer
impl Send for SampleBuffer
impl Sync for SampleBuffer
impl Unpin for SampleBuffer
impl UnsafeUnpin for SampleBuffer
impl UnwindSafe for SampleBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more