mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: reenable sampling
This commit is contained in:
parent
e9c825e865
commit
efd182f302
6 changed files with 61 additions and 38 deletions
|
|
@ -1,10 +1,12 @@
|
|||
use crate::*;
|
||||
|
||||
pub type MaybeSample = Option<Arc<RwLock<Sample>>>;
|
||||
|
||||
/// The sampler device plays sounds in response to MIDI notes.
|
||||
#[derive(Debug)]
|
||||
pub struct Sampler {
|
||||
pub name: String,
|
||||
pub mapped: [Option<Arc<RwLock<Sample>>>;128],
|
||||
pub mapped: [MaybeSample;128],
|
||||
pub recording: Option<(usize, Arc<RwLock<Sample>>)>,
|
||||
pub unmapped: Vec<Arc<RwLock<Sample>>>,
|
||||
pub voices: Arc<RwLock<Vec<Voice>>>,
|
||||
|
|
@ -14,7 +16,7 @@ pub struct Sampler {
|
|||
pub audio_outs: Vec<JackAudioOut>,
|
||||
pub buffer: Vec<Vec<f32>>,
|
||||
pub output_gain: f32,
|
||||
pub editing: Option<Arc<RwLock<Sample>>>,
|
||||
pub editing: MaybeSample,
|
||||
pub mode: Option<SamplerMode>,
|
||||
/// Size of actual notes area
|
||||
pub size: Measure<TuiOut>,
|
||||
|
|
@ -83,7 +85,7 @@ impl Sampler {
|
|||
Arc::new(RwLock::new(Sample::new("Sample", 0, 0, vec![vec![];self.audio_ins.len()])))
|
||||
));
|
||||
}
|
||||
pub fn finish_recording (&mut self) -> Option<Arc<RwLock<Sample>>> {
|
||||
pub fn finish_recording (&mut self) -> MaybeSample {
|
||||
let recording = self.recording.take();
|
||||
if let Some((index, sample)) = recording {
|
||||
let old = self.mapped[index].clone();
|
||||
|
|
@ -111,6 +113,13 @@ impl Sampler {
|
|||
pub fn cursor (&self) -> (usize, usize) {
|
||||
(self.cursor.0.load(Relaxed), self.cursor.1.load(Relaxed))
|
||||
}
|
||||
/// Assign sample to pitch
|
||||
pub fn set_sample (&mut self, pitch: u7, sample: MaybeSample) -> MaybeSample {
|
||||
let i = pitch.as_int() as usize;
|
||||
let old = self.mapped[i].clone();
|
||||
self.mapped[i] = sample;
|
||||
old
|
||||
}
|
||||
}
|
||||
|
||||
impl NoteRange for Sampler {
|
||||
|
|
@ -123,8 +132,12 @@ impl NoteRange for Sampler {
|
|||
}
|
||||
|
||||
impl NotePoint for Sampler {
|
||||
fn note_len (&self) -> usize { 0/*TODO*/ }
|
||||
fn set_note_len (&self, x: usize) -> usize { 0 /*TODO*/ }
|
||||
fn note_len (&self) -> usize {
|
||||
0 /*TODO?*/
|
||||
}
|
||||
fn set_note_len (&self, x: usize) -> usize {
|
||||
0 /*TODO?*/
|
||||
}
|
||||
fn note_pos (&self) -> usize {
|
||||
self.note_pt.load(Relaxed)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue