mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
display/play/stop transport
This commit is contained in:
parent
265dc13248
commit
1f928fba9d
8 changed files with 251 additions and 177 deletions
|
|
@ -14,23 +14,62 @@ pub const ACTIONS: [(&'static str, &'static str);3] = [
|
|||
|
||||
pub struct Transport {
|
||||
exited: bool,
|
||||
sample_rate: u64,
|
||||
position: u64,
|
||||
bpm: f64,
|
||||
title: String,
|
||||
client: ::jack::Client,
|
||||
transport: ::jack::Transport,
|
||||
//position: Arc<Mutex<Option<TransportStatePosition>>>,
|
||||
//poll_thread: std::thread::JoinHandle<()>,
|
||||
}
|
||||
|
||||
impl Transport {
|
||||
pub fn new () -> Result<Self, Box<dyn Error>> {
|
||||
let (client, status) = Client::new(
|
||||
"bloop_transport_client",
|
||||
ClientOptions::NO_START_SERVER
|
||||
)?;
|
||||
// Poll transport state every 10ms
|
||||
//let poll = std::time::Duration::from_millis(16);
|
||||
//let poll_thread = {
|
||||
//let transport = transport.clone();
|
||||
//let position = position.clone();
|
||||
//std::thread::spawn(move || loop {
|
||||
//std::thread::sleep(poll);
|
||||
//match transport.query() {
|
||||
//Ok(state) => *position.lock().unwrap() = Some(state),
|
||||
//Err(error) => {
|
||||
//*position.lock().unwrap() = None;
|
||||
////println!("{error:?}");
|
||||
//}
|
||||
//}
|
||||
//})
|
||||
//};
|
||||
Ok(Self {
|
||||
exited: false,
|
||||
sample_rate: 48000,
|
||||
position: 0,
|
||||
bpm: 120.0
|
||||
exited: false,
|
||||
title: String::from("Untitled project"),
|
||||
transport: client.transport(),
|
||||
client,
|
||||
//position,
|
||||
//poll_thread
|
||||
})
|
||||
}
|
||||
|
||||
pub fn play_from_start_or_stop_and_rewind (&mut self) {
|
||||
}
|
||||
pub fn play_or_pause (&mut self) {
|
||||
|
||||
pub fn play_or_pause (&mut self) -> Result<(), Box<dyn Error>> {
|
||||
match self.transport.query_state()? {
|
||||
TransportState::Stopped => self.play(),
|
||||
TransportState::Rolling => self.stop(),
|
||||
_ => Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play (&mut self) -> Result<(), Box<dyn Error>> {
|
||||
Ok(self.transport.start()?)
|
||||
}
|
||||
|
||||
pub fn stop (&mut self) -> Result<(), Box<dyn Error>> {
|
||||
Ok(self.transport.stop()?)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue