i dont know why that worked

This commit is contained in:
🪞👃🪞 2024-06-16 13:58:46 +03:00
parent 4ae62c5bc2
commit b73aa8a0dc
17 changed files with 552 additions and 481 deletions

View file

@ -2,21 +2,19 @@ use crate::prelude::*;
pub struct Transport {
name: String,
transport: Option<::jack::Transport>,
bpm: f64,
transport: ::jack::Transport,
timesig: (f32, f32),
bpm: f64,
}
impl Transport {
pub fn new ()
-> Result<DynamicDevice<Self>, Box<dyn Error>>
{
//let transport = client.transport();
Ok(DynamicDevice::new(render, handle, |_|{}, Self {
name: "Transport".into(),
bpm: 113.0,
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
let (client, _) = Client::new(name, ClientOptions::NO_START_SERVER)?;
Ok(DynamicDevice::new(render, handle, process, Self {
name: name.into(),
transport: client.transport(),
timesig: (4.0, 4.0),
transport: None,
bpm: 113.0,
}))
}
@ -24,7 +22,7 @@ impl Transport {
}
pub fn play_or_pause (&mut self) -> Result<(), Box<dyn Error>> {
match self.transport.as_ref().unwrap().query_state()? {
match self.transport.query_state()? {
TransportState::Stopped => self.play(),
TransportState::Rolling => self.stop(),
_ => Ok(())
@ -32,14 +30,18 @@ impl Transport {
}
pub fn play (&mut self) -> Result<(), Box<dyn Error>> {
Ok(self.transport.as_ref().unwrap().start()?)
Ok(self.transport.start()?)
}
pub fn stop (&mut self) -> Result<(), Box<dyn Error>> {
Ok(self.transport.as_ref().unwrap().stop()?)
Ok(self.transport.stop()?)
}
}
pub fn process (state: &mut Transport, client: &Client, scope: &ProcessScope) -> Control {
Control::Continue
}
pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
-> Usually<Rect>
{
@ -220,7 +222,7 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
//Ok(())
//}
pub fn handle (state: &mut Transport, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
pub fn handle (state: &mut Transport, event: &AppEvent) -> Result<(), Box<dyn Error>> {
Ok(())
}
@ -231,9 +233,9 @@ pub const ACTIONS: [(&'static str, &'static str);4] = [
("(Shift-)Space", "⯈ Play/pause"),
];
struct Notifications;
struct TransportJack;
impl NotificationHandler for Notifications {
impl NotificationHandler for TransportJack {
fn thread_init (&self, _: &Client) {
}