mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 15:56:57 +02:00
restruct: 25e
This commit is contained in:
parent
c737c7d839
commit
3bbe52093e
11 changed files with 454 additions and 432 deletions
26
src/device/sampler/sample_kit.rs
Normal file
26
src/device/sampler/sample_kit.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use crate::*;
|
||||
|
||||
/// Collection of samples, one per slot, fixed number of slots.
|
||||
///
|
||||
/// History: Separated to cleanly implement [Default].
|
||||
///
|
||||
/// ```
|
||||
/// let samples = tek::SampleKit([None, None, None, None]);
|
||||
/// ```
|
||||
#[derive(Debug)] pub struct SampleKit <const N: usize> (
|
||||
pub [Option<Arc<RwLock<Sample>>>;N]
|
||||
);
|
||||
|
||||
impl<const N: usize> Default for SampleKit<N> {
|
||||
fn default () -> Self { Self([const { None }; N]) }
|
||||
}
|
||||
|
||||
impl<const N: usize> SampleKit<N> {
|
||||
pub fn get (&self, index: usize) -> &Option<Arc<RwLock<Sample>>> {
|
||||
if index < self.0.len() {
|
||||
&self.0[index]
|
||||
} else {
|
||||
&None
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue