Files: de37e989827890621e4dbd2d5a5493b416130606 / src / main.rs
1016 bytesRaw
1 | extern crate ncurses; |
2 | |
3 | mod clock; |
4 | mod control; |
5 | mod interface; |
6 | |
7 | fn main () { |
8 | Metronome::run(60_f64); |
9 | } |
10 | |
11 | |
12 | pub type Bpm = f64; |
13 | |
14 | struct Metronome { |
15 | pub bpm: Bpm |
16 | } |
17 | |
18 | impl Metronome { |
19 | pub fn run (bpm: Bpm) { |
20 | let control = control::Control::new(); |
21 | |
22 | let clock_signature = clock::ClockSignature::new(bpm); |
23 | |
24 | let clock = clock::Clock::start(clock_signature, control.tx.clone()); |
25 | let terminal_interface = interface::TerminalInterface::start(clock_signature, control.tx.clone()); |
26 | |
27 | for control_message in control.rx { |
28 | match control_message { |
29 | control::ControlMessage::Signature(signature) => { |
30 | terminal_interface.tx.send(interface::InterfaceMessage::Signature(signature)).unwrap(); |
31 | }, |
32 | control::ControlMessage::Time(time) => { |
33 | terminal_interface.tx.send(interface::InterfaceMessage::Time(time)).unwrap(); |
34 | }, |
35 | _ => {} |
36 | } |
37 | } |
38 | } |
39 | } |
40 | |
41 |
Built with git-ssb-web