failing multi chord test from file
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
mod flags;
|
mod flags;
|
||||||
|
mod play;
|
||||||
mod seq;
|
mod seq;
|
||||||
mod syn;
|
mod syn;
|
||||||
mod tone;
|
mod tone;
|
||||||
@@ -16,8 +17,12 @@ fn main() {
|
|||||||
flags.sound_font,
|
flags.sound_font,
|
||||||
flags.sample_rate,
|
flags.sample_rate,
|
||||||
));
|
));
|
||||||
for i in 0..flags.play.len() {
|
let mut i = 0;
|
||||||
syn_seq.append(i as i32, flags.play[i].clone());
|
for p in flags.play.iter() {
|
||||||
|
for p in play::new(p.clone()) {
|
||||||
|
syn_seq.append(i as i32, p);
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
play(syn_seq, flags.sample_rate, flags.bpm);
|
play(syn_seq, flags.sample_rate, flags.bpm);
|
||||||
|
|||||||
47
src/play.rs
Normal file
47
src/play.rs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
pub fn new<S: ToString>(s: S) -> Vec<String> {
|
||||||
|
parse(from_string(s.to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_string(s: String) -> String {
|
||||||
|
match std::fs::File::open(s.clone()) {
|
||||||
|
Ok(mut reader) => {
|
||||||
|
let mut content = String::new();
|
||||||
|
reader
|
||||||
|
.read_to_string(&mut content)
|
||||||
|
.expect(format!("failed to read {}", s).as_ref());
|
||||||
|
content.split_whitespace().collect::<Vec<_>>().join(" ")
|
||||||
|
}
|
||||||
|
Err(_) => s,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse(s: String) -> Vec<String> {
|
||||||
|
vec![s]
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
#[test]
|
||||||
|
fn test_string() {
|
||||||
|
assert_eq!(super::new("a b c")[0], "a b c".to_string());
|
||||||
|
assert_eq!(super::new("a b c".to_string())[0], "a b c".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_single_line_file() {
|
||||||
|
assert_eq!(
|
||||||
|
super::new("src/testdata/single_line_file.txt")[0],
|
||||||
|
"a b c".to_string()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_two_channels_one_bar() {
|
||||||
|
assert_eq!(
|
||||||
|
super::new("src/testdata/two_channels_one_bar.txt")[0],
|
||||||
|
"a b c".to_string()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/testdata/single_line_file.txt
vendored
Normal file
1
src/testdata/single_line_file.txt
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
a b c
|
||||||
2
src/testdata/two_channels_one_bar.txt
vendored
Normal file
2
src/testdata/two_channels_one_bar.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
a b c
|
||||||
|
a5 b5 c5
|
||||||
Reference in New Issue
Block a user