All about temporal semantics
This commit is contained in:
@@ -47,8 +47,8 @@ fn emit_no_delta() {
|
||||
|
||||
#[test]
|
||||
fn at_half() {
|
||||
// at 0.5 in root window (0..0.125) => delta = 0.5 * 0.125 = 0.0625
|
||||
let outputs = expect_outputs(r#""kick" s 0.5 at"#, 1);
|
||||
// at 0.5 in root zoom (0..0.125) => delta = 0.5 * 0.125 = 0.0625
|
||||
let outputs = expect_outputs(r#""kick" s 0.5 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(
|
||||
approx_eq(deltas[0], 0.0625),
|
||||
@@ -59,7 +59,7 @@ fn at_half() {
|
||||
|
||||
#[test]
|
||||
fn at_quarter() {
|
||||
let outputs = expect_outputs(r#""kick" s 0.25 at"#, 1);
|
||||
let outputs = expect_outputs(r#""kick" s 0.25 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(
|
||||
approx_eq(deltas[0], 0.03125),
|
||||
@@ -70,7 +70,7 @@ fn at_quarter() {
|
||||
|
||||
#[test]
|
||||
fn at_zero() {
|
||||
let outputs = expect_outputs(r#""kick" s 0.0 at"#, 1);
|
||||
let outputs = expect_outputs(r#""kick" s 0.0 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(approx_eq(deltas[0], 0.0), "at 0.0 should be delta 0");
|
||||
}
|
||||
@@ -117,83 +117,83 @@ fn div_3_each() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_full() {
|
||||
// window 0.0 1.0 is the full step, same as root
|
||||
let outputs = expect_outputs(r#"0.0 1.0 window "kick" s 0.5 at"#, 1);
|
||||
fn zoom_full() {
|
||||
// zoom 0.0 1.0 is the full step, same as root
|
||||
let outputs = expect_outputs(r#"0.0 1.0 zoom "kick" s 0.5 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(approx_eq(deltas[0], 0.0625), "full window at 0.5 = 0.0625");
|
||||
assert!(approx_eq(deltas[0], 0.0625), "full zoom at 0.5 = 0.0625");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_first_half() {
|
||||
// window 0.0 0.5 restricts to first half (0..0.0625)
|
||||
fn zoom_first_half() {
|
||||
// zoom 0.0 0.5 restricts to first half (0..0.0625)
|
||||
// at 0.5 within that = 0.25 of full step = 0.03125
|
||||
let outputs = expect_outputs(r#"0.0 0.5 window "kick" s 0.5 at"#, 1);
|
||||
let outputs = expect_outputs(r#"0.0 0.5 zoom "kick" s 0.5 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(
|
||||
approx_eq(deltas[0], 0.03125),
|
||||
"first-half window at 0.5 = 0.03125, got {}",
|
||||
"first-half zoom at 0.5 = 0.03125, got {}",
|
||||
deltas[0]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_second_half() {
|
||||
// window 0.5 1.0 restricts to second half (0.0625..0.125)
|
||||
fn zoom_second_half() {
|
||||
// zoom 0.5 1.0 restricts to second half (0.0625..0.125)
|
||||
// at 0.0 within that = start of second half = 0.0625
|
||||
let outputs = expect_outputs(r#"0.5 1.0 window "kick" s 0.0 at"#, 1);
|
||||
let outputs = expect_outputs(r#"0.5 1.0 zoom "kick" s 0.0 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(
|
||||
approx_eq(deltas[0], 0.0625),
|
||||
"second-half window at 0.0 = 0.0625, got {}",
|
||||
"second-half zoom at 0.0 = 0.0625, got {}",
|
||||
deltas[0]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_second_half_middle() {
|
||||
// window 0.5 1.0, at 0.5 within that = 0.75 of full step = 0.09375
|
||||
let outputs = expect_outputs(r#"0.5 1.0 window "kick" s 0.5 at"#, 1);
|
||||
fn zoom_second_half_middle() {
|
||||
// zoom 0.5 1.0, at 0.5 within that = 0.75 of full step = 0.09375
|
||||
let outputs = expect_outputs(r#"0.5 1.0 zoom "kick" s 0.5 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(approx_eq(deltas[0], 0.09375), "got {}", deltas[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_windows() {
|
||||
// window 0.0 0.5, then window 0.5 1.0 within that
|
||||
fn nested_zooms() {
|
||||
// zoom 0.0 0.5, then zoom 0.5 1.0 within that
|
||||
// outer: 0..0.0625, inner: 0.5..1.0 of that = 0.03125..0.0625
|
||||
// at 0.0 in inner = 0.03125
|
||||
let outputs = expect_outputs(r#"0.0 0.5 window 0.5 1.0 window "kick" s 0.0 at"#, 1);
|
||||
let outputs = expect_outputs(r#"0.0 0.5 zoom 0.5 1.0 zoom "kick" s 0.0 at emit pop"#, 1);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(
|
||||
approx_eq(deltas[0], 0.03125),
|
||||
"nested window at 0.0 = 0.03125, got {}",
|
||||
"nested zoom at 0.0 = 0.03125, got {}",
|
||||
deltas[0]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_pop_sequence() {
|
||||
// First in window 0.0 0.5 at 0.0 -> delta 0
|
||||
// Pop, then in window 0.5 1.0 at 0.0 -> delta 0.0625
|
||||
fn zoom_pop_sequence() {
|
||||
// First in zoom 0.0 0.5 at 0.0 -> delta 0
|
||||
// Pop at context and zoom, then in zoom 0.5 1.0 at 0.0 -> delta 0.0625
|
||||
let outputs = expect_outputs(
|
||||
r#"0.0 0.5 window "kick" s 0.0 at pop 0.5 1.0 window "snare" s 0.0 at"#,
|
||||
r#"0.0 0.5 zoom "kick" s 0.0 at emit pop pop 0.5 1.0 zoom "snare" s 0.0 at emit pop"#,
|
||||
2,
|
||||
);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(approx_eq(deltas[0], 0.0), "first window start");
|
||||
assert!(approx_eq(deltas[0], 0.0), "first zoom start");
|
||||
assert!(
|
||||
approx_eq(deltas[1], 0.0625),
|
||||
"second window start, got {}",
|
||||
"second zoom start, got {}",
|
||||
deltas[1]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn div_in_window() {
|
||||
// window 0.0 0.5 (duration 0.0625), then div 2 each
|
||||
fn div_in_zoom() {
|
||||
// zoom 0.0 0.5 (duration 0.0625), then div 2 each
|
||||
// subdivisions at 0 and 0.03125
|
||||
let outputs = expect_outputs(r#"0.0 0.5 window "kick" s 2 div each"#, 2);
|
||||
let outputs = expect_outputs(r#"0.0 0.5 zoom "kick" s 2 div each"#, 2);
|
||||
let deltas = get_deltas(&outputs);
|
||||
assert!(approx_eq(deltas[0], 0.0));
|
||||
assert!(approx_eq(deltas[1], 0.03125), "got {}", deltas[1]);
|
||||
|
||||
Reference in New Issue
Block a user