bbx_dsp/reader.rs
1//! Audio file reader trait.
2//!
3//! This module defines the [`Reader`] trait for reading audio file data.
4//! Implementations are provided by the `bbx_file` crate (e.g., WAV reader).
5
6use crate::sample::Sample;
7
8/// Trait for reading audio data from files.
9///
10/// Implementations should load audio data on construction and provide
11/// access to the decoded samples via [`read_channel`](Self::read_channel).
12pub trait Reader<S: Sample>: Send + Sync {
13 /// Get the sample rate of the audio file being read.
14 fn sample_rate(&self) -> f64;
15
16 /// Get the number of channels in the audio file being read.
17 fn num_channels(&self) -> usize;
18
19 /// Get the number of samples in the audio file being read.
20 fn num_samples(&self) -> usize;
21
22 /// Read samples from a specific channel of the audio file.
23 fn read_channel(&self, channel_index: usize) -> &[S];
24}