groovebox: autoslice!

This commit is contained in:
🪞👃🪞 2025-05-15 04:10:58 +03:00
parent 5a360d02fa
commit 7495dd10f2
3 changed files with 36 additions and 26 deletions

View file

@ -12,9 +12,14 @@
(layer "./keys_global.edn")) (layer "./keys_global.edn"))
(view (bsp/a :view-dialog (bsp/w :view-meters-output (bsp/e :view-meters-input (view (bsp/a :view-dialog (bsp/w :view-meters-output (bsp/e :view-meters-input
(bsp/n (fixed/y 6 (bsp/e :view-sample-status :view-sample-viewer)) (bsp/n
(fixed/y :h-sample-detail
(bsp/e (fill/y (fixed/x 20 (align/nw :view-sample-status)))
:view-sample-viewer))
(bsp/e (bsp/e
(fill/y (align/n (bsp/s :view-status-v (bsp/s (fill/y (align/n
(bsp/s :view-midi-ports-status :view-audio-ports-status) (bsp/s :view-status-v
(bsp/n :view-editor-status :view-pool))))) (bsp/s :view-midi-ports-status :view-audio-ports-status))))
(bsp/e :view-samples-keys :view-editor))))))) (bsp/w
(bsp/s :view-editor-status :view-pool)
(bsp/e :view-samples-keys :view-editor))))))))

View file

@ -189,6 +189,9 @@ impl App {
fn w_sidebar (&self) -> u16 { fn w_sidebar (&self) -> u16 {
self.project.w_sidebar(self.editor.is_some()) self.project.w_sidebar(self.editor.is_some())
} }
fn h_sample_detail (&self) -> u16 {
4.max(self.height() as u16 * 3 / 9)
}
fn focus_editor (&self) -> bool { fn focus_editor (&self) -> bool {
self.is_editing() self.is_editing()
} }

View file

@ -50,20 +50,22 @@ impl Sampler {
#[tengri_proc::command(Sampler)] #[tengri_proc::command(Sampler)]
impl SamplerCommand { impl SamplerCommand {
fn record_toggle (sampler: &mut Sampler, sample: usize) -> Perhaps<Self> { fn record_toggle (sampler: &mut Sampler, slot: usize) -> Perhaps<Self> {
if sampler.recording.is_some() { let recording = sampler.recording.as_ref().map(|x|x.0);
Self::record_finish(sampler) Self::record_finish(sampler);
// autoslice: continue recording at next slot
if recording != Some(slot) {
Self::record_begin(sampler, slot)
} else { } else {
Self::record_begin(sampler, sample) Ok(None)
} }
} }
fn record_begin (sampler: &mut Sampler, pitch: usize) -> Perhaps<Self> { fn record_begin (sampler: &mut Sampler, slot: usize) -> Perhaps<Self> {
sampler.recording = Some(( sampler.recording = Some((
pitch, slot,
Arc::new(RwLock::new(Sample::new( Arc::new(RwLock::new(Sample::new(
"Sample", 0, 0, vec![vec![];sampler.audio_ins.len()] "Sample", 0, 0, vec![vec![];sampler.audio_ins.len()]
))) )))
)); ));
Ok(None) Ok(None)
} }
@ -82,39 +84,39 @@ impl SamplerCommand {
sampler.recording = None; sampler.recording = None;
Ok(None) Ok(None)
} }
fn play_sample (sampler: &mut Sampler, pitch: usize) -> Perhaps<Self> { fn play_sample (sampler: &mut Sampler, slot: usize) -> Perhaps<Self> {
if let Some(ref sample) = sampler.mapped[pitch] { if let Some(ref sample) = sampler.mapped[slot] {
sampler.voices.write().unwrap().push(Sample::play(sample, 0, &u7::from(128))); sampler.voices.write().unwrap().push(Sample::play(sample, 0, &u7::from(128)));
} }
Ok(None) Ok(None)
} }
fn stop_sample (sampler: &mut Sampler, pitch: usize) -> Perhaps<Self> { fn stop_sample (sampler: &mut Sampler, slot: usize) -> Perhaps<Self> {
todo!(); todo!();
Ok(None) Ok(None)
} }
//fn select (&self, state: &mut Sampler, i: usize) -> Option<Self> { //fn select (&self, state: &mut Sampler, i: usize) -> Option<Self> {
//Self::Select(state.set_note_pos(i)) //Self::Select(state.set_note_pos(i))
//} //}
///// Assign sample to pitch ///// Assign sample to slot
//fn set (&self, pitch: u7, sample: Option<Arc<RwLock<Sample>>>) -> Option<Self> { //fn set (&self, slot: u7, sample: Option<Arc<RwLock<Sample>>>) -> Option<Self> {
//let i = pitch.as_int() as usize; //let i = slot.as_int() as usize;
//let old = self.mapped[i].clone(); //let old = self.mapped[i].clone();
//self.mapped[i] = sample; //self.mapped[i] = sample;
//Some(Self::Set(old)) //Some(Self::Set(old))
//} //}
//fn set_start (&self, state: &mut Sampler, pitch: u7, frame: usize) -> Option<Self> { //fn set_start (&self, state: &mut Sampler, slot: u7, frame: usize) -> Option<Self> {
//todo!() //todo!()
//} //}
//fn set_gain (&self, state: &mut Sampler, pitch: u7, g: f32) -> Option<Self> { //fn set_gain (&self, state: &mut Sampler, slot: u7, g: f32) -> Option<Self> {
//todo!() //todo!()
//} //}
//fn note_on (&self, state: &mut Sampler, pitch: u7, v: u7) -> Option<Self> { //fn note_on (&self, state: &mut Sampler, slot: u7, v: u7) -> Option<Self> {
//todo!() //todo!()
//} //}
//fn note_off (&self, state: &mut Sampler, pitch: u7) -> Option<Self> { //fn note_off (&self, state: &mut Sampler, slot: u7) -> Option<Self> {
//todo!() //todo!()
//} //}
//fn set_sample (&self, state: &mut Sampler, pitch: u7, s: Option<Arc<RwLock<Sample>>>) -> Option<Self> { //fn set_sample (&self, state: &mut Sampler, slot: u7, s: Option<Arc<RwLock<Sample>>>) -> Option<Self> {
//Some(Self::SetSample(p, state.set_sample(p, s))) //Some(Self::SetSample(p, state.set_sample(p, s)))
//} //}
//fn import (&self, state: &mut Sampler, c: FileBrowserCommand) -> Option<Self> { //fn import (&self, state: &mut Sampler, c: FileBrowserCommand) -> Option<Self> {
@ -169,9 +171,9 @@ impl SamplerCommand {
////("set/gain" [i: u7, g: f32] ////("set/gain" [i: u7, g: f32]
////Some(Self::SetGain(i.expect("no index"), g.expect("no gain")))) ////Some(Self::SetGain(i.expect("no index"), g.expect("no gain"))))
////("note/on" [p: u7, v: u7] ////("note/on" [p: u7, v: u7]
////Some(Self::NoteOn(p.expect("no pitch"), v.expect("no velocity")))) ////Some(Self::NoteOn(p.expect("no slot"), v.expect("no velocity"))))
////("note/off" [p: u7] ////("note/off" [p: u7]
////Some(Self::NoteOff(p.expect("no pitch")))))); ////Some(Self::NoteOff(p.expect("no slot"))))));
} }
#[tengri_proc::command(Sampler)] #[tengri_proc::command(Sampler)]