wip: refactor pt.8, 512 errors lol

This commit is contained in:
🪞👃🪞 2024-11-10 15:40:45 +01:00
parent a1818a8504
commit a784f7a6f2
19 changed files with 238 additions and 183 deletions

View file

@ -1 +0,0 @@
use crate::*;

View file

@ -1,4 +1,4 @@
use scene::*;
use crate::*;
pub struct Arrangement {
/// JACK client handle (needs to not be dropped for standalone mode to work).
@ -56,8 +56,8 @@ pub enum ArrangementCommand {
Go(Direction),
Edit(Option<Arc<RwLock<Phrase>>>),
Scene(SceneCommand),
Track(TrackCommand),
Clip(ClipCommand),
Track(ArrangementTrackCommand),
Clip(ArrangementClipCommand),
}
#[derive(Clone)]

View file

@ -1,4 +1,4 @@
pub(crate) use tek_core::*;
pub use tek_core::*;
pub(crate) use tek_core::midly::{*, live::LiveEvent, num::u7};
pub(crate) use std::thread::JoinHandle;
pub(crate) use std::fmt::{Debug, Formatter, Error};
@ -9,6 +9,8 @@ pub(crate) use tek_core::jack::{
};
submod! {
api_jack
arrange
clock
mixer
phrase
@ -16,14 +18,13 @@ submod! {
plugin_kind
plugin_lv2
pool
sampler
sample
scene scene_cmd
sampler
scene
scene_cmd
sequencer
track
transport transport_cmd
transport
transport_cmd
voice
api_cmd
api_jack
}

View file

@ -10,6 +10,17 @@ pub struct Transport {
pub metronome: bool,
}
impl Debug for Transport {
fn fmt (&self, f: &mut Formatter<'_>) -> std::result::Result<(), Error> {
f.debug_struct("transport")
.field("jack", &self.jack)
.field("transport", &"(JACK transport)")
.field("clock", &self.clock)
.field("metronome", &self.metronome)
.finish()
}
}
impl Audio for Transport {
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
let times = scope.cycle_times().unwrap();
@ -41,3 +52,22 @@ impl Audio for Transport {
Control::Continue
}
}
impl Transport {
pub fn toggle_play (&mut self) -> Usually<()> {
let playing = self.clock.playing.read().unwrap().expect("1st sample has not been processed yet");
let playing = match playing {
TransportState::Stopped => {
self.transport.start()?;
Some(TransportState::Starting)
},
_ => {
self.transport.stop()?;
self.transport.locate(0)?;
Some(TransportState::Stopped)
},
};
*self.clock.playing.write().unwrap() = playing;
Ok(())
}
}