mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
remove old transport device
This commit is contained in:
parent
f5da2e6dad
commit
a7344f8a72
4 changed files with 59 additions and 146 deletions
|
|
@ -66,82 +66,3 @@ pub fn draw_bpm (buf: &mut Buffer, x: u16, y: u16, bpm: usize) {
|
|||
"1/16"
|
||||
.blit(buf, x + 29, y, Some(style.bold()));
|
||||
}
|
||||
|
||||
pub struct Transport {
|
||||
name: String,
|
||||
/// Holds info about bpm
|
||||
timebase: Arc<Timebase>,
|
||||
|
||||
transport: ::jack::Transport,
|
||||
}
|
||||
|
||||
impl Transport {
|
||||
pub fn new (name: &str, timebase: &Arc<Timebase>) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||
let (client, _) = Client::new(name, ClientOptions::NO_START_SERVER)?;
|
||||
let transport = client.transport();
|
||||
DynamicDevice::new(render, handle, process, Self {
|
||||
name: name.into(), timebase: timebase.clone(), transport
|
||||
}).activate(client)
|
||||
}
|
||||
|
||||
pub fn play_from_start_or_stop_and_rewind (&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()?)
|
||||
}
|
||||
|
||||
pub fn timebase (&self) -> Arc<Timebase> {
|
||||
self.timebase.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process (_: &mut Transport, _: &Client, _: &ProcessScope) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
pub fn handle (_: &mut Transport, _: &AppEvent) -> Usually<bool> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
||||
-> Usually<Rect>
|
||||
{
|
||||
//area.x = area.width.saturating_sub(80) / 2;
|
||||
//area.width = area.width.min(80);
|
||||
area.height = 3;
|
||||
draw_box(buf, area);
|
||||
let label = Style::default().white().not_dim();
|
||||
let border = Style::default().gray().dim();
|
||||
let mut x = 2;
|
||||
for button in [
|
||||
"PLAY",
|
||||
"STOP",
|
||||
"REC",
|
||||
"DUB",
|
||||
&format!("BPM {:03}.{:03}",
|
||||
state.timebase.bpm() / 1000.0,
|
||||
state.timebase.bpm() % 1000.0,
|
||||
),
|
||||
"0.0+00",
|
||||
"0:00.000",
|
||||
].iter() {
|
||||
buf.set_string(area.x + x, area.y + 1, button, label);
|
||||
x = x + button.len() as u16 + 1;
|
||||
buf.set_string(area.x + x, area.y + 1, "│", border);
|
||||
x = x + 2;
|
||||
}
|
||||
Ok(area)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue