@@ -201,23 +201,33 @@ impl AudioProcessor for ConstantSourceRenderer {
201201
202202 let offset = params. get ( & self . offset ) ;
203203 let output_channel = output. channel_data_mut ( 0 ) ;
204- let mut current_time = scope. current_time ;
205-
206- output_channel
207- . iter_mut ( )
208- . zip ( offset. iter ( ) . cycle ( ) )
209- . for_each ( |( o, & value) | {
210- if current_time < self . start_time || current_time >= self . stop_time {
211- * o = 0. ;
212- } else {
213- // as we pick values directly from the offset param which is already
214- // computed at sub-sample accuracy, we don't need to do more than
215- // copying the values to their right place.
216- * o = value;
217- }
218-
219- current_time += dt;
220- } ) ;
204+
205+ // fast path
206+ if offset. len ( ) == 1
207+ && self . start_time <= scope. current_time
208+ && self . stop_time > next_block_time
209+ {
210+ output_channel. fill ( offset[ 0 ] ) ;
211+ } else {
212+ // sample accurate path
213+ let mut current_time = scope. current_time ;
214+
215+ output_channel
216+ . iter_mut ( )
217+ . zip ( offset. iter ( ) . cycle ( ) )
218+ . for_each ( |( o, & value) | {
219+ if current_time < self . start_time || current_time >= self . stop_time {
220+ * o = 0. ;
221+ } else {
222+ // as we pick values directly from the offset param which is already
223+ // computed at sub-sample accuracy, we don't need to do more than
224+ // copying the values to their right place.
225+ * o = value;
226+ }
227+
228+ current_time += dt;
229+ } ) ;
230+ }
221231
222232 // tail_time false when output has ended this quantum
223233 let still_running = self . stop_time >= next_block_time;
0 commit comments