AUDIO
Source snapshot · 12 October 2026

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 --locked
Chapters
  1. Create deterministic delay fixtures lines 1–66
  2. Check exact repeat and cross-feedback timing lines 67–83
  3. Verify automation and bypass-tail retention lines 84–114
  4. Reject the entire faulty block transactionally lines 115–165
  5. Measure processing, prepared edits and reset lines 166–207

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 1
2use ravet_foundation::{

Bring these module/type names into scope for “Create deterministic delay fixtures”; the surrounding chapter explains their responsibilities.

Link to line 2
3 AudioBuffer, AudioLayout, Event, EventData, ParameterId, PrepareError, ProcessBlock,

Supply these names as the remaining imports, arguments or fields of the surrounding declaration.

Link to line 3
4 ProcessConfig, ProcessStatus, Processor, Transport,

Supply these names as the remaining imports, arguments or fields of the surrounding declaration.

Link to line 4
5};

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 5
6

Blank line separating the surrounding statements.

Link to line 6
7fn 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 7
8 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 8
9 frame_offset,

Supply these names as the remaining imports, arguments or fields of the surrounding declaration.

Link to line 9
10 data: EventData::ParameterValue {

Typed event payload; timing is kept separately in frame_offset.

Link to line 10
11 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 11
12 value,

Supply these names as the remaining imports, arguments or fields of the surrounding declaration.

Link to line 12
13 },

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 13
14 }

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 14
15}

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 15
16fn 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 16
17 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 17
18 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 18
19 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 19
20 .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 20
21 .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 21
22 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 22
23}

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 23
24fn 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 24
25 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 25
26 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 26
27 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 27
28) -> ([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 28
29 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 29
30 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 30
31 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 31
32 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 32
33 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 33
34 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 34
35 (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 35
36}

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 36
37fn 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 37
38 values: [f32; 5],

Requested physical controls in the order documented for this processor.

Link to line 38
39 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 39
40 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 40
41 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 41
42) -> [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 42
43 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 43
44 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 44
45 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 45
46 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 46
47 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 47
48 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 48
49 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 49
50 .iter()

Borrow collection entries for iteration without moving or copying the whole collection.

Link to line 50
51 .filter(|e| (start..end).contains(&e.frame_offset))

Keep only entries for which this predicate returns true.

Link to line 51
52 .map(|e| Event {

Transform each iterator entry, or the successful value of an Option/Result, using the supplied closure.

Link to line 52
53 frame_offset: e.frame_offset - start,

The event’s timing coordinate, interpreted relative to its current clip/block context.

Link to line 53
54 ..*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 54
55 })

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 55
56 .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 56
57 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 57
58 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 58
59 for c in 0..2 {

Visit the two internal delay channels, even when the external layout is mono.

Link to line 59
60 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 60
61 }

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 61
62 }

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 62
63 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 63
64}

Close the surrounding scope, value or argument list in “Create deterministic delay fixtures”.

Link to line 64
65

Blank line separating the surrounding statements.

Link to line 65
66#[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 66

Check 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 67
68 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 68
69 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 69
70 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 70
71 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 71
72 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 72
73 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 73
74 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 74
75 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 75
76 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 76
77 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 77
78 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 78
79 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 79
80 }

Close the surrounding scope, value or argument list in “Check exact repeat and cross-feedback timing”.

Link to line 80
81}

Close the surrounding scope, value or argument list in “Check exact repeat and cross-feedback timing”.

Link to line 81
82

Blank line separating the surrounding statements.

Link to line 82
83#[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 83

Verify 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 84
85 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 85
86 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 86
87 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 87
88 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 88
89 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 89
90 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 90
91 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 91
92 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 92
93 ];

Close the surrounding scope, value or argument list in “Verify automation and bypass-tail retention”.

Link to line 93
94 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 94
95 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 95
96 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 96
97 for c in 0..2 {

Visit the two internal delay channels, even when the external layout is mono.

Link to line 97
98 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 98
99 }

Close the surrounding scope, value or argument list in “Verify automation and bypass-tail retention”.

Link to line 99
100

Blank line separating the surrounding statements.

Link to line 100
101 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 101
102 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 102
103 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 103
104 [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 104
105 &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 105
106 &[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 106
107 31,

Supply these names as the remaining imports, arguments or fields of the surrounding declaration.

Link to line 107
108 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 108
109 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 109
110 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 110
111 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 111
112}

Close the surrounding scope, value or argument list in “Verify automation and bypass-tail retention”.

Link to line 112
113

Blank line separating the surrounding statements.

Link to line 113
114#[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 114

Reject 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 115
116 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 116
117 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 117
118 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 118
119 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 119
120 assert_eq!(

Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.

Link to line 120
121 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 121
122 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 122
123 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 123
124 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 124
125 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 125
126 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 126
127 &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 127
128 &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 128
129 &[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 129
130 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 130
131 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 131
132 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 132
133 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 133
134 assert_eq!(

Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.

Link to line 134
135 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 135
136 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 136
137 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 137
138 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 138
139 [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 139
140 [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 140
141 [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 141
142 [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 142
143 ] {

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 143
144 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 144
145 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 145
146 }

Close the surrounding scope, value or argument list in “Reject the entire faulty block transactionally”.

Link to line 146
147 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 147
148 assert!(

Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.

Link to line 148
149 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 149
150 .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 150
151 .iter()

Borrow collection entries for iteration without moving or copying the whole collection.

Link to line 151
152 .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 152
153 .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 153
154 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 154
155 assert_eq!(

Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.

Link to line 155
156 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 156
157 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 157
158 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 158
159 assert!(matches!(

Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.

Link to line 159
160 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 160
161 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 161
162 ));

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 162
163}

Close the surrounding scope, value or argument list in “Reject the entire faulty block transactionally”.

Link to line 163
164

Blank line separating the surrounding statements.

Link to line 164
165#[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 165

Measure 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 166
167 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 167
168 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 168
169 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 169
170 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 170
171 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 171
172 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 172
173 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 173
174 .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 174
175 .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 175
176 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 176
177 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 177
178 assert_eq!(

Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.

Link to line 178
179 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 179
180 ProcessStatus::Continue

Represent a successfully processed block. The offline renderer treats any different status as a failed rendering session.

Link to line 180
181 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 181
182 }

Close the surrounding scope, value or argument list in “Measure processing, prepared edits and reset”.

Link to line 182
183 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 183
184 });

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 184
185 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 185
186 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 186
187 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 187
188

Blank line separating the surrounding statements.

Link to line 188
189 // 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 189
190 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 190
191 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 191
192 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 192
193 .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 193
194 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 194
195 samples[0] = 1.;

Assign the computed value to samples[0]. The right-hand expression supplies the new value for this step.

Link to line 195
196 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 196
197 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 197
198 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 198
199 assert_eq!(

Verify the fixture’s expected result. A mismatch fails the test rather than becoming a successful support claim.

Link to line 199
200 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 200
201 ProcessStatus::Continue

Represent a successfully processed block. The offline renderer treats any different status as a failed rendering session.

Link to line 201
202 );

Close the current expression or scope; no additional processing operation occurs on this line.

Link to line 202
203 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 203
204 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 204
205 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 205
206 }

Close the surrounding scope, value or argument list in “Measure processing, prepared edits and reset”.

Link to line 206
207}

Close the surrounding scope, value or argument list in “Measure processing, prepared edits and reset”.

Link to line 207

Source SHA-256: cf9c8096384cd763507c9e1fe4fa40e7a075c1a37f7e9fe2ba7e297647f25466

API: ravet_examples · ravet_foundation

All tutorial walkthroughs