Delay regression tests
examples/tutorials/tests/delay.rs · 207 source lines
Read the chapters in source order. Select a numbered source line to expand its explanation; the line numbers and code match this snapshot exactly.
cargo test -p ravet-examples --test delay --no-default-features --lockedChapters
Create deterministic delay fixtures
Import the portable delay, timing contracts and event types. The parameter/prepare/process/render helpers construct known physical patches and in-place mono/stereo blocks. Rendering repartitions absolute event offsets, allowing the same clip to be compared across block boundaries.
1use ravet_examples::delay::DelayProcessor;
Bring these module/type names into scope for “Create deterministic delay fixtures”; the surrounding chapter explains their responsibilities.
Link to line 12use ravet_foundation::{
Bring these module/type names into scope for “Create deterministic delay fixtures”; the surrounding chapter explains their responsibilities.
Link to line 23 AudioBuffer, AudioLayout, Event, EventData, ParameterId, PrepareError, ProcessBlock,
Supply these names as the remaining imports, arguments or fields of the surrounding declaration.
Link to line 34 ProcessConfig, ProcessStatus, Processor, Transport,
Supply these names as the remaining imports, arguments or fields of the surrounding declaration.
Link to line 45};
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 56
Blank line separating the surrounding statements.
Link to line 67fn parameter(frame_offset: usize, id: u32, value: f32) -> Event {
Define parameter. Import the portable delay, timing contracts and event types. The parameter/prepare/process/render helpers construct known physical patches and in-place mono/stereo blocks. Rendering repartitions absolute event offsets, allowing the same clip to be compared across block boundaries.
Link to line 78 Event {
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Create deterministic delay fixtures” explanation above.
Link to line 89 frame_offset,
Supply these names as the remaining imports, arguments or fields of the surrounding declaration.
Link to line 910 data: EventData::ParameterValue {
Typed event payload; timing is kept separately in frame_offset.
Link to line 1011 id: ParameterId(id),
Define or initialize id with the displayed type/value. Its ownership and use are described in “Create deterministic delay fixtures”.
Link to line 1112 value,
Supply these names as the remaining imports, arguments or fields of the surrounding declaration.
Link to line 1213 },
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 1314 }
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 1415}
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 1516fn prepare(values: [f32; 5]) -> DelayProcessor {
Define prepare. Import the portable delay, timing contracts and event types. The parameter/prepare/process/render helpers construct known physical patches and in-place mono/stereo blocks. Rendering repartitions absolute event offsets, allowing the same clip to be compared across block boundaries.
Link to line 1617 let mut processor = DelayProcessor::default();
Bind mutable processor to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 1718 processor.set_controls(values).unwrap();
Call the displayed operation with these arguments as the next step in “Create deterministic delay fixtures”. The chapter describes its role and validation.
Link to line 1819 processor
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Create deterministic delay fixtures” explanation above.
Link to line 1920 .prepare(ProcessConfig::new(8000., 128, 16, AudioLayout::STEREO).unwrap())
Call the displayed operation with these arguments as the next step in “Create deterministic delay fixtures”. The chapter describes its role and validation.
Link to line 2021 .unwrap();
Call the displayed operation with these arguments as the next step in “Create deterministic delay fixtures”. The chapter describes its role and validation.
Link to line 2122 processor
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Create deterministic delay fixtures” explanation above.
Link to line 2223}
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 2324fn process(
Define process. Import the portable delay, timing contracts and event types. The parameter/prepare/process/render helpers construct known physical patches and in-place mono/stereo blocks. Rendering repartitions absolute event offsets, allowing the same clip to be compared across block boundaries.
Link to line 2425 processor: &mut DelayProcessor,
Define or initialize processor with the displayed type/value. Its ownership and use are described in “Create deterministic delay fixtures”.
Link to line 2526 input: &[Vec<f32>; 2],
Define or initialize input with the displayed type/value. Its ownership and use are described in “Create deterministic delay fixtures”.
Link to line 2627 events: &[Event],
Define or initialize events with the displayed type/value. Its ownership and use are described in “Create deterministic delay fixtures”.
Link to line 2728) -> ([Vec<f32>; 2], ProcessStatus) {
Complete the function’s parameter list and specify the return type. A Result preserves the explicit success/error distinction.
Link to line 2829 let frames = input[0].len();
Bind frames to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 2930 let mut output = [vec![99.; frames], vec![99.; frames]];
Bind mutable output to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 3031 let inputs = input.each_ref().map(|c| &c[..]);
Bind inputs to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 3132 let mut outputs = output.each_mut().map(|c| &mut c[..]);
Bind mutable outputs to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 3233 let buffer = AudioBuffer::separate(&inputs, &mut outputs, frames).unwrap();
Borrow distinct input/output slices. An instrument supplies an empty input slice; output storage already belongs to the caller.
Link to line 3334 let status = processor.process(&mut ProcessBlock::new(buffer, events, Transport::default()));
Combine borrowed audio, the active input-event slice and explicit transport into one processing view.
Link to line 3435 (output, status)
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Create deterministic delay fixtures” explanation above.
Link to line 3536}
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 3637fn render(
Define render. Import the portable delay, timing contracts and event types. The parameter/prepare/process/render helpers construct known physical patches and in-place mono/stereo blocks. Rendering repartitions absolute event offsets, allowing the same clip to be compared across block boundaries.
Link to line 3738 values: [f32; 5],
Requested physical controls in the order documented for this processor.
Link to line 3839 input: &[Vec<f32>; 2],
Define or initialize input with the displayed type/value. Its ownership and use are described in “Create deterministic delay fixtures”.
Link to line 3940 events: &[Event],
Define or initialize events with the displayed type/value. Its ownership and use are described in “Create deterministic delay fixtures”.
Link to line 4041 block: usize,
Define or initialize block with the displayed type/value. Its ownership and use are described in “Create deterministic delay fixtures”.
Link to line 4142) -> [Vec<f32>; 2] {
Complete the function’s parameter list and specify the return type. A Result preserves the explicit success/error distinction.
Link to line 4243 let mut processor = prepare(values);
Bind mutable processor to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 4344 let frames = input[0].len();
Bind frames to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 4445 let mut result = [Vec::new(), Vec::new()];
Bind mutable result to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 4546 for start in (0..frames).step_by(block) {
Evaluate this condition or visit this range in source order. The statements in the following scope implement “Create deterministic delay fixtures”.
Link to line 4647 let end = (start + block).min(frames);
Bind end to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 4748 let clip = input.each_ref().map(|c| c[start..end].to_vec());
Bind clip to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 4849 let local: Vec<_> = events
Bind local to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 4950 .iter()
Borrow collection entries for iteration without moving or copying the whole collection.
Link to line 5051 .filter(|e| (start..end).contains(&e.frame_offset))
Keep only entries for which this predicate returns true.
Link to line 5152 .map(|e| Event {
Transform each iterator entry, or the successful value of an Option/Result, using the supplied closure.
Link to line 5253 frame_offset: e.frame_offset - start,
The event’s timing coordinate, interpreted relative to its current clip/block context.
Link to line 5354 ..*e
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Create deterministic delay fixtures” explanation above.
Link to line 5455 })
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 5556 .collect();
Call the displayed operation with these arguments as the next step in “Create deterministic delay fixtures”. The chapter describes its role and validation.
Link to line 5657 let (output, status) = process(&mut processor, &clip, &local);
Call the displayed operation with these arguments as the next step in “Create deterministic delay fixtures”. The chapter describes its role and validation.
Link to line 5758 assert_eq!(status, ProcessStatus::Continue);
Represent a successfully processed block. The offline renderer treats any different status as a failed rendering session.
Link to line 5859 for c in 0..2 {
Visit the two internal delay channels, even when the external layout is mono.
Link to line 5960 result[c].extend_from_slice(&output[c]);
Call the displayed operation with these arguments as the next step in “Create deterministic delay fixtures”. The chapter describes its role and validation.
Link to line 6061 }
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 6162 }
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 6263 result
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Create deterministic delay fixtures” explanation above.
Link to line 6364}
Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.
Link to line 6465
Blank line separating the surrounding statements.
Link to line 6566#[test]
Apply this Rust attribute to the following item. cfg selects which target/feature/test build contains it; derive generates the named trait implementations.
Link to line 66Check exact repeat and cross-feedback timing
Render impulses through stereo and ping-pong patches and compare specific sample positions/channels. These assertions test ring delay and feedback routing numerically, not subjective audibility.
67fn stereo_repeats_and_ping_pong_cross_feedback_have_exact_timing() {
Define stereo_repeats_and_ping_pong_cross_feedback_have_exact_timing. Render impulses through stereo and ping-pong patches and compare specific sample positions/channels. These assertions test ring delay and feedback routing numerically, not subjective audibility.
Link to line 6768 let mut input = [vec![0.; 321], vec![0.; 321]];
Bind mutable input to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 6869 input[0][0] = 1.;
Assign the computed value to input[0][0]. The right-hand expression supplies the new value for this step.
Link to line 6970 input[1][7] = 0.25;
Assign the computed value to input[1][7]. The right-hand expression supplies the new value for this step.
Link to line 7071 for cross in [0., 1.] {
Evaluate this condition or visit this range in source order. The statements in the following scope implement “Check exact repeat and cross-feedback timing”.
Link to line 7172 let output = render([10., 0.5, 1., 0., cross], &input, &[], 37);
Bind output to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 7273 assert_eq!(output[0][80], 1.);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 7374 assert_eq!(output[1][87], 0.25);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 7475 assert_eq!(output[if cross == 0. { 0 } else { 1 }][160], 0.5);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 7576 assert_eq!(output[if cross == 0. { 1 } else { 0 }][167], 0.125);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 7677 assert_eq!(output[0][240], 0.25);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 7778 assert_eq!(output[1][247], 0.0625);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 7879 assert_eq!(output.iter().flatten().filter(|s| **s != 0.).count(), 7);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 7980 }
Close the surrounding scope, value or argument list in “Check exact repeat and cross-feedback timing”.
Link to line 8081}
Close the surrounding scope, value or argument list in “Check exact repeat and cross-feedback timing”.
Link to line 8182
Blank line separating the surrounding statements.
Link to line 8283#[test]
Apply this Rust attribute to the following item. cfg selects which target/feature/test build contains it; derive generates the named trait implementations.
Link to line 83Verify automation and bypass-tail retention
Render the same scheduled changes using different block sizes and compare output samples. Switch bypass on and off while echoes exist to verify that dry bypass does not stop internal history.
84fn automation_is_partition_independent_and_bypass_keeps_the_tail() {
Define automation_is_partition_independent_and_bypass_keeps_the_tail. Render the same scheduled changes using different block sizes and compare output samples. Switch bypass on and off while echoes exist to verify that dry bypass does not stop internal history.
Link to line 8485 let input = [vec![0.25; 1200], vec![-0.125; 1200]];
Bind input to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 8586 let events = [
Bind events to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 8687 parameter(113, 1, 17.),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 8788 parameter(117, 2, 0.8),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 8889 parameter(129, 3, 0.9),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 8990 parameter(203, 5, 1.),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 9091 parameter(319, 4, 1.),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 9192 parameter(557, 4, 0.),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 9293 ];
Close the surrounding scope, value or argument list in “Verify automation and bypass-tail retention”.
Link to line 9394 let values = [10., 0.5, 0.3, 0., 0.];
Bind values to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 9495 let first = render(values, &input, &events, 128);
Bind first to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 9596 assert_eq!(first, render(values, &input, &events, 19));
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 9697 for c in 0..2 {
Visit the two internal delay channels, even when the external layout is mono.
Link to line 9798 assert_eq!(first[c][319..557], input[c][319..557]);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 9899 }
Close the surrounding scope, value or argument list in “Verify automation and bypass-tail retention”.
Link to line 99100
Blank line separating the surrounding statements.
Link to line 100101 let mut impulse = [vec![0.; 241], vec![0.; 241]];
Bind mutable impulse to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 101102 impulse[0][0] = 1.;
Assign the computed value to impulse[0][0]. The right-hand expression supplies the new value for this step.
Link to line 102103 let output = render(
Bind output to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 103104 [10., 0.5, 1., 0., 0.],
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 104105 &impulse,
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 105106 &[parameter(79, 4, 1.), parameter(81, 4, 0.)],
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Verify automation and bypass-tail retention” explanation above.
Link to line 106107 31,
Supply these names as the remaining imports, arguments or fields of the surrounding declaration.
Link to line 107108 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 108109 assert_eq!(output[0][80], 0.);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 109110 assert_eq!(output[0][160], 0.5);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 110111 assert_eq!(output[0][240], 0.25);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 111112}
Close the surrounding scope, value or argument list in “Verify automation and bypass-tail retention”.
Link to line 112113
Blank line separating the surrounding statements.
Link to line 113114#[test]
Apply this Rust attribute to the following item. cfg selects which target/feature/test build contains it; derive generates the named trait implementations.
Link to line 114Reject the entire faulty block transactionally
Place a valid early edit before a later invalid event, then check the returned fault, silenced output and unchanged requested/history behavior. A control patch error must also leave previous controls intact.
115fn invalid_late_event_rejects_whole_block_and_preserves_history() {
Define invalid_late_event_rejects_whole_block_and_preserves_history. Place a valid early edit before a later invalid event, then check the returned fault, silenced output and unchanged requested/history behavior. A control patch error must also leave previous controls intact.
Link to line 115116 let mut processor = prepare([10., 0.5, 1., 0., 0.]);
Bind mutable processor to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 116117 let mut reference = prepare([10., 0.5, 1., 0., 0.]);
Bind mutable reference to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 117118 let mut input = [vec![0.; 64], vec![0.; 64]];
Bind mutable input to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 118119 input[0][0] = 1.;
Assign the computed value to input[0][0]. The right-hand expression supplies the new value for this step.
Link to line 119120 assert_eq!(
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 120121 process(&mut processor, &input, &[]),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 121122 process(&mut reference, &input, &[])
Call the displayed operation with these arguments as the next step in “Reject the entire faulty block transactionally”. The chapter describes its role and validation.
Link to line 122123 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 123124 let zero = [vec![0.; 64], vec![0.; 64]];
Bind zero to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 124125 let values = processor.controls();
Bind values to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 125126 let (output, status) = process(
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 126127 &mut processor,
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 127128 &zero,
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 128129 &[parameter(0, 3, 0.2), parameter(63, 2, 1.)],
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 129130 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 130131 assert!(matches!(status, ProcessStatus::Fault(_)));
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 131132 assert!(output.iter().flatten().all(|s| *s == 0.));
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 132133 assert_eq!(processor.controls(), values);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 133134 assert_eq!(
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 134135 process(&mut processor, &zero, &[]),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 135136 process(&mut reference, &zero, &[])
Call the displayed operation with these arguments as the next step in “Reject the entire faulty block transactionally”. The chapter describes its role and validation.
Link to line 136137 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 137138 for invalid in [
Evaluate this condition or visit this range in source order. The statements in the following scope implement “Reject the entire faulty block transactionally”.
Link to line 138139 [0., 0.5, 1., 0., 0.],
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 139140 [2001., 0.5, 1., 0., 0.],
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 140141 [10., f32::NAN, 1., 0., 0.],
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 141142 [10., 0.5, 1., 0.5, 0.],
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 142143 ] {
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 143144 assert!(processor.set_controls(invalid).is_err());
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 144145 assert_eq!(processor.controls(), values);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 145146 }
Close the surrounding scope, value or argument list in “Reject the entire faulty block transactionally”.
Link to line 146147 processor.reset();
Call the displayed operation with these arguments as the next step in “Reject the entire faulty block transactionally”. The chapter describes its role and validation.
Link to line 147148 assert!(
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 148149 process(&mut processor, &zero, &[])
Call the displayed operation with these arguments as the next step in “Reject the entire faulty block transactionally”. The chapter describes its role and validation.
Link to line 149150 .0
Supply this literal numeric entry to the array or argument list being constructed. Its units/addressing follow the containing fixture or configuration.
Link to line 150151 .iter()
Borrow collection entries for iteration without moving or copying the whole collection.
Link to line 151152 .flatten()
Call the displayed operation with these arguments as the next step in “Reject the entire faulty block transactionally”. The chapter describes its role and validation.
Link to line 152153 .all(|s| *s == 0.)
Call the displayed operation with these arguments as the next step in “Reject the entire faulty block transactionally”. The chapter describes its role and validation.
Link to line 153154 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 154155 assert_eq!(
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 155156 processor.prepare(ProcessConfig::new(384000., 128, 16, AudioLayout::STEREO).unwrap()),
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 156157 Err(PrepareError::InvalidSampleRate)
Construct the success/error variant selected by the surrounding match or function return. The enclosed value becomes its payload.
Link to line 157158 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 158159 assert!(matches!(
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 159160 process(&mut processor, &zero, &[]).1,
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Reject the entire faulty block transactionally” explanation above.
Link to line 160161 ProcessStatus::Fault(_)
Define or initialize ProcessStatus with the displayed type/value. Its ownership and use are described in “Reject the entire faulty block transactionally”.
Link to line 161162 ));
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 162163}
Close the surrounding scope, value or argument list in “Reject the entire faulty block transactionally”.
Link to line 163164
Blank line separating the surrounding statements.
Link to line 164165#[test]
Apply this Rust attribute to the following item. cfg selects which target/feature/test build contains it; derive generates the named trait implementations.
Link to line 165Measure processing, prepared edits and reset
Prepare all storage outside the measured region, then repeatedly process and edit controls/reset inside allocation_counter::measure. Assert no allocation/deallocation and cover maximum delay and nonfinite input handling. This is a heap-behavior check, not a real-time deadline measurement.
166fn prepared_processing_control_changes_and_reset_have_no_heap_actions() {
Define prepared_processing_control_changes_and_reset_have_no_heap_actions. Prepare all storage outside the measured region, then repeatedly process and edit controls/reset inside allocation_counter::measure. Assert no allocation/deallocation and cover maximum delay and nonfinite input handling. This is a heap-behavior check, not a real-time deadline measurement.
Link to line 166167 let mut processor = prepare([10., 0.5, 0.5, 0., 0.]);
Bind mutable processor to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 167168 let input = [[0.1f32; 128], [-0.1; 128]];
Bind input to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 168169 let inputs = input.each_ref().map(|c| &c[..]);
Bind inputs to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 169170 let mut output = [[0.; 128]; 2];
Bind mutable output to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 170171 let measured = allocation_counter::measure(|| {
Measure heap activity only in the enclosed processing/changes/reset region; preparation and assertions are outside it.
Link to line 171172 for i in 0..1000 {
Evaluate this condition or visit this range in source order. The statements in the following scope implement “Measure processing, prepared edits and reset”.
Link to line 172173 processor
Continue the surrounding value or expression with this exact operand. Read it together with the preceding statement and the “Measure processing, prepared edits and reset” explanation above.
Link to line 173174 .set_controls([1. + (i % 2000) as f32, 0.95, 0.75, 0., (i % 2) as f32])
Call the displayed operation with these arguments as the next step in “Measure processing, prepared edits and reset”. The chapter describes its role and validation.
Link to line 174175 .unwrap();
Call the displayed operation with these arguments as the next step in “Measure processing, prepared edits and reset”. The chapter describes its role and validation.
Link to line 175176 let mut outputs = output.each_mut().map(|c| &mut c[..]);
Bind mutable outputs to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 176177 let buffer = AudioBuffer::separate(&inputs, &mut outputs, 128).unwrap();
Borrow distinct input/output slices. An instrument supplies an empty input slice; output storage already belongs to the caller.
Link to line 177178 assert_eq!(
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 178179 processor.process(&mut ProcessBlock::new(buffer, &[], Transport::default())),
Combine borrowed audio, the active input-event slice and explicit transport into one processing view.
Link to line 179180 ProcessStatus::Continue
Represent a successfully processed block. The offline renderer treats any different status as a failed rendering session.
Link to line 180181 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 181182 }
Close the surrounding scope, value or argument list in “Measure processing, prepared edits and reset”.
Link to line 182183 processor.reset();
Call the displayed operation with these arguments as the next step in “Measure processing, prepared edits and reset”. The chapter describes its role and validation.
Link to line 183184 });
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 184185 assert_eq!(measured.count_total, 0);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 185186 assert_eq!(measured.count_current, 0);
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 186187 assert!(output.iter().flatten().all(|s| s.is_finite()));
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 187188
Blank line separating the surrounding statements.
Link to line 188189 // Maximum two-second delay and the mono layout use the same prepared path.
Source note: Maximum two-second delay and the mono layout use the same prepared path.
Link to line 189190 let mut mono = DelayProcessor::default();
Bind mutable mono to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 190191 mono.set_controls([2000., 0., 1., 0., 1.]).unwrap();
Call the displayed operation with these arguments as the next step in “Measure processing, prepared edits and reset”. The chapter describes its role and validation.
Link to line 191192 mono.prepare(ProcessConfig::new(8000., 128, 0, AudioLayout::MONO).unwrap())
Call the displayed operation with these arguments as the next step in “Measure processing, prepared edits and reset”. The chapter describes its role and validation.
Link to line 192193 .unwrap();
Call the displayed operation with these arguments as the next step in “Measure processing, prepared edits and reset”. The chapter describes its role and validation.
Link to line 193194 let mut samples = [0.; 128];
Bind mutable samples to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 194195 samples[0] = 1.;
Assign the computed value to samples[0]. The right-hand expression supplies the new value for this step.
Link to line 195196 for block in 0..126 {
Evaluate this condition or visit this range in source order. The statements in the following scope implement “Measure processing, prepared edits and reset”.
Link to line 196197 let mut channels = [&mut samples[..]];
Bind mutable channels to the expression on this and any following continuation lines. The chapter above explains how this intermediate value is used.
Link to line 197198 let buffer = AudioBuffer::in_place(&mut channels, 128).unwrap();
Borrow the active mutable channel slices as both effect input and output. Constructing the view does not allocate audio storage.
Link to line 198199 assert_eq!(
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 199200 mono.process(&mut ProcessBlock::new(buffer, &[], Transport::default())),
Combine borrowed audio, the active input-event slice and explicit transport into one processing view.
Link to line 200201 ProcessStatus::Continue
Represent a successfully processed block. The offline renderer treats any different status as a failed rendering session.
Link to line 201202 );
Close the current expression or scope; no additional processing operation occurs on this line.
Link to line 202203 assert_eq!(samples[0], if block == 125 { 1. } else { 0. });
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 203204 assert!(samples[1..].iter().all(|s| *s == 0.));
Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.
Link to line 204205 samples.fill(0.);
Call the displayed operation with these arguments as the next step in “Measure processing, prepared edits and reset”. The chapter describes its role and validation.
Link to line 205206 }
Close the surrounding scope, value or argument list in “Measure processing, prepared edits and reset”.
Link to line 206207}
Close the surrounding scope, value or argument list in “Measure processing, prepared edits and reset”.
Link to line 207