git ssb

0+

dinoworm ๐Ÿ› / metronome



Tree: 9cf1052d129942a85af116c81a7f960330143ad6

Files: 9cf1052d129942a85af116c81a7f960330143ad6 / src / control.rs

892 bytesRaw
1use std::thread;
2use std::sync::mpsc::{channel, Sender, Receiver};
3
4pub type Time = f32;
5
6pub enum ChangeMode {
7 Start,
8 Continue,
9 Stop
10}
11
12pub
13
14
15pub enum Control {
16 Time(Time),
17 ChangeMode(ChangeMode),
18 TapTempo,
19 SetTempo(),
20 Nudge(
21 Configure(ChangeMode)
22}
23
24pub fn create_control_channel() -> (Sender<Control>, Receiver<Control>) {
25 return channel();
26}
27
28pub fn connect_clock(fps: u32, control_tx: Sender<Control>) {
29 thread::spawn(move|| {
30 let mut fps_clock = fps_clock::FpsClock::new(fps);
31 let mut nanosecs_since_start = 0.0;
32 let mut nanosecs_since_last_tick;
33 loop {
34 nanosecs_since_last_tick = fps_clock.tick();
35 nanosecs_since_start += nanosecs_since_last_tick;
36 let clock_time = Control::Time(nanosecs_since_start);
37 control_tx.send(clock_time).unwrap();
38 }
39 });
40}
41

Built with git-ssb-web