panic if shell desired as not impl
This commit is contained in:
32
src/main.rs
32
src/main.rs
@@ -1,3 +1,4 @@
|
||||
use io_prompt_prototype::prompt;
|
||||
use itertools::Itertools;
|
||||
|
||||
mod flags;
|
||||
@@ -12,11 +13,22 @@ fn main() {
|
||||
eprintln!("{:?}", flags);
|
||||
}
|
||||
|
||||
let once = flags.play.iter().filter(|x| x.len() > 0).count() > 0;
|
||||
loop {
|
||||
play_with_flags(&flags);
|
||||
if once {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn play_with_flags(flags: &flags::Flags) {
|
||||
let mut syn_seq = seq::new_syn(syn::Syn::new(
|
||||
flags.debug,
|
||||
flags.sound_font,
|
||||
flags.sample_rate,
|
||||
flags.debug.clone(),
|
||||
flags.sound_font.clone(),
|
||||
flags.sample_rate.clone(),
|
||||
));
|
||||
|
||||
let mut i = 0;
|
||||
for p in flags.play.iter() {
|
||||
for p in play::new(p.clone()) {
|
||||
@@ -24,11 +36,15 @@ fn main() {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
if i == 0 {
|
||||
let s: String = prompt!("> ").parse().expect("failed to readline");
|
||||
panic!("not impl");
|
||||
}
|
||||
|
||||
play(syn_seq, flags.sample_rate, flags.bpm);
|
||||
play(syn_seq, flags.sample_rate, flags.bpm, true);
|
||||
}
|
||||
|
||||
fn play(mut s: seq::SynSeq, sample_rate: usize, bpm: usize) {
|
||||
fn play(mut s: seq::SynSeq, sample_rate: usize, bpm: usize, sync: bool) {
|
||||
let samples_per_beat = sample_rate / bpm * 60;
|
||||
let params = tinyaudio::prelude::OutputDeviceParameters {
|
||||
channels_count: 2,
|
||||
@@ -52,6 +68,8 @@ fn play(mut s: seq::SynSeq, sample_rate: usize, bpm: usize) {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// Wait it out
|
||||
std::thread::sleep(std::time::Duration::from_secs(duration as u64));
|
||||
if sync {
|
||||
// Wait it out
|
||||
std::thread::sleep(std::time::Duration::from_secs(duration as u64));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user